Skip to content

Commit d4bfa86

Browse files
authored
[direnv] Fix a bug with devbox shell enabled & direnv (#460)
## Summary With recent changes to direnv integration. cd-ing into a direnv integration devbox project would prevent the user to run `devbox shell`. That is because the env variable `DEVBOX_SHELL_ENABLED` gets set alongside others with direnv integration even though the user may not be inside a devbox shell. This change keeps a back up of the value of `DEVBOX_SHELL_ENABLED` before letting direnv make any changes to env variables. Then puts the backed up value back for `DEVBOX_SHELL_ENABLED`. ## How was it tested? - cd into a direnv directory - confirm direnv has set devbox's env variables - run `./devbox shell` - confirm it goes into the shell successfully - while in shell run `cd ..` and then `cd` back into the directory - confirm `DEVBOX_SHELL_ENABLED` is still set to 1 - exit from devbox shell - confirm `DEVBOX_SHELL_ENABLED` is either 0 or none
1 parent 149c822 commit d4bfa86

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

internal/impl/tmpl/envrc.tmpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
use_devbox() {
55
watch_file devbox.json
66
if [ -f .devbox/gen/shell.nix ]; then
7+
DEVBOX_SHELL_ENABLED_BACKUP=$DEVBOX_SHELL_ENABLED
78
use nix .devbox/gen/shell.nix
89
eval $(devbox shell --print-env)
10+
export DEVBOX_SHELL_ENABLED=$DEVBOX_SHELL_ENABLED_BACKUP
911
fi
1012
}
1113
use devbox
1214

13-
14-
15-
# check out https://www.jetpack.io/devbox/docs/ide_configuration/direnv/
15+
# check out https://www.jetpack.io/devbox/docs/ide_configuration/direnv/
1616
# for more details

0 commit comments

Comments
 (0)