From b019b86f1e5676a0be23cd0549d95d169c7c8ac7 Mon Sep 17 00:00:00 2001 From: Javis Date: Thu, 12 Mar 2026 16:41:49 +0800 Subject: [PATCH] fix(install): prioritize .bash_profile over .bashrc on macOS On macOS, Terminal.app and iTerm open login shells by default, which source ~/.bash_profile but not ~/.bashrc. The installer was checking ~/.bashrc first, causing the PATH export to be written to a file that's never sourced in new terminal sessions. This commit reorders the config file candidates for bash on macOS to check ~/.bash_profile first, ensuring the opencode PATH is correctly set for login shells. Linux behavior is unchanged since non-login interactive shells (the default for most terminal emulators) source ~/.bashrc. Fixes #17132 --- install | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/install b/install index b0716d53208..d80fc3f9ce6 100755 --- a/install +++ b/install @@ -386,7 +386,13 @@ case $current_shell in config_files="${ZDOTDIR:-$HOME}/.zshrc ${ZDOTDIR:-$HOME}/.zshenv $XDG_CONFIG_HOME/zsh/.zshrc $XDG_CONFIG_HOME/zsh/.zshenv" ;; bash) - config_files="$HOME/.bashrc $HOME/.bash_profile $HOME/.profile $XDG_CONFIG_HOME/bash/.bashrc $XDG_CONFIG_HOME/bash/.bash_profile" + # On macOS, Terminal.app and iTerm open login shells which source .bash_profile, + # not .bashrc. Prioritize .bash_profile on macOS to ensure PATH is set correctly. + if [[ "$OSTYPE" == "darwin"* ]]; then + config_files="$HOME/.bash_profile $HOME/.bashrc $HOME/.profile $XDG_CONFIG_HOME/bash/.bash_profile $XDG_CONFIG_HOME/bash/.bashrc" + else + config_files="$HOME/.bashrc $HOME/.bash_profile $HOME/.profile $XDG_CONFIG_HOME/bash/.bashrc $XDG_CONFIG_HOME/bash/.bash_profile" + fi ;; ash) config_files="$HOME/.ashrc $HOME/.profile /etc/profile"