Skip to content

fix(install): create ~/.zshrc when it's missing so opencode lands on PATH - #57348

Draft
kitlangton wants to merge 1 commit into
devfrom
install-create-zshrc
Draft

kitlangton wants to merge 1 commit into
devfrom
install-create-zshrc

Conversation

@kitlangton

Copy link
Copy Markdown
Contributor

Today

A new Mac has no ~/.zshrc. When someone runs curl -fsSL https://opencode.ai/v2/install | bash on one, the installer finds no zsh config file, prints No config file found for zsh. You may need to manually add to PATH, and stops there. The next command they type, opencode, fails with command not found.

After

When none of the zsh (or fish) config files exist, the installer creates the shell's main one (${ZDOTDIR:-$HOME}/.zshrc, or ~/.config/fish/config.fish) and adds the PATH line to it as usual. Bash and other shells keep today's warning, because on macOS a login bash reads .bash_profile and guessing the wrong file would hide the problem.

How

install: before the "No config file found" branch, pick the shell's main config file, mkdir -p its folder and touch it. If either step fails, the old warning still prints.

Proof

On a throwaway HOME with SHELL=/bin/zsh and no dotfiles:

$ env -i HOME=/tmp/onb-home SHELL=/bin/zsh PATH=/usr/bin:/bin bash install
$ cat /tmp/onb-home/.zshrc

# opencode
export PATH=/tmp/onb-home/.opencode/bin:$PATH

A second run prints Command already exists in /tmp/onb-home/.zshrc, skipping write., and --no-modify-path still creates no files.

Risk

Low. It only runs when no candidate file exists, and only for zsh and fish. Undo is a one-line revert.

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant