Open TheUncleRemus opened 9 months ago
@TheUncleRemus Thanks for sharing your setup to workaround. Are you proposing to add this to a doc?
It looks like the key is to install go in a location flatpak allows vscode to access and make the extension know about the location.
Hi @hyangah yes! The key is to install go
to a custom path that is "visible" to flatpak
sandbox
My proposal can be:
README.md
thx. :)
The suggestion is:
"go.alternateTools": { "go": "<path_to_go_binary>" }
Hi @hyangah , my objection points are:
vscode-side
configuration, my configuration is flatpak-side
. If you want to use go
with another flatpak app? Yes, my configuration proposes a vscode
go-configuration but flatpak-side not vscode-side.@TheUncleRemus if it is about using go with other flatpak app, is there any flatpak community that can host the doc and review the contents?
Hi @hyangah ,
I have checked your configuration and I confirm to you that it doesn't works!
If you want to setup the go-configuration vscode-side
, the minimum setup that works fine is:
{
"go.alternateTools": {
"go": "<path_to_go_bin>"
},
"go.goroot": "<path_to_goroot>",
"go.gopath": "<path_to_go_bin>"
}
In every way...
flatpak-side
setup (because for every problem that eventually can cause the vscode disaster, my go-setup persists. Yeah, you can say that: "this eventually has a low-probability" but exists.thx
Can you tell us more details what doesn't work? go.goroot
is GOROOT envvar which we don't recommend to configure with recent go except a few exceptions. go.gopath
is GOPATH envvar and path to go binary shouldn't be the right value.
We can add a section in faq or advanced setting doc to mention your link, but we don't want to ask users to run a shell script that we don't understand or manage.
Hi @hyangah ,
yeah, correct! I means just this! When you run vscode by flatpak, your vscode
run insiede in a sandbox and the environemnt variables like $PATH
are differet!
from the flatpak documentation Description. Flatpak is a tool for managing applications and the runtimes they use. In the Flatpak model, applications can be built and distributed independently from the host system they are used on, and they are isolated from the host system ('sandboxed') to some degree, at runtime.
In fact if you see the error tooltip in vscode the value of the printed $PATH
is not uquals to the $PATH environment variable host-wide.
For this reason I have opened this thred. In summary:
go
to an accessible path also from flatpak.$GOROOT
path in a flatpak environment variables configuration (as showed into my script)After that you can use your go
instalaltion inside your vscode and the go
instalaltion strictly depends by $GOROOT
env setupped as showed above.
But you must be warry up because if you use go
from the outside of vscode and go
inside of vscode, you have two differetn set of the go-environment
variables - except for the $GOROOT
- (one of for the host-wide
and one of for the flatpak-side
. As showed in the GOBIN*.png figures)
from the host terminal
go env
from the vscode terminal
go env
For this reason in my opinion a solid documentation will be useful for the user, also because I had read this thred and there are confusing opinion.
If you want I can suppor to to you for docs pull requst.
I apologize for the hentropic text :)
@hyangah do you have any updates?
Thanks for sharing the screenshots. From the screenshots, I guess the settings were not configured correctly.
"go.alternateTools": { "go": ... }
should point to the path to the exact binary, not its directory. I assume ~/.golang/go/bin
is a directory.
Moreover, is your "go" command located in ~/.golang/go/bin
? You seemed to configure GOPATH
("go.gopath"
) to be the same directory. That's very unusual. For the meaning of GOPATH
, see https://pkg.go.dev/cmd/go#hdr-GOPATH_environment_variable and https://pkg.go.dev/cmd/go#hdr-GOPATH_and_Modules. I admit the official doc is a bit confusing, but it's historically used to set up a project workspace.
Can you try to fix the configuration errors and come up with a minimal configuration?
Hi @hyangah ,
don't focus to screenshots, because the point is not: "how can I configure my vscode for golang".
The point is: "How can I configure my flatpak vscode
for golang".
The point is not: the collision between he GOPATH var and vscode go
configuration (the screenshoots are misleading). The point is: have you a documentation section that describe this situation? Thus, your documentation describe the scenario when vscode is installed from flatpak (the answear is: no!).
Yes, I known, this is not a vscode
"problem" or a go
problem, but with the new era (potentially) of immutable OS, this scenario could be recurring.
I then I open this "issue" to propose an additional section to your doc. useful to describe this scenario.
Thanks. But we want to provide accurate info. Please correct errors. Then we are happy to have a place to link. (Wiki). For example, setting GOROOT and GOPATH isn't necessary nowadays and sometimes setting it can lead to confusion. I asked to test if they can be avoided, but it looks like the option wasn't tested correctly.
On Wed, Jan 10, 2024, 9:23 AM TheUncleRemus @.***> wrote:
Hi @hyangah https://github.com/hyangah , don't focus to screenshots, because the point is not: "how can I configure my vscode for golang". The point is: "How can I configure my flatpak vscode for golang".
The point is not: the collision between he GOPATH var and vscode go configuration (the screenshoots are misleading). The point is: have you a documentation section that describe this situation? Thus, your documentation describe the scenario when vscode is installed from flatpak (the answear is: no!).
Yes, I known, this is not a vscode "problem" or a go problem, but with the new era (potentially) of immutable OS, this scenario could be recurring.
I then I open this "issue" to propose an additional section to your doc. useful to describe this scenario.
— Reply to this email directly, view it on GitHub https://github.com/golang/vscode-go/issues/3063#issuecomment-1884945750, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABGESL3KQQ3XN324H2AC4XTYN2P77AVCNFSM6AAAAAA72AYXJCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBUHE2DKNZVGA . You are receiving this because you were mentioned.Message ID: @.***>
@hyangah onestly I don't understand. The point, for me, is: if you have this environment
vscode
from flatpakgo
installation binary using default method (path)You can configure your vscode
what you want, but it doesn't work...
If you want a "green" setup (using flatpak), you need:
go
into a non private flatpak pathsettings.json
.I don't have any other suggestions to you. If you want you can consider my observations useful to enrich your vscode
docs, otherwise I don't know 😅😁
TuR
proposal
I have published a simple repo for
go-vscode
configuration when vscode is installed from flatpak. You can to reach the repo at this link:Can you consider this configuration as proposal?
Thx!