opencode
opencode copied to clipboard
fix(nix): make shell completion installation resilient to failures
Fixes #9285
Summary
Fixes Nix build failure when shell completion generation fails or produces empty output.
Changes
- Capture completion output before installation
- Add error handling with
|| trueto prevent build failures if bash or zsh are not installed - Only install completions if they contain content (using
-ntest) - Use safe piping with
echoinstead of direct command substitution - Add warning messages (following nixpkgs convention with ANSI color codes) when completion generation fails
Problem
The build was failing with:
ERROR: installShellCompletion: installed shell completion file does not exist or has zero size
This occurred when:
-
opencode completioncommand failed or returned empty output during the Nix build process - bash or zsh shells were not installed in the build environment
Solution
The completion installation is now optional and gracefully handles failures, allowing the build to succeed even if completions cannot be generated. Warning messages are displayed when completion generation fails.