You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[RFC][direnv-inspired] introduce export and hook commands, use in devbox shell, global and direnv (#1172)
## Summary
See #1156 for overall motivation.
**In this PR:**
1. Turn off adding bin-wrappers path to $PATH from `devbox shellenv`.
2. We add commands `devbox hook` and `devbox export`, analogous to
`direnv hook` and `direnv export`.
- `export` is an alias of shellenv, and is hidden
- `hook` registers a shell prompt hook that wil call `eval $(devbox
export)`
3. During `devbox shell`, we add `eval $(devbox hook)` to the generated
shellrc file.
4. During `direnv`, the code is essentially unchanged except
calling`devbox export` instead of `devbox shellenv`.
5. For global, the users are currently expected to add `eval $(devbox
global hook <shell>)`
**RFC proposal to roll out:**
1. I don't think we need `devbox export`. We can continue with `devbox
shellenv`.
2. We can remove `devbox hook` entirely: in the generated shellrc, we
can inline the code of the hook that calls `devbox export`.
3. We can introduce `devbox global activate` to have the functionality
that `devbox global hook` has in this PR.
- `activate` is a generic word, enabling us to change its functionality
under-the-hood. It would save us the dilemma we have with this PR about
how to make users change their shellrc code from `devbox global
shellenv` to `devbox global hook`.
- We can make `devbox global shellenv` an alias of `devbox global
activate`. This would save users from needing to update their personal
shellrc files.
## How was it tested?
Added a feature flag: `DEVBOX_FEATURE_PROMPT_HOOK=1`.
Did some basic testing:
- project:
- `devbox shell` and then edited `devbox.json` to add a new package, and
saw the new package being installed prior to next prompt being
displayed.
- `devbox run -- iex -S mix` worked as expected, since we can turn off
the bin-wrappers.
- global:
- added `devbox global hook | source` to my fish shell.
- `devbox global ls` worked.
- `devbox global add <package>` worked as before.
**Note:** this PR adds the basic functionality, but the feature is not
yet robust. For a full list of pending scenarios that must work, please
refer to the (internal) notion doc.
&flags.pure, "pure", false, "If this flag is specified, devbox creates an isolated environment inheriting almost no variables from the current environment. A few variables, in particular HOME, USER and DISPLAY, are retained.")
0 commit comments