Unable to load .envrc
mattconway1984 opened this issue · comments
Describe the bug
Running a GitLab job I was hoping to use direnv to be able to set a specific Python version using pyenv. This works fine running outside of the context of a GitLab CI job.
Here is a simple GitLab CI job:
$ cat $HOME/.bashrc
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
if command -v pyenv 1>/dev/null 2>&1; then
eval "$(pyenv init -)"
fi
eval "$(direnv hook bash)"
$ source $HOME/.bashrc
$ echo "$SHELL"
/bin/bash
$ direnv allow .
$ cat .envrc
layout pyenv 3.11.5
$ direnv status
direnv exec path /usr/bin/direnv
DIRENV_CONFIG /home/gitlab-runner/.config/direnv
bash_path /usr/bin/bash
disable_stdin false
warn_timeout 5s
whitelist.prefix []
whitelist.exact map[]
No .envrc loaded
Found RC path /home/gitlab-runner/builds/3ztZoLqF/0/p3459/test/test-rig-d/.envrc
Found watch: ".envrc" - 2024-02-09T10:51:43Z
Found watch: "../../../../../../.local/share/direnv/allow/eb14c78e8db6dd6748c8b9ce9de2ba7286ea09887c9821317fbac279ba318d8c" - 2024-02-09T10:51:43Z
Found RC allowed true
Found RC allowPath /home/gitlab-runner/.local/share/direnv/allow/eb14c78e8db6dd6748c8b9ce9de2ba7286ea09887c9821317fbac279ba318d8c
$ python3 --version
Python 3.8.10
$ which python3
/home/gitlab-runner/.pyenv/shims/python3
$ pyenv versions
* system (set by /home/gitlab-runner/.pyenv/version)
3.11.7
To Reproduce
Follow steps in CI script above.
Expected behavior
direnv loads the .envrc
file in the local directory and sets the local environment.
Environment
- OS:
Linux <hostname> 5.15.0-92-generic #102~20.04.1-Ubuntu SMP Mon Jan 15 13:09:14 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
- Shell: bash
- Direnv version 2.21.2
Additional context
Add any other context about the problem here.
For non-Interactive shells (in .bashrc):
eval "$(direnv hook bash)"
should be eval "$(direnv export bash)"