Open wakaryry opened 3 months ago
Hello @wakaryry sorry for the late reply, could you elaborate a bit more about your setup?
I don't know all of the logic yet, I understand that your problem is local
not working when global
and GOROOT
are both set? Are local and global showing the correct (different) values?
I couldn't reproduce this yet, we have over 300 test cases... did you follow the INSTALL.md (especially 4. goenv manages GOROOT
), ENVIRONMENT_VARIABLES.md (especially GOENV_DISABLE_GOROOT
) and CHANGELOG.md 2.0.0beta6 (goenv rehash
)? Did you install into .bash_profile or .bashrc (see 4.
)?
Can you post $ env | grep GO
in your local folder / environment?
I don't know enough about all inner workings, goenv local
works, but global does not.
goenv local 1.22.3
goenv root
# copy that path, usually the result of your user $HOME/.goenv
/shims
"go.alternateTools": {
"go": "/Users/myuser/.goenv/shims"
}
exec $SHELL
# or open a new terminalgo version
# should show go1.22.3Everytime you change goenv local
you should run exec $SHELL
or open a new terminal.
@ChronosMasterOfAllTime I saw multiple problems locally:
goenv local --unset
the code uses goenv version-file $PWD
which is allowed to search all the way up to that folder so goenv local
still showed that version (1.21.10)goenv local
(unset) and goenv global
(1.22.3) workedgoenv global system
I found no way to update the shims with goenv rehash
, they still pointed to the old global, so system (1.22.4) can't be used inside the shims folderMy expectation would be:
goenv local
only respects the "local" folder $PWD/.go-version (goenv version-file $PWD
should not search all the way up until $HOME/.go-version, only inside the project folder if currently inside a subdirectory, otherwise that would be a local global version 😅)goenv local --unset
allows goenv global
to use ${GOENV_ROOT}/version (goenv version-file
should find it, this is working)goenv global system
should rehash the shims to use the system Go if installed (and --unset
should be added to be symmetrical to local
)goenv local
and goenv global
should rehash the shims in general after an installed
version has been setgoenv local
and goenv global
should call exec $SHELL
(or -l) if configured by the user (internally a new reload
command)
Then VS Code users could be happy again 😄@ChronosMasterOfAllTime I saw multiple problems locally:
- There was a $HOME/.go-version file (maybe from local development?), so even after
goenv local --unset
the code usesgoenv version-file $PWD
which is allowed to search all the way up to that folder sogoenv local
still showed that version (1.21.10)- After I deleted that file manually,
goenv local
(unset) andgoenv global
(1.22.3) worked- After
goenv global system
I found no way to update the shims withgoenv rehash
, they still pointed to the old global, so system (1.22.4) can't be used inside the shims folderMy expectation would be:
goenv local
only respects the "local" folder $PWD/.go-version (goenv version-file $PWD
should not search all the way up until $HOME/.go-version, only inside the project folder if currently inside a subdirectory, otherwise that would be a local global version 😅)goenv local --unset
allowsgoenv global
to use ${GOENV_ROOT}/version (goenv version-file
should find it, this is working)goenv global system
should rehash the shims to use the system Go if installed (and--unset
should be added to be symmetrical tolocal
)goenv local
andgoenv global
should rehash the shims in general after aninstalled
version has been setgoenv local
andgoenv global
should callexec $SHELL
(or -l) if configured by the user (internally a newreload
command) Then VS Code users could be happy again 😄
Nice find! I would certainly welcome a PR since you did a solid job of RCA'ing this.
How can I make it work correct on VSCODE?
Apple M2 Pro;
VSCODE: Version: 1.87.2
If I set
goenv global
, the vscode will always use the global set. I can not change it into the local go version.I must change the global and reload the vscode.
I can not work with vscode using other go versions.
Thanks.