Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot set PATH env var in both a plugin and devbox.json #2138

Open
jay-aye-see-kay opened this issue Jun 11, 2024 · 0 comments · May be fixed by #2418
Open

Cannot set PATH env var in both a plugin and devbox.json #2138

jay-aye-see-kay opened this issue Jun 11, 2024 · 0 comments · May be fixed by #2418
Assignees
Labels
bug Something isn't working

Comments

@jay-aye-see-kay
Copy link
Contributor

What happened?

Setting PATH in a project's devbox.json#env will override that setting in made in any plugins. I haven't tested what happens if two plugins try to set PATH but expect it would be a "last wins" situation.

A workaround is to set PATH in shell.init_hook rather than in env. This is a bit more verbose but appears to always work as expected. A quick fix for the ruby plugin might be to do this, i.e.

 "shell": {
      "init_hook": [
          "export PATH=\"{{ .Virtenv }}/bin:$PATH\""
      ]
  }

Ideally env vars in plugins would be expanded sequentially so that PATH could be modified by multiple plugins. But I'm not sure how difficult that would be to implement.

Steps to reproduce

  1. setup temp project: cd $(mktemp -d) && devbox init && devbox generate direnv
  2. add ruby (the only built in plugin that sets env.PATH): devbox add ruby
  3. OBSERVE ruby plugin has prepended a dir to the PATH: echo $PATH | grep ".devbox/virtenv/ruby/bin"
  4. add "env": { "PATH": "/path/to/my/bin:$PATH" } to devbox.json
  5. OBSERVE path has been prepended as expected echo $PATH | grep "/path/to/my/bin"
  6. OBSERVE BUG ruby plugin's change to PATH has been overwritten: echo $PATH | grep ".devbox/virtenv/ruby/bin" (no result)

Command

No response

devbox.json

{
  "packages": ["ruby@latest"],
  "env": {
    "PATH": "/path/to/my/bin:$PATH"
  }
}

Devbox version

0.11.0

Nix version

2.18.1

What system does this bug occur on?

macOS (Apple Silicon)

Debug logs

No response

@jay-aye-see-kay jay-aye-see-kay added bug Something isn't working triage Issue needs triage labels Jun 11, 2024
@mohsenari mohsenari linked a pull request Nov 21, 2024 that will close this issue
@mohsenari mohsenari self-assigned this Nov 21, 2024
@mohsenari mohsenari removed the triage Issue needs triage label Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging a pull request may close this issue.

2 participants