PATH is not inherited from invoking shell
For example:
$ which node
/home/adam/.nvm/versions/node/v20.19.3/bin/node
$ bun dev # run opencode
Now if I type !which node into the opencode prompt, I get /usr/bin/node.
This issue might be a duplicate of existing issues. Please check:
- #197: Similar issue where opencode doesn't inherit the shell environment from node version managers (Volta in that case vs NVM in this case)
Feel free to ignore if none of these address your specific case.
Checked - not a duplicate.
I am also facing this now. I have Volta installed and other manager tool (mise) and in the terminal where I launch opencode, I see that in the $PATH mise is listed before volta, but when I am inside opencode I see that a new entry for volta was added in the beggining of the PATH. Where and why it is adding this ? How can I make it does not add ?
I assume there must be some sort of bug here: https://github.com/sst/opencode/blob/733e5cd876bb0a025bacbbd1aab7f8abf4e957f1/packages/opencode/src/session/prompt.ts#L1221
I looked at that code and was surprised to see it source-ing shell startup files like .zshenv, .zshrc, .bashrc in a non-standard way:
- Loading
.zshenvshould be superfluous for zsh, because it will automatically source this anyway. .zshrcand.bashrcare intended for use in interactive shells only.- Why is it using
-l? These are not login shells.
The second point might actually explain the root cause in my case, although I'm not sure of that yet. We already know from #2033 that bun can do strange things with its environment.