opencode
opencode copied to clipboard
Nix build fails when shell completion generation produces empty output
Problem
The Nix build fails with the following error:
ERROR: installShellCompletion: installed shell completion file does not exist or has zero size
This occurs when:
- The
opencode completioncommand fails or returns empty output during the build - bash or zsh shells are not installed in the build environment
Expected Behavior
The Nix build should succeed even if shell completions cannot be generated. Shell completions are optional and their absence should not prevent the package from being built.
Proposed Solution
Make the shell completion installation resilient to failures by:
- Capturing completion output before installation
- Adding error handling with `|| true`
- Only installing completions if they contain actual content
- Using safe piping to avoid empty file errors
This issue might be a duplicate of or related to existing issues. Please check:
- #8962: Desktop build on nixos - Direct Nix build failure with IPC requests
- #5914: NixOS: custom tools fail because they cannot find imported modules - Module resolution issues in Nix builds
- #4853: When built from the flake, opencode package is extremely large (4GB+) - Nix flake configuration issues
- #6750: Intermittent empty output from Bash/Tool execution - Similar empty output problem
- #7207: opencode shell output empty - Related shell command output issues
- #7540: Does not build on Arch Linux - Related build environment failures
- #8188: [build from src] 'bun install' Failed in Docker - Similar environment-specific build issues
- #9273: Binary name collision blocks Nix packaging - Related Nix packaging blocker
Feel free to ignore if none of these address your specific case.