Every .tool-versions needs a .envrc? #101
-
When we are using the This takes me the following questions:
My Setup
use asdf
source_up .envrc
use asdf
Behaviors
$ cd ~/
direnv: loading ~/.envrc
direnv: using asdf
direnv: Creating env file ~/.asdf/installs/direnv/2.30.3/env/3953415231-2784736007-4011808011-2769317095
direnv: loading ~/.asdf/installs/direnv/2.30.3/env/3953415231-2784736007-4011808011-2769317095
direnv: using asdf nodejs 17.4.0
direnv: using asdf direnv 2.30.3
$ node --version
v17.4.0
$ which node
~/.asdf/installs/nodejs/17.4.0/bin/node
$ cd ~/project
direnv: loading ~/project/.envrc
direnv: loading ~/.envrc
direnv: using asdf
direnv: loading ~/.asdf/installs/direnv/2.30.3/env/3953415231-2784736007-4011808011-2769317095
direnv: using asdf nodejs 17.4.0
direnv: using asdf direnv 2.30.3
direnv: using asdf
direnv: loading ~/.asdf/installs/direnv/2.30.3/env/2059550318-3277659698-894641201-398937083
direnv: using asdf pnpm 6.30.1
direnv: using asdf direnv 2.30.3
direnv: using asdf nodejs 16.14.0
$ node --version
v16.14.0
$ which node
~/.asdf/installs/nodejs/16.14.0/bin/node
$ cd ~/project/sub-project
# same output from ~/project
$ node --version
v16.14.0
$ which node
~/.asdf/installs/nodejs/16.14.0/bin/node |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Ooh that's a very interesting point, and I can see the confusion. Unfortunately, I don't think we can change this behavior in any sane way, as direnv executes This is actually good and useful behavior for
In scenario 1), you'll end up with an environment formed by evaluating direnv/direnv#218 talks about this exact issue in great detail. So, I think the answer to your question is: "yes, this behavior is expected". Would you be open to sending in a PR adding a note about it, @gullitmiranda? |
Beta Was this translation helpful? Give feedback.
Ooh that's a very interesting point, and I can see the confusion. Unfortunately, I don't think we can change this behavior in any sane way, as direnv executes
.envrc
files with cwd set to the folder that script is in. In other words, in your example, from within the~/project/.envrc
file, there's no way to tell the difference between "we're currently in~/project
" and "we're currently in~/project/sub-project/
".This is actually good and useful behavior for
direnv
to have. If it didn't act that way, you might experience different behavior in this two situations:~
to~/project/sub-project
~
to~/project
and then to~/project/sub-project
In scenario 1), y…