PATH is not inherited from invoking shell #1457

Open
opened 2026-02-16 17:31:04 -05:00 by yindo · 5 comments
Owner

Originally created by @aspiers on GitHub (Aug 23, 2025).

Originally assigned to: @thdxr on GitHub.

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.

Originally created by @aspiers on GitHub (Aug 23, 2025). Originally assigned to: @thdxr on GitHub. 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`.
Author
Owner

@github-actions[bot] commented on GitHub (Aug 23, 2025):

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.

@github-actions[bot] commented on GitHub (Aug 23, 2025): 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.
Author
Owner

@aspiers commented on GitHub (Aug 23, 2025):

Checked - not a duplicate.

@aspiers commented on GitHub (Aug 23, 2025): Checked - not a duplicate.
Author
Owner

@trystan2k commented on GitHub (Nov 27, 2025):

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 ?

@trystan2k commented on GitHub (Nov 27, 2025): 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 ?
Author
Owner

@rekram1-node commented on GitHub (Dec 2, 2025):

I assume there must be some sort of bug here:
https://github.com/sst/opencode/blob/733e5cd876bb0a025bacbbd1aab7f8abf4e957f1/packages/opencode/src/session/prompt.ts#L1221

@rekram1-node commented on GitHub (Dec 2, 2025): I assume there must be some sort of bug here: https://github.com/sst/opencode/blob/733e5cd876bb0a025bacbbd1aab7f8abf4e957f1/packages/opencode/src/session/prompt.ts#L1221
Author
Owner

@aspiers commented on GitHub (Dec 12, 2025):

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:

  1. Loading .zshenv should be superfluous for zsh, because it will automatically source this anyway.
  2. .zshrc and .bashrc are intended for use in interactive shells only.
  3. 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.

@aspiers commented on GitHub (Dec 12, 2025): 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: 1. Loading `.zshenv` should be superfluous for zsh, because it will automatically source this anyway. 2. `.zshrc` and `.bashrc` are intended for use in interactive shells only. 3. 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.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1457