Skip to content

PATH is not inherited from invoking shell #2202

Closed

Description

@aspiers

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.

Activity

  1. github-actions commented on Aug 23, 2025

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Feel free to ignore if none of these address your specific case.

  2. aspiers commented on Aug 23, 2025

    @aspiers
    ContributorAuthor

    Checked - not a duplicate.

  3. trystan2k commented on Nov 27, 2025

    @trystan2k

    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 ?

  4. rekram1-node commented on Dec 2, 2025

    @rekram1-node
    Contributor
  5. aspiers commented on Dec 12, 2025

    @aspiers
    ContributorAuthor

    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 up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions