Skip to content
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

vscode installed from flatpak fails to access the default go installation location /usr/local/go #3063

Open
TheUncleRemus opened this issue Nov 25, 2023 · 13 comments
Assignees
Labels
Documentation WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@TheUncleRemus
Copy link

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:

https://github.com/TheUncleRemus/flapak-vscode-as-go-ide.git

Can you consider this configuration as proposal?

Thx!

@gopherbot gopherbot added this to the Untriaged milestone Nov 25, 2023
@TheUncleRemus TheUncleRemus changed the title Proposal: Instruction+script about go an vscode configuration when using vscode fro flatpa Proposal: Instruction+script about go and vscode configuration when using vscode fro flatpak Nov 25, 2023
@hyangah
Copy link
Contributor

hyangah commented Nov 29, 2023

@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.

@hyangah hyangah added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Nov 29, 2023
@TheUncleRemus
Copy link
Author

TheUncleRemus commented Nov 29, 2023

Hi @hyangah yes! The key is to install go to a custom path that is "visible" to flatpak sandbox

My proposal can be:

  • to add to docs of the current project my solution
  • or integrate my repo (or script) in the current project
  • or referes my repo from the current README.md

thx. :)

@hyangah hyangah changed the title Proposal: Instruction+script about go and vscode configuration when using vscode fro flatpak vscode installed from flatpak fails to access the default go installation location /usr/local/go Nov 30, 2023
@hyangah
Copy link
Contributor

hyangah commented Nov 30, 2023

The suggestion is:

  • install go in a different location: https://go.dev/doc/install uses /usr/local/go, but uses a different location.
  • use the following setting:
"go.alternateTools": { "go": "<path_to_go_binary>" }

@TheUncleRemus
Copy link
Author

Hi @hyangah ,
my objection points are:

  • your configuration is a 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.
  • Furthermore I don't really shure that your configuration works fine, but I will try.

@hyangah
Copy link
Contributor

hyangah commented Dec 1, 2023

@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?

@TheUncleRemus
Copy link
Author

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...

  • I prefer the 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.
  • if in the current documentation doesn't exists the section: "minimun setup in flatpak context" I propose to you to add the minimun setup config as above.

thx

@hyangah
Copy link
Contributor

hyangah commented Dec 1, 2023

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.

@TheUncleRemus
Copy link
Author

TheUncleRemus commented Dec 1, 2023

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:

  • install go to an accessible path also from flatpak.
  • set $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 

GOBIN_host-side

from the vscode terminal

go env

GOBIN

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.

Appendix: tooltip error in vscode configuration

Schermata del 2023-12-01 14-08-54

Schermata del 2023-12-01 14-10-24

If you want I can suppor to to you for docs pull requst.

I apologize for the hentropic text :)

@TheUncleRemus
Copy link
Author

@hyangah do you have any updates?

@hyangah
Copy link
Contributor

hyangah commented Jan 10, 2024

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?

@TheUncleRemus
Copy link
Author

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.

@hyangah
Copy link
Contributor

hyangah commented Jan 10, 2024 via email

@TheUncleRemus
Copy link
Author

TheUncleRemus commented Jan 10, 2024

@hyangah onestly I don't understand. The point, for me, is: if you have this environment

  • vscodefrom flatpak
  • goinstallation 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:

  • to install go into a non private flatpak path
  • configure the flatpak environment with env var (that are different from host-side env vars); or setup 'vscode' using settings.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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

4 participants