Skip to content

fix: stop modifying shell rc files in postinstall#801

Closed
jackwener wants to merge 1 commit intomainfrom
fix/postinstall-no-rc-modification
Closed

fix: stop modifying shell rc files in postinstall#801
jackwener wants to merge 1 commit intomainfrom
fix/postinstall-no-rc-modification

Conversation

@jackwener
Copy link
Copy Markdown
Owner

Summary

  • Remove all .zshrc / .bashrc modification logic from postinstall.js
  • Only write completion files to disk (~/.zsh/completions/_opencli, ~/.bash_completion.d/opencli, fish)
  • Print clear setup instructions telling the user what to add to their rc file

Motivation

The previous approach parsed .zshrc to find a compinit line and spliced fpath=(...) before it. This broke multi-line shell commands — e.g. zinit blocks where zicompinit matched /compinit/ inside a backslash-continued line, causing the insertion to split the command block and corrupt the user's shell config (#788).

Rather than trying to fix the parser (which can never be fully safe against arbitrary shell syntax), we adopt the approach used by rustup, homebrew, and other CLI tools: write the file, print the instructions, let the user decide where to put it.

Before → After

Shell Before After
zsh Wrote _opencli + modified .zshrc (splice/append) Writes _opencli + prints fpath/compinit instructions
bash Wrote opencli + modified .bashrc (append) Writes opencli + prints source instruction
fish Wrote opencli.fish (no rc change) Same — no change

Test plan

  • npm install -g prints completion setup instructions for zsh
  • .zshrc is not modified
  • .bashrc is not modified
  • Completion works after user manually adds the printed lines

Closes #788

Replace the fragile .zshrc/.bashrc modification logic with a safer
approach: only write completion files and print setup instructions.

The previous approach tried to parse and splice into rc files, which
broke multi-line shell commands (e.g. zinit blocks with backslash
continuations matching /compinit/). Instead of attempting to fix the
parser, remove rc modification entirely — this matches the approach
used by rustup, homebrew, and other CLI tools.

Closes #788
@jackwener
Copy link
Copy Markdown
Owner Author

Pushed the changes to PR #796 fork branch instead, as requested.

@jackwener jackwener closed this Apr 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: opencli --version reports 0.0.0 when installed from source + Failed to load module for user clis

1 participant