Skip to content

nix: build fails after CLI completion command change #50408

Closed

Description

@mindnbytes

Description

The Nix package on v2 still runs opencode completion in postInstall, but the Effect CLI now exposes completions through --completions <shell>.

completion is parsed as the optional directory argument, so the build consistently fails with:

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

Using opencode --completions bash and opencode --completions zsh fixes the build. I tested the complete package build locally on aarch64-linux; the generated Bash and Zsh scripts were nonempty and passed shell syntax checks.

Plugins

None

OpenCode version

Affected source: 2.0.12+b8aa08f (b8aa08f260130452dc87fbc20c2a4e2ff743e642)

Steps to reproduce

  1. Check out the v2 branch at b8aa08f260130452dc87fbc20c2a4e2ff743e642.
  2. Run nix build .#opencode -L.
  3. Observe the failure during completion installation.

Screenshot and/or share link

Not applicable; build log excerpt included above.

Operating System

NixOS, Linux 6.18.52, aarch64

Terminal

Ghostty

Activity

  1. LeoParkerOu commented on Sep 22, 2026

    @LeoParkerOu

    I’d like to work on this.

    I’ll update the v2 Nix packaging step to use the current --completions <shell> interface instead of the removed completion command. I’ll verify the generated Bash and Zsh completion files are non-empty and pass shell syntax checks, then run the relevant packaging checks before opening a PR.

  2. jerome-benoit commented on Sep 28, 2026

    @jerome-benoit
    Contributor

    Landed in #51891.

    While putting that together I hit a second problem on the same lines that the original report does not cover: the generated script hardcodes the command name, and that name is a build-time define (OPENCODE_CLI_NAME in packages/cli/script/build.ts), not something argv[0] can change. So opencode2 --completions bash does not produce opencode2 completions — it reproduces the opencode script byte for byte, and installShellCompletion --cmd opencode2 happily writes an identical file under the other name. The alias silently gets no completions.

    The fix runs the generator once and renames the output for the alias:

    installShellCompletion --cmd opencode2 \
      --bash <($out/bin/opencode --completions bash | sed 's/opencode/opencode2/g')

    I checked that the blanket replace is safe against the current output: every opencode occurrence in the generated bash, zsh and fish scripts is either the bare command name, a _opencode* helper, the ###-begin-…-completions-### markers, or the ~/.config/…/completions/_opencode path hint. Renaming all of them consistently is what you want for a second command name, and the markers and path hint are not parsed by anything.

    Verified on the built package: the two files are no longer identical, and each references only its own name.

    opencode.bash    31479 bytes   refs: opencode
    opencode2.bash   31579 bytes   refs: opencode2
    

    Fish is also installed now. The Effect CLI accepts --completions <bash|zsh|fish|sh> and fish was never wired up, though the script generates fine. sh is a synonym for bash — the two outputs are byte-identical — so --bash already covers it.

    Credit to @ReStranger in #51406, which was closed unmerged but had both of these; I got the alias wrong on my first pass.

  3. added 4 commits that reference this issue on Sep 28, 2026
    002ebbb
    fd912b2
    870ad46
    cc91747
  4. mindnbytes commented on Sep 29, 2026

    @mindnbytes
    Author

    My pull request from the week ago sovled this issue. Just want to make sure you've read the second post is mentioning PR. We just need maintainer attention here, I guess.

  5. added a commit that references this issue on Sep 29, 2026
    3a7985c
  6. mindnbytes commented on Oct 3, 2026

    @mindnbytes
    Author

    Fixed on v2 by #51891, merged October 2. The Nix package now uses the current --completions CLI flag and installs Bash, Zsh, and Fish completions.

  7. ReStranger commented on Oct 3, 2026

    @ReStranger
    Contributor

    Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions