-
Notifications
You must be signed in to change notification settings - Fork 646
Error installing tools when using Go version managers (asdf-vm) #3087
Comments
I don't know about @pecigonzalo Is there an established guideline recommended for |
@hyangah I dont think there is, IMO its not an Maybe using |
@pecigonzalo If it is intended to work with One workaround is to install the necessary tools manually and drop them in the vscode bin path or PATH the Go extension will look for binaries. Personally, I don't think most tools need to be rebuilt to match the version of go in use. I just ignore all the reinstallation messages most of time (the popup is annoying but it seems to happen only once whenever I switch my go and goroot). Maybe there are some tools that I don't know about but are sensitive to the go version. @ramya-rao-a may know better about this version match requirement. -- |
@hyangah It works with the de-facto way of installing binaries, I never said it does not support doing There are in my experience 3 approaches to version managers:
As explained the problem with the ones that fall on the 3rd class is Arguably I would say, if users want to install the tools are part of how the code is lined, formatted and inspected then having them in the |
I believe what @hyangah meant here is that the
Tool installation has presented a challenge in the context of Go modules, because the majority of tools are not related to the project that a user is working on. Adding indirect dependencies to user's modules as they download tools is not acceptable behavior, which is why this work-around was introduced. @hyangah: What do you think, are you okay with adding a special case for 1.14 to use /cc @jayconrod, just so you see another use case in action 😄 |
I understand if you do not wish to support this use-case for this extension, but I have to disagree with this, I do not think it the job of the version manager to do that. IMO if this is the case, it would be great for Go to use a temp dir inside the working context, like its done for Alternatively, it could be something to be resolved by As far as I understand this, it is not fair or possible to ask the version manager to understand that a random command run in a random directory wants a version set in a repository. It would sort of PS: The command is able to run outside of the Go project with my workaround, but it means its running a global Go version that could be different from the project one. |
It may not be in formal docs, but it's mentioned frequently in related issues: golang/go#27643, golang/go#24250. It's not ideal, but it is the current state with modules.
The only way to do this correctly would be to temporarily create a nested module in your project. This makes me pretty nervous - @hyangah: do you think this is a reasonable idea?
There have been proposals for such a flag, and we'll certainly use it if it gets added in a later version of Go.
This seems like reasonable behavior. As @hyangah said, it shouldn't be necessary to have tools compiled with the same version of Go as you are currently using, and I don't think we have the infrastructure to support easily switching between versions of tools based on your current version of Go. |
If that is acceptable solution then I'll just use the global version
configuration and if ok the PR this to indicate that, for other stumbling
on the same issue. Thanks for replying so quickly.
…On Wed, Mar 4, 2020, 10:12 PM Rebecca Stambler ***@***.***> wrote:
I do not recall any Go docs I have used advising to run commands in
temporary directories but if you could you point me to those docs I can try
and PR the version manager accordingly if possible.
It may not be in formal docs, but it's mentioned frequently in related
issues: golang/go#27643 <golang/go#27643>,
golang/go#24250 <golang/go#24250>. It's not
ideal, but it is the current state with modules.
IMO if this is the case, it would be great for Go to use a temp dir inside
the working context, like its done for .venv or node_modules (I know its
used more like the equivalent vendor but its just an example) as most
version managers support inheritance from the parent folder.
The only way to do this correctly would be to temporarily create a nested
module in your project. This makes me pretty nervous - @hyangah
<https://github.com/hyangah>: do you think this is a reasonable idea?
Alternatively, it could be something to be resolved by Go supporting a
global install param, as npm does with the --global.
There have been proposals for such a flag, and we'll certainly use it if
it gets added in a later version of Go.
PS: The command is able to run outside of the Go project with my
workaround, but it means its running a global Go version that could be
different from the project one.
This seems like reasonable behavior. As @hyangah
<https://github.com/hyangah> said, it shouldn't be necessary to have
tools compiled with the same version of Go as you are currently using, and
I don't think we have the infrastructure to support easily switching
between versions of tools based on your current version of Go.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3087?email_source=notifications&email_token=ACLS7CPOLHSZB53ECHCLSV3RF274ZA5CNFSM4LBBHJH2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEN2KCPY#issuecomment-594846015>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACLS7CMMZFOYMKM7XJRZJ73RF274ZANCNFSM4LBBHJHQ>
.
|
Looks like this has been resolved. Closing. |
@stamblerre I was not able to comment back before as I did not had the time to generate a proper test env but I actually stumbled upon some issues, as some tools (lets say I was working on a clear example of the issue so it was easy to see, but just wanted to comment that the workaround its not 100 effective. |
I have created
system is go1.14.2 from ubuntu packages
When I open
which installs to
So having a global Additionally, the output on save shows:
But if I run |
Thanks for the clarification. I added golang/vscode-go#146 (comment) to golang/vscode-go#146. We will be revisiting the way that this extension handles multiple Go versions, and as part of that, we will investigate how to best work with Go version managers. Let's continue the discussion on golang/vscode-go#146 as this needs to be part of the larger conversation. /cc @hyangah |
What version of Go, VS Code & VS Code Go extension are you using?
go version
to get version of Gogo version go1.14 linux/amd64
code -v
orcode-insiders -v
to get version of VS Code or VS Code Insiders1.42.1
0.13.1
go env GOOS GOARCH
to get the operating system and processor architecture detailslinux
amd64
WSL2
Share the Go related settings you have added/edited
Describe the bug
Im using
asdf-vm
and I have a similar but related issue to #2899 wherevscode-go
fails to install the required go tools because it runsgo
in a different path than the one the code is on.This would affect anything that depends on the location potentially, like
direnv
as well (altho givendirenv
was run when the shell entered the directory and you open VSCode from that shell, it could be that it works).Output:
This is because the exec of
go get -v
seems to happen outside of the code repository, causingasdf
to not find the.tool-versions
file and be able to select the correct binary.I believe its this section:
vscode-go/src/goInstallTools.ts
Lines 177 to 178 in 7f301ed
Steps to reproduce the behavior:
asdf-vm
and thegolang
pluginasdf install golang 1.14
asdf local golang 1.14
.tool-versions
containing the version that you selectedGo: Install/Update Tools
actionWorkaround
Set a global default for
asdf
andgo
to eithersystem
or a fixed version of go.While this workaround works, it's sub-optimal as many other commands could also be running outside of the PWD of the code and be using an incorrect version of go.
The text was updated successfully, but these errors were encountered: