opencode icon indicating copy to clipboard operation
opencode copied to clipboard

fix(nix): make shell completion installation resilient to failures

Open jerome-benoit opened this issue 2 days ago • 8 comments

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 || true to prevent build failures if bash or zsh are not installed
  • Only install completions if they contain content (using -n test)
  • Use safe piping with echo instead 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 completion command 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.

jerome-benoit avatar Jan 18 '26 20:01 jerome-benoit