troubleshooting.mdx 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. ---
  2. title: Troubleshooting
  3. description: Common issues and how to resolve them.
  4. ---
  5. To debug any issues with OpenCode, you can check the logs or the session data
  6. that it stores locally.
  7. ---
  8. ### Logs
  9. Log files are written to:
  10. - **macOS/Linux**: `~/.local/share/opencode/log/`
  11. - **Windows**: `%USERPROFILE%\.local\share\opencode\log\`
  12. Log files are named with timestamps (e.g., `2025-01-09T123456.log`) and the most recent 10 log files are kept.
  13. You can set the log level with the `--log-level` command-line option to get more detailed debug information. For example, `opencode --log-level DEBUG`.
  14. ---
  15. ### Storage
  16. opencode stores session data and other application data on disk at:
  17. - **macOS/Linux**: `~/.local/share/opencode/`
  18. - **Windows**: `%USERPROFILE%\.local\share\opencode`
  19. This directory contains:
  20. - `auth.json` - Authentication data like API keys, OAuth tokens
  21. - `log/` - Application logs
  22. - `project/` - Project-specific data like session and message data
  23. - If the project is within a Git repo, it is stored in `./<project-slug>/storage/`
  24. - If it is not a Git repo, it is stored in `./global/storage/`
  25. ---
  26. ## Getting help
  27. If you're experiencing issues with OpenCode:
  28. 1. **Report issues on GitHub**
  29. The best way to report bugs or request features is through our GitHub repository:
  30. [**github.com/anomalyco/opencode/issues**](https://github.com/anomalyco/opencode/issues)
  31. Before creating a new issue, search existing issues to see if your problem has already been reported.
  32. 2. **Join our Discord**
  33. For real-time help and community discussion, join our Discord server:
  34. [**opencode.ai/discord**](https://opencode.ai/discord)
  35. ---
  36. ## Common issues
  37. Here are some common issues and how to resolve them.
  38. ---
  39. ### OpenCode won't start
  40. 1. Check the logs for error messages
  41. 2. Try running with `--print-logs` to see output in the terminal
  42. 3. Ensure you have the latest version with `opencode upgrade`
  43. ---
  44. ### Authentication issues
  45. 1. Try re-authenticating with the `/connect` command in the TUI
  46. 2. Check that your API keys are valid
  47. 3. Ensure your network allows connections to the provider's API
  48. ---
  49. ### Model not available
  50. 1. Check that you've authenticated with the provider
  51. 2. Verify the model name in your config is correct
  52. 3. Some models may require specific access or subscriptions
  53. If you encounter `ProviderModelNotFoundError` you are most likely incorrectly
  54. referencing a model somewhere.
  55. Models should be referenced like so: `<providerId>/<modelId>`
  56. Examples:
  57. - `openai/gpt-4.1`
  58. - `openrouter/google/gemini-2.5-flash`
  59. - `opencode/kimi-k2`
  60. To figure out what models you have access to, run `opencode models`
  61. ---
  62. ### ProviderInitError
  63. If you encounter a ProviderInitError, you likely have an invalid or corrupted configuration.
  64. To resolve this:
  65. 1. First, verify your provider is set up correctly by following the [providers guide](/docs/providers)
  66. 2. If the issue persists, try clearing your stored configuration:
  67. ```bash
  68. rm -rf ~/.local/share/opencode
  69. ```
  70. 3. Re-authenticate with your provider using the `/connect` command in the TUI.
  71. ---
  72. ### AI_APICallError and provider package issues
  73. If you encounter API call errors, this may be due to outdated provider packages. opencode dynamically installs provider packages (OpenAI, Anthropic, Google, etc.) as needed and caches them locally.
  74. To resolve provider package issues:
  75. 1. Clear the provider package cache:
  76. ```bash
  77. rm -rf ~/.cache/opencode
  78. ```
  79. 2. Restart opencode to reinstall the latest provider packages
  80. This will force opencode to download the most recent versions of provider packages, which often resolves compatibility issues with model parameters and API changes.
  81. ---
  82. ### Copy/paste not working on Linux
  83. Linux users need to have one of the following clipboard utilities installed for copy/paste functionality to work:
  84. **For X11 systems:**
  85. ```bash
  86. apt install -y xclip
  87. # or
  88. apt install -y xsel
  89. ```
  90. **For Wayland systems:**
  91. ```bash
  92. apt install -y wl-clipboard
  93. ```
  94. **For headless environments:**
  95. ```bash
  96. apt install -y xvfb
  97. # and run:
  98. Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
  99. export DISPLAY=:99.0
  100. ```
  101. opencode will detect if you're using Wayland and prefer `wl-clipboard`, otherwise it will try to find clipboard tools in order of: `xclip` and `xsel`.