Description
OpenCode hangs silently — both TUI and opencode run CLI — when launched from a non-git directory that contains a large subtree (e.g. ML dataset, millions of files). The documented watcher.ignore config option does not prevent the hang. Only an actual .gitignore inside a real .git repo avoids it.
Reproduction
Fresh directory with a large data subtree, no git repo:
mkdir /tmp/oc-repro && cd /tmp/oc-repro
# (populate /tmp/oc-repro/data/ with a lot of files, e.g. an ML dataset —
# in my case ~millions of files in data/ under /media/ffarhat/data01/drafter-test)
~/.config/opencode/opencode.json has:
{
"$schema": "https://opencode.ai/config.json",
"model": "ollama/qwen2.5-coder:7b",
"snapshot": false,
"watcher": {
"ignore": [
"node_modules/**",
".git/**",
"data/**",
"datasets/**",
"logs/**"
]
},
"provider": { "...": "..." }
}
Then:
cd /tmp/oc-repro
opencode run -m ollama/qwen2.5-coder:7b "Reply: OK"
Expected: OK within a few seconds (as happens in any clean dir).
Actual: Hangs after printing > build · qwen2.5-coder:7b. No response, no error, no timeout on opencode's side — times out on mine.
State matrix
.git? |
.gitignore with data/? |
opencode.json.watcher.ignore with data/**? |
Result |
| yes |
yes |
yes |
✓ works (returns response quickly) |
| yes |
no |
yes |
✗ hangs |
| no |
no |
yes |
✗ hangs |
| no |
yes (file present without .git) |
yes |
✗ hangs (not tested in this matrix but implied) |
Only the .git + .gitignore combination fixes it. watcher.ignore in opencode.json appears non-functional for this purpose, or only filters events after enumeration.
Debug log from the hanging case
INFO ... service=file.watcher directory=/media/ffarhat/data01/drafter-test init
INFO ... service=file.watcher directory=/media/ffarhat/data01/drafter-test platform=linux backend=inotify watcher backend
INFO ... service=provider providerID=ollama found
INFO ... service=session.prompt status=started resolveTools
INFO ... service=tool.registry status=completed duration=0 bash
[stops here — no further output for 30+ seconds]
Log stops mid-tool-registration, implying the watcher setup (inotify recursion?) is blocking the event loop. data/ in that tree has millions of files; inotify would need a watch per directory.
Environment
- OpenCode 1.4.10 (also reproduced on 1.4.7)
- Ubuntu 24.04.4 LTS, kernel 6.x
- Installed via official
https://opencode.ai/install script
- Ollama backend, but same behavior with
--pure
Workaround
Initialize a git repo in the heavy dir and add a .gitignore:
git init
printf 'data/\nlogs/\n' > .gitignore
Works immediately.
Suggested fix
Either:
- Make
watcher.ignore actually prevent inotify watches being added for matching paths (not just filter events after the fact), or
- Document clearly that
watcher.ignore does not apply to initial watch setup and a .gitignore is required, or
- Add a hard timeout on initial watcher setup to surface the problem explicitly rather than hanging indefinitely.
Happy to test a patched build if helpful.
Description
OpenCode hangs silently — both TUI and
opencode runCLI — when launched from a non-git directory that contains a large subtree (e.g. ML dataset, millions of files). The documentedwatcher.ignoreconfig option does not prevent the hang. Only an actual.gitignoreinside a real.gitrepo avoids it.Reproduction
Fresh directory with a large data subtree, no git repo:
~/.config/opencode/opencode.jsonhas:{ "$schema": "https://opencode.ai/config.json", "model": "ollama/qwen2.5-coder:7b", "snapshot": false, "watcher": { "ignore": [ "node_modules/**", ".git/**", "data/**", "datasets/**", "logs/**" ] }, "provider": { "...": "..." } }Then:
Expected:
OKwithin a few seconds (as happens in any clean dir).Actual: Hangs after printing
> build · qwen2.5-coder:7b. No response, no error, no timeout on opencode's side — times out on mine.State matrix
.git?.gitignorewithdata/?opencode.json.watcher.ignorewithdata/**?Only the
.git+.gitignorecombination fixes it.watcher.ignoreinopencode.jsonappears non-functional for this purpose, or only filters events after enumeration.Debug log from the hanging case
Log stops mid-tool-registration, implying the watcher setup (inotify recursion?) is blocking the event loop.
data/in that tree has millions of files; inotify would need a watch per directory.Environment
https://opencode.ai/installscript--pureWorkaround
Initialize a git repo in the heavy dir and add a
.gitignore:Works immediately.
Suggested fix
Either:
watcher.ignoreactually prevent inotify watches being added for matching paths (not just filter events after the fact), orwatcher.ignoredoes not apply to initial watch setup and a.gitignoreis required, orHappy to test a patched build if helpful.