Skip to content

fix(nix): use Effect CLI completion flags - #50409

Closed
mindnbytes wants to merge 2 commits into
anomalyco:v2from
mindnbytes:nix-completions
Closed

mindnbytes wants to merge 2 commits into
anomalyco:v2from
mindnbytes:nix-completions

Conversation

@mindnbytes

Copy link
Copy Markdown

Issue for this PR

Fixes #50408

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Updates the Nix package to generate completions with Effect CLI's --completions <shell> flag instead of the removed yargs completion command.

The generated command name is compiled as opencode, so the compatibility alias scripts substitute opencode2 before installation.

How did you verify your code works?

  • nix build .#opencode -L on aarch64-linux
  • ran both packaged binaries with --version
  • confirmed all Bash and Zsh completion files are nonempty
  • checked the scripts with bash -n and zsh -n
  • confirmed alias scripts register opencode2

Screenshots / recordings

N/A

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

@mindnbytes

Copy link
Copy Markdown
Author

Fixes #50408 is included in the PR description. The needs:issue label appears to be a false positive because this PR targets v2 rather than the default branch.

jerome-benoit added a commit to jerome-benoit/opencode that referenced this pull request Sep 28, 2026
Three independent defects in the v2 Nix packaging, each fatal to
`nix build .#opencode` or `nix build .#opencode-desktop`.

`nix/opencode.nix` generates completions through `opencode completion`, a
subcommand v2 no longer has. The Effect CLI parses it as the optional
`directory` argument and the TUI opens instead, so `installShellCompletion`
gets a zero-size file and the build fails:

    Error: ENOENT: no such file or directory, chdir '/build/source/packages/cli' -> 'completion'
    ERROR: installShellCompletion: installed shell completion file .../opencode.bash does not exist or has zero size

Completions now come from the Effect-CLI global action flag,
`--completions <bash|zsh|fish|sh>`. Naming the shell directly also drops
the `SHELL=/bin/zsh` coaxing the old yargs-based path needed. `sh` is a
synonym for `bash`, so `--bash` already covers it; fish did not ship
before even though the CLI generates it.

Each shell is staged to a file before installation. A process substitution
does not propagate the generator's exit status, so a failure here would
install a zero-size completion and still pass — which is how the bug above
presented in the first place.

The command name is a build-time define, so `opencode2 --completions` just
reproduces the `opencode` scripts. They are renamed for the alias with
`substitute --replace-fail`, so a future change to the baked-in name breaks
the build instead of quietly shipping a second copy of the opencode one.

`nix/electron.nix` still carries the electron 42.10.1 hashes while
`packages/desktop/package.json` moved to 44.4.3, so the desktop's electron
fetchzip cannot resolve. The hashes are refreshed from the 44.4.3
SHASUMS256.txt; the headers hash is the fetchzip recursive hash, computed
the same way the 42.10.1 one was (reproducing the previous value as a
control). The x86_64-darwin entry is dropped: nixpkgs' electron `tags` has
no such platform and `get` throws for it, so the value was never selected.

`nix/desktop.nix` stages the CLI executable but not the package manifest
next to it, and `packages/desktop/scripts/utils.ts` reads the bundled CLI's
version from that manifest. The desktop build aborts in `scripts/prebuild.ts`:

    ENOENT: no such file or directory, open '/build/desktop-cli/cli-linux-x64-baseline/package.json'

The manifest is now written alongside the executable, so the version file
the desktop ships resolves without spawning the binary.

Fixes anomalyco#50408

Co-developed-by: @ReStranger (anomalyco#51406), @mindnbytes (anomalyco#50409)
jerome-benoit added a commit to jerome-benoit/opencode that referenced this pull request Sep 28, 2026
Three independent defects in the v2 Nix packaging, each fatal to
`nix build .#opencode` or `nix build .#opencode-desktop`.

`nix/opencode.nix` generates completions through `opencode completion`, a
subcommand v2 no longer has. The Effect CLI parses it as the optional
`directory` argument and the TUI opens instead, so `installShellCompletion`
gets a zero-size file and the build fails:

    Error: ENOENT: no such file or directory, chdir '/build/source/packages/cli' -> 'completion'
    ERROR: installShellCompletion: installed shell completion file .../opencode.bash does not exist or has zero size

Completions now come from the Effect-CLI global action flag,
`--completions <bash|zsh|fish|sh>`. Naming the shell directly also drops
the `SHELL=/bin/zsh` coaxing the old yargs-based path needed. `sh` is a
synonym for `bash`, so `--bash` already covers it; fish did not ship
before even though the CLI generates it.

Each shell is staged to a file before installation. A process substitution
does not propagate the generator's exit status, so a failure here would
install a zero-size completion and still pass — which is how the bug above
presented in the first place.

The command name is a build-time define, so `opencode2 --completions` just
reproduces the `opencode` scripts. They are renamed for the alias with
`substitute --replace-fail`, so a future change to the baked-in name breaks
the build instead of quietly shipping a second copy of the opencode one.

`nix/electron.nix` still carries the electron 42.10.1 hashes while
`packages/desktop/package.json` moved to 44.4.3, so the desktop's electron
fetchzip cannot resolve. The hashes are refreshed from the 44.4.3
SHASUMS256.txt; the headers hash is the fetchzip recursive hash, computed
the same way the 42.10.1 one was (reproducing the previous value as a
control). The x86_64-darwin entry is dropped: nixpkgs' electron `tags` has
no such platform and `get` throws for it, so the value was never selected.

`nix/desktop.nix` stages the CLI executable but not the package manifest
next to it, and `packages/desktop/scripts/utils.ts` reads the bundled CLI's
version from that manifest. The desktop build aborts in `scripts/prebuild.ts`:

    ENOENT: no such file or directory, open '/build/desktop-cli/cli-linux-x64-baseline/package.json'

The manifest is now written alongside the executable, so the version file
the desktop ships resolves without spawning the binary.

Fixes anomalyco#50408

Co-developed-by: @ReStranger (anomalyco#51406), @mindnbytes (anomalyco#50409)
jerome-benoit added a commit to jerome-benoit/opencode that referenced this pull request Sep 28, 2026
Three independent defects in the v2 Nix packaging, each fatal to
`nix build .#opencode` or `nix build .#opencode-desktop`.

`nix/opencode.nix` generates completions through `opencode completion`, which
v2 removed: the Effect CLI parses it as the optional `directory` argument, so
the TUI opens instead and `installShellCompletion` gets a zero-size file. It
now uses the global `--completions <shell>` flag, stages each shell to a file
so a generator failure fails the build, and renames the `opencode2` copies
because the command name is a build-time define. Fish ships now; `sh` is a
synonym for `bash`.

`nix/electron.nix` carries the electron 42.10.1 hashes while
`packages/desktop/package.json` moved to 44.4.3, so the desktop's electron
fetchzip cannot resolve. Refreshed from the 44.4.3 SHASUMS256.txt; the
headers hash recomputed the same way the 42.10.1 one was, reproducing it as
a control. The x86_64-darwin entry is dropped, nixpkgs' electron tags have
no such platform.

`nix/desktop.nix` stages the CLI executable but not the manifest that
`packages/desktop/scripts/utils.ts` reads the version from, so
`scripts/prebuild.ts` aborts on a missing package.json.

Fixes anomalyco#50408

Co-developed-by: @ReStranger (anomalyco#51406), @mindnbytes (anomalyco#50409)
@mindnbytes

Copy link
Copy Markdown
Author

Superseded by #51891, which merged the v2 completion fix (including opencode2 and Fish). Thanks!

@mindnbytes mindnbytes closed this Oct 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant