-
Notifications
You must be signed in to change notification settings - Fork 752
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
Include GOROOT/bin to PATH when go wasn't found from PATH #713
Comments
Change https://golang.org/cl/258316 mentions this issue: |
Change https://golang.org/cl/258519 mentions this issue: |
…t found from PATH The fix for #679 changed to prepend GOROOT/bin to PATH or Path only if users explicitly configured to use go different from what's found from PATH. I forgot the case where go was not found from PATH and the extension picked up a common default go installation directory. (C:\Go\bin or /usr/local/go/bin). This change rewrote the fix - rewrote getBinPath to return why it chose the path as well. Then, we mutate the PATH env var if getBinPath picked go with a reason other than it's in PATH (why === 'path'). Since getBinPath and getBinPathWithPreferredGopathGoroot are used in many places, this CL introduces getBinPathWithExplanation and getBinPath wraps it. Updates #679 Fixes #713 Change-Id: Ie00612fcef2cf4c2a187a263da04b342182c030b Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/258316 Trust: Hyang-Ah Hana Kim <hyangah@gmail.com> Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Suzy Mueller <suzmue@golang.org> (cherry picked from commit 9bf9d64) Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/258519
I created an RC with the fix here For users who were affected by this: |
Switching to the latest nightly extension above does not resolve the issue. |
Same for me. I installed v1.17.2-rc.1 and the behavior is the same |
@saada nightly doesn't have the fix yet. @dylan-bourque Thanks! Can you please share 1) the full path of go binary you think it should use, 2) the PATH env var, and 3) the output of |
downgrade to 0.17.0 worked for me! |
@dylan-bourque Based on our chat in slack, the problem you encountered is different from this issue and preexisted before 0.17.1 release. The extension inherits all the environment vars set by vscode. So, if vscode does not pick up the right env var, I think you will need to file an issue to the vscode repo. @saada thanks for the update. I'd appreciate it if you can help checking if the 0.17.2-rc.2 addresses the issue. |
Change https://golang.org/cl/258557 mentions this issue: |
Change https://golang.org/cl/258797 mentions this issue: |
…TH mutation Changes to vscode.EnvironmentVariableCollection persist across vscode sessions, so when we decide not to mutate PATH, we need to clear the preexisting changes. The new function 'clearGoRuntimeBaseFromPATH' reverses almost all of what addGoRuntimeBaseToPATH did on the persisted state. Manually tested by setting/unsetting "go.alternateTools". Also, fixes the case where 'go.alternateTools' is set as an alternate tool name rather than an absolute path - in that case, we search the alternate tool from PATH. In this case, the reason shouldn't be 'path'. Manually tested by setting "go.alternateTools": { "go": "mygo.sh" } where "mygo.sh" is another binary that exists in PATH and shells out go. In addition to this, this change fixes an exception thrown while calling updateIntegratedTerminal when no 'go' executable is found from the default PATH. In that case, getBinPathFromEnvVar returns null, and path.dirname throws an error for non-string params. This results in the failure of updating terminal's PATH change and the users will not see the picked go from the terminal. This is a bug preexisted before 0.17.1 Manually tested by launching code without go in PATH. Updates #679 Fixes #713 Change-Id: I240694cb4425e81998299ab38097393a0f3faf46 Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/258557 Trust: Hyang-Ah Hana Kim <hyangah@gmail.com> Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Suzy Mueller <suzmue@golang.org> (cherry picked from commit 1b82f49) Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/258797
https://github.com/golang/vscode-go/releases/tag/v0.17.2 is released. |
just tested v0.17.2 and it works now. Thank you! |
I fixed the issue by installing the vscode using homebrew. |
The fix for #679 change to prepend
GOROOT/bin
toPATH
orPath
only if users explicitly configured to use go different from what's found fromPATH
. I forgot the case where go was not found fromPATH
, so the extension guessed and picked up a common default go installation directory. (C:\Go\bin
or/usr/local/go/bin
).This is a regression and needs fix.
As a result, underlying tools such as gopls or delve that searches only
PATH
failed to locate thego
binary. gopls crashes in this case.For users who encountered this issue: You can try one of the followings for now:
Please try out https://github.com/golang/vscode-go/releases/tag/v0.17.2-rc.1
There is an instruction.
If it doesn't fix the issue, please update this issue.
Meanwhile, you can try one of the followings:
Option 1) downgrade to 0.17.0 for now (Extension view -> select 'Go' extension -> click the gear icon -> install another version -> select 0.17.0), or
Option 2) add
"go.goroot": "/usr/local/go"
temporarily until 0.17.1 is out, orOption 3) add
/usr/local/go/bin
to yourPATH
and relaunch code for linux/mac users.C:\Go\bin
toPath
for windows users.I recommend the Option 3
Edit: For people who wonder why VS Code reports a different
PATH
than what you see from the terminal:When vscode launches for the first time, it initializes the environment like a login shell (
~/.profile
/~/.bash_profile
/~/.zprofile
). When you tryecho $PATH
from the terminal, the shell environment may be set for interactive shell env (.bashrc
, etc).The text was updated successfully, but these errors were encountered: