Documentation Index Fetch the complete documentation index at: https://mintlify.com/opencode-ai/opencode/llms.txt
Use this file to discover all available pages before exploring further.
This guide covers common issues you might encounter while using OpenCode and their solutions.
Installation issues
Command not found: opencode
Symptoms: Running opencode returns “command not found”Solution:
Verify installation
Check if OpenCode is installed:
Update PATH
If installed via Go: # Add to ~/.bashrc or ~/.zshrc
export PATH = " $PATH : $HOME /go/bin"
Then reload your shell: source ~/.bashrc # or ~/.zshrc
Reinstall if necessary
Try reinstalling OpenCode: # Using Homebrew
brew reinstall opencode-ai/tap/opencode
# Using Go
go install github.com/opencode-ai/opencode@latest
Symptoms: Permission errors when installing or running OpenCodeSolution: # If installed globally, ensure proper permissions
sudo chown -R $( whoami ) /usr/local/bin/opencode
# Or install for current user only
go install github.com/opencode-ai/opencode@latest
Configuration issues
Symptoms: OpenCode doesn’t find your configuration fileSolution: OpenCode looks for configuration in these locations (in order):
./.opencode.json (current directory)
$XDG_CONFIG_HOME/opencode/.opencode.json
$HOME/.opencode.json
Create a config file in one of these locations: # Option 1: Home directory
touch ~/.opencode.json
# Option 2: XDG config directory
mkdir -p ~/.config/opencode
touch ~/.config/opencode/.opencode.json
Invalid JSON in config file
Symptoms: OpenCode fails to start with JSON parsing errorSolution: Validate your JSON: # Use jq to validate and format
jq . ~/.opencode.json
Common JSON errors:
Missing commas between properties
Trailing commas (not allowed in JSON)
Unquoted keys or values
Unclosed brackets or braces
Example of valid JSON: {
"providers" : {
"anthropic" : {
"apiKey" : "your-key" ,
"disabled" : false
}
}
}
Model not found or unsupported
Symptoms: Error message about unsupported or unavailable modelSolution:
Verify provider is configured
Check that the provider for your model is properly configured: # For Anthropic
echo $ANTHROPIC_API_KEY
# For OpenAI
echo $OPENAI_API_KEY
Check provider status
Ensure the provider isn’t disabled: {
"providers" : {
"anthropic" : {
"disabled" : false // Should be false
}
}
}
Provider and API issues
Symptoms: Authentication errors with your API keySolution:
Verify API key is valid
Check for extra spaces or newlines
Ensure the key hasn’t expired
Verify the key has the correct permissions
Check environment variables
# List all OpenCode-related env vars
env | grep -E '(ANTHROPIC|OPENAI|GEMINI|GITHUB)'
Test API key directly
Test your API key with curl: # Anthropic
curl https://api.anthropic.com/v1/messages \
-H "x-api-key: $ANTHROPIC_API_KEY " \
-H "content-type: application/json" \
-d '{"model":"claude-4-sonnet-20250514","max_tokens":10,"messages":[{"role":"user","content":"Hi"}]}'
# OpenAI
curl https://api.openai.com/v1/models \
-H "Authorization: Bearer $OPENAI_API_KEY "
Symptoms: Error messages about rate limits or too many requestsSolution: OpenCode automatically retries rate-limited requests with exponential backoff (up to 8 retries). If you continue to hit rate limits:
Wait: Rate limits typically reset after a few minutes
Upgrade: Consider upgrading your API tier
Reduce load: Use smaller models for simple tasks
Monitor usage: Check your API usage dashboard
OpenCode respects Retry-After headers and implements exponential backoff automatically.
Symptoms: Requests timeout or hang indefinitelySolution:
Check network connection
Verify you can reach the API: ping api.anthropic.com
ping api.openai.com
Check firewall and proxy settings
Ensure your firewall allows HTTPS traffic
If behind a corporate proxy, configure proxy settings
Check VPN isn’t blocking API access
Verify API status
Check provider status pages:
Symptoms: Error about exceeding maximum context lengthSolution: This error occurs when your conversation exceeds the model’s context window.
Options:
Enable auto-compact (enabled by default):
This automatically summarizes your conversation when approaching the limit.
Manually compact the session using Ctrl+K → “Compact Session”
Start a new session with Ctrl+N
Use a model with a larger context window :
Claude 4 Sonnet: 200K tokens
Gemini 2.5: 1M tokens
GPT-4.1: 128K tokens
GitHub Copilot issues
Symptoms: OpenCode can’t find your GitHub Copilot tokenSolution:
Authenticate with GitHub CLI
Or set token explicitly
export GITHUB_TOKEN = "ghp_your_token_here"
Verify token location
Check that the token file exists: ls -la ~/.config/github-copilot/
See the GitHub Copilot guide for more details.
Copilot token exchange failed
Symptoms: Error exchanging GitHub token for Copilot bearer tokenSolution:
Ensure Copilot chat is enabled in your GitHub settings
Verify your Copilot subscription is active
Check that your GitHub token has Copilot permissions
Try re-authenticating with the GitHub CLI
Self-hosted model issues
Cannot connect to local endpoint
Symptoms: Connection refused to local model endpointSolution:
Verify server is running
# Check if the port is listening
netstat -an | grep :1234
# or
lsof -i :1234
Test endpoint
curl http://localhost:1234/v1/models
Check LOCAL_ENDPOINT variable
echo $LOCAL_ENDPOINT
# Should output: http://localhost:1234/v1
See the self-hosted models guide for more details.
Model doesn't support tool calling
Shell and command execution issues
Commands not found in shell
Symptoms: Tools like npm, python, or custom scripts aren’t foundSolution: Use a login shell to load your PATH: {
"shell" : {
"path" : "/bin/bash" ,
"args" : [ "-l" ]
}
}
See the shell configuration guide for more details.
Environment variables not available
Symptoms: Environment variables set in your profile aren’t availableSolution: Ensure variables are exported in your profile: export NODE_PATH = "/usr/local/lib/node_modules"
export PATH = " $HOME /.local/bin: $PATH "
And use a login shell configuration.
Command execution timeout
Symptoms: Long-running commands are killedSolution: OpenCode uses a default timeout of 2 minutes for commands. For long-running operations:
Break down the operation into smaller steps
Ask OpenCode to run the command with explicit timeout handling
Consider running the command outside of OpenCode for very long operations
Database and session issues
Symptoms: SQLite database lock errorsSolution: This usually means another OpenCode instance is running.
Close other instances
Check for running OpenCode processes: Kill any orphaned processes:
Symptoms: Previous conversations don’t appearSolution: Check the database file exists: ls -la ~/.opencode/opencode.db
If the database is corrupted, you may need to remove it (this will delete all sessions): # Backup first
cp ~/.opencode/opencode.db ~/.opencode/opencode.db.backup
# Remove corrupted database
rm ~/.opencode/opencode.db
Symptoms: Session switching (Ctrl+A) doesn’t workSolution:
Ensure you have multiple sessions created
Try creating a new session with Ctrl+N first
Check if the database is accessible
Restart OpenCode
Symptoms: OpenCode takes a long time to startSolution:
Check shell startup time
Your shell profile might be slow to load: time bash -l -c 'echo loaded'
Optimize shell profile
Remove unnecessary initialization
Lazy-load plugins and tools
Profile your shell config to find slow parts
Check database size
Large databases can slow startup: ls -lh ~/.opencode/opencode.db
Consider archiving old sessions.
Symptoms: OpenCode uses excessive memorySolution:
Use models with smaller context windows
Compact long sessions
Restart OpenCode periodically
Check for memory leaks (report as a bug if persistent)
Symptoms: Responses take a long time to generateSolution:
Use faster models (e.g., GPT-4o Mini, Claude Haiku)
Reduce maxTokens for faster responses
Check your network connection
Consider using a different provider or region
LSP integration issues
Symptoms: Language server features don’t workSolution:
Verify LSP server is installed
which gopls # for Go
which typescript-language-server # for TypeScript
Check LSP configuration
{
"lsp" : {
"go" : {
"disabled" : false ,
"command" : "gopls"
}
}
}
Enable LSP debug logging
Then check logs with Ctrl+L
LSP diagnostics not showing
Symptoms: OpenCode doesn’t show code errors or warningsSolution:
Ensure the LSP server supports diagnostics
Check that files are saved (LSP typically works on saved files)
Verify the language server is properly initialized
Try restarting OpenCode
Getting help
If you’re still experiencing issues:
Enable debug mode Run OpenCode with debug logging: View logs with Ctrl+L
Report a bug Create a new issue with:
OpenCode version
Operating system
Error messages
Debug logs
Join the community Get help from other users and contributors in discussions.
Useful debug commands
# Check OpenCode version
opencode --version
# Run with debug output
opencode -d
# Check configuration
cat ~/.opencode.json | jq .
# Verify environment variables
env | grep -E '(ANTHROPIC|OPENAI|GEMINI|GITHUB|AWS|AZURE)'
# Test API connectivity
curl https://api.anthropic.com/v1/messages -I
curl https://api.openai.com/v1/models -I
# Check database
ls -lh ~/.opencode/opencode.db
sqlite3 ~/.opencode/opencode.db "SELECT COUNT(*) FROM sessions;"
# View recent logs
tail -f ~/.opencode/debug.log # if OPENCODE_DEV_DEBUG=true