-
-
Notifications
You must be signed in to change notification settings - Fork 38
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
bug: direnv, no shims in PATH, asdf global, asdf direnv shell issue/question #149
Comments
One correction: I've found that there actually is a |
I believe your expectation is right, I'd also expect Indeed, this looks like a bug. We have a few tests for the shell command however none of them launches an interactive shell. I believe we could add one more test that Could you please do the following? (running on your project directory) Be sure to run asdf current
go --version # or whatever flag you give to golang in order to print the version number
env ASDF_GOLANG_VERSION=1.17.8 asdf exec go --version
env ASDF_GOLANG_VERSION=1.18 asdf exec go --version
# I believe this should work since we have tests for this use case.
env ASDF_DIRENV_DEBUG=true asdf direnv shell golang 1.18 -- go --version
# This one - opening a new interactive shell - I believe wont work. This is the case we need tests for.
# My first guess is that the new shell is loading it's own shellrc and going back to golang 1.17.
env ASDF_DIRENV_DEBUG=true asdf direnv shell golang 1.18 # inside new shell run: `asdf current`.
# This one is the same as before but explicitly spawns a new bash shell without loading any shellrc.
env ASDF_DIRENV_DEBUG=true asdf direnv shell golang 1.18 -- bash --norc --noprofile # inside new shell run: `asdf current` |
One for testing that the tool version can override those from global and local .tool-versions file. One for testing that we spawn a SHELL and that it has the correct version independent of global and local .tool-versions. Related issue: #149
Just added a couple of tests which I believe we were missing. These two new tests ensure that No code changes were necessary, so maybe adding those tests does not solve this issue and perhaps it's something on your environment we haven't yet figured out. |
direnv system /home/scop/.tool-versions golang 1.17.8 /home/scop/.tool-versions perl ______ No version is set. Run "asdf perl " go version go1.17.8 linux/amd64 go version go1.17.8 linux/amd64 go version go1.18 linux/amd64 So far as expected. But now it gets interesting -- this gives 1.17.8 vs the expected 1.18, i.e. not what your expectation above was: Next one fails pretty much exactly the same as the previous. Last one fails exactly the same as the previous: |
Looking at Perhaps, in your
|
I'm also not a golang user, so I'm just guessing what if the executed binary is |
I believe I could not find evidence that |
Verified that it's the |
Yes, looks like asdf-golang These lines (from your
however, on line 3, Looking at the output on |
Same from but again, GOROOT seems to be that of
|
Guess there are kind of two problems here:
$ echo $PATH # starting point
/home/scop/.asdf/installs/golang/1.17.9/bin:/home/scop/.asdf/installs/golang/1.17.9/go/bin:/home/scop/.asdf/installs/golang/1.17.9/packages/bin:[...]
$ asdf direnv shell golang 1.18.1
direnv: using asdf golang 1.18.1
direnv: loading ~/.asdf/plugins/golang/bin/exec-env
$ echo $PATH
/home/scop/.asdf/installs/golang/1.18.1/bin:/home/scop/.asdf/installs/golang/1.17.9/bin:/home/scop/.asdf/installs/golang/1.17.9/go/bin:/home/scop/.asdf/installs/golang/1.17.9/packages/bin:[...] Why only Not really asking these questions from you, more like reminding myself where to pick up debugging more when I find some more time. Perhaps I should also try this out with some other plugin besides golang to see if it fares any better. |
#151 fixes the incomplete |
Hmm, this could arguably be a bug and it should possibly instead set both unconditionally. (Well in my case I would prefer that it would never touch either no matter what, but that's an orthogonal issue.) asdf's plugin creator help isn't really helpful on this. |
Otherwise, existing values from the environment may continue to point to a wrong version. Refs asdf-community/asdf-direnv#149
I've filed asdf-community/asdf-golang#80 which fixes the remaining issues for me. In the meantime, I'm doing use asdf
unset -v GOROOT GOPATH ...in all my Leaving this open still to consider and resolve this (or not) from the initial comment:
|
Just bit by this as well on a new setup. I removed (And because recent versions of homebrew Python create only This leaves new asdf-direnv users with a "broken" setup, or at least one that no longer works the way it used to until further modifications are made. The intention here is good, to completely remove the shim lookup. However, it would be great to update the docs with an explicit note about the consequences, as many asdf users have asdf shims taking precedence over system-installed versions on $PATH. |
Added an assertion during our |
Tried to reproduce this myself with no luck. Having no asdf-shims on |
I can see a few differences between @pikeas' report and @vic's reproducer try:
Don't know if either of these makes a difference, but I suppose they could, and it would be good to try eliminating the differences in search of a reproducer. |
What I experienced should be reproducible:
When invoking an interpreter, it will necessarily be one that is not managed by asdf, because asdf's directories aren't on PATH. That's exactly as expected and intended. The reason I commented is documentation - the "pro-tip" encourages removing the shim dir from PATH, and so it would nice if the docs a) remind/warn users that this will change their system behavior and b) make recommendations on other ways to achieve the old behavior (add |
Otherwise, existing values from the environment may continue to point to a wrong version. Refs asdf-community/asdf-direnv#149
Describe the Bug
I'm not sure if this is a bug in asdf/asdf-direnv/asdf-golang or just a pilot error, but I thought I'd try reporting it here anyway for thoughts.
The setup in question is
I've implemented the "pro tip" basically by just this:
...i.e. I'm not sourcing
~/.asdf/asdf.sh
.In this state, there are two problems
go
in$PATH
at allasdf direnv shell golang 1.18
, but that doesn't work even though I'm getting "using asdf golang 1.18" in the output:To start to resolve this I've added
~/.envrc
with contentsuse asdf
.No(see correction in a comment below). That fixes 1) above, the Go set to global with asdf is now in my~/.tool-versions
is present nor any other in effect$PATH
along with other its settings.However, the problem with 2) remains. I would like to open a new shell with a different Go every now and then, and the way I read https://github.com/asdf-community/asdf-direnv#temporary-environments-for-one-shot-commands it would seem that
asdf direnv shell golang x.xx.x
should accomplish that. But it doesn't:I've found that a
asdf global golang x.xx
serves as a workaround for 2) -- it does change the Go version in the current shell (if the shell is using the global, naturally, and not overridden by a dir specific one). But the obvious problem is that it "leaks" to other new shells because of the altered global.asdf shell golang x.xx
is not available, asdf barfsSo, boils down to 2 questions:
a) Is adding
use asdf
to this effect in~/.envrc
something that one usually does with the "pro tip", or what's the "correct" way to get the asdf globals to work with it? If that's the way, perhaps amend the pro tip doc with that?b) Is there something wrong with
asdf direnv shell golang ...
, or my use or expectation of it?Steps to Reproduce
See above.
Expected Behaviour
I hope the description above covers this.
Actual Behaviour
I hope the description above covers this.
Debug Output
The text was updated successfully, but these errors were encountered: