anomalyco / anomalyco/opencode
Auto-update via Homebrew runs `brew upgrade opencode`, which triggers `brew cleanup` + `brew autoremove` and removed Node.js (and 16 other formulae) from my machine
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Description
opencode installed from Homebrew core (brew install opencode) upgraded itself on startup
(1.17.10 → 1.18.30_1) by running brew upgrade opencode. Homebrew ran its periodic
brew cleanup inside that upgrade ("has not been run in the last 30 days") and then
Autoremoving 17 unneeded formulae, which uninstalled node (installed earlier as a dependency
of another formula, so installed_on_request: false) together with llhttp, libuv, simdjson,
brotli, libnghttp3, libngtcp2 and the rest of node's dependency tree.
Result: /opt/homebrew/bin/node, npm, npx disappeared, pnpm (a shebang script) failed
with env: node: No such file or directory, and every tool on the machine that shells out to
node broke. Nothing asked for confirmation; the only trace is one INFO line in
~/.local/share/opencode/log/opencode.log. It took a while to find, because the user never
typed brew that day.
On top of that, the version it upgraded to (1.18.30 from Homebrew core) is the one affected by
#48645 / #48811 (TypeError: undefined is not an object (evaluating 'a.name') on every prompt),
so the silent upgrade both broke opencode and removed Node.js.
Environment
- opencode 1.17.10 → 1.18.30_1, installed from Homebrew core (
/opt/homebrew/bin/opencode) - macOS 26.6.2 (Darwin 25.6.0), arm64
- Homebrew 7.0.4
- No
autoupdatekey inopencode.jsonc(default behaviour)
Steps to reproduce
brew install opencode(Homebrew core formula), with an older version installed.- Have
nodeon the machine as a dependency-only formula (installed_on_request: false),
e.g. pulled in by another formula, and nobrew cleanupfor 30 days. - Start
opencodein a project. - opencode runs
brew upgrade opencode; Homebrew runsbrew cleanupand autoremove.
Log excerpt (opencode.log, run 90a5680b)
timestamp=2026-09-18T09:17:06.589Z level=INFO run=90a5680b message=upgraded method=brew target=1.18.30 stdout="==> Would upgrade 2 dependencies for opencode:
pcre2 10.47_1 -> 10.48
ripgrep 15.1.0 -> 15.2.0
==> Would upgrade 1 outdated package
opencode 1.17.10 -> 1.18.30_1 (46MB)
==> Upgrading opencode
1.17.10 -> 1.18.30_1
==> Installing dependencies for opencode: pcre2 and ripgrep
...
==> Running `brew cleanup opencode`...
Disable this behaviour by setting `HOMEBREW_NO_INSTALL_CLEANUP=1`.
...
==> `brew cleanup` has not been run in the last 30 days, running now...
...
==> Autoremoving 17 unneeded formulae:
ada-url brotli c-ares fmt hdrhistogram_c libffi libnghttp2 libnghttp3 libngtcp2 libuv llhttp
merve nbytes node simdjson simdutf uvwasi
Uninstalling /opt/homebrew/Cellar/node/26.4.0... (2,071 files, 92MB)
Uninstalling /opt/homebrew/Cellar/llhttp/9.4.2... (15 files, 165KB)
...
Expected behaviour
Either of:
- Do not run
brew upgradeimplicitly at all for the Homebrew install method; print
"new version available, runbrew upgrade opencode" instead (the upgrade is a package-manager
operation with side effects on unrelated packages). - If the auto-upgrade stays, run it with
HOMEBREW_NO_INSTALL_CLEANUP=1and
HOMEBREW_NO_AUTOREMOVE=1in the environment, so that it only touches opencode and its own
dependencies, and ask for confirmation first (the TUI is interactive at that point).
Also worth logging the upgrade at a visible level (a toast or a WARN line), not only INFO.
Workaround
"autoupdate": false in opencode.jsonc, and brew install node to get Node back
(installed_on_request becomes true, so autoremove no longer targets it).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Locate the Homebrew auto-update path used when the default autoupdate behavior runs, along with the opencode.jsonc autoupdate setting. Reproduce the upgrade with a dependency-only Node.js installation and an overdue Homebrew cleanup. Done means the chosen behavior prevents unrelated cleanup/autoremove side effects, requests confirmation where applicable, and makes the upgrade visible beyond an INFO log.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- macos, node.js, typescript
- Domain
- cli, devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100