DEV Community

David Satime Wallin
David Satime Wallin

Posted on

Go -mess with flatpak+vscode

Made a fresh fedora 28 install on my macbook pro today (yes I'm an osx hater) and decided to install vscode (me too went from emacs to vscode) through flatpak - which I had yet to try out.

Now the basic install of vscode is a one-liner. Simply do flatpak install flathub com.visualstudio.code and you're done. The trouble arose when I installed the go extension.

Normally this is a one-step-thing as well but this time I couldn't get the darn thing to find the go binary. I use fish as my shell and started to suspect it did not find the environment variables correctly (since vscode initiates an sh-shell of its own). So, perhaps noob-ishly, I started setting my PATH, GOPATH and GOROOT in .bash_profile as well. This actually made a difference. I could now see the correct path in the vscode terminal. The strange thing was that, ever if the path was correct, the binary could not be found when I tried to run it from inside vscode.

My investigation continued. I quite soon realized that it was my lacking knowledge of flatpak that made me stumble. Since my GOROOT was pointing at /usr/lib/golang (yes i normally use GVM but couldn't be bothered today) and flatpak is sandboxed it could not find the content of GOROOT.

Thus, the simple solution was (if perhaps not the best) to

1) download the Go linux binaries

2) unpacking them into $HOME/go

3) adding this to $HOME/.bash_profile

PATH=$HOME/src/go/bin:$HOME/go/bin:$PATH
export PATH
GOROOT=$HOME/go
export GOROOT
GOPATH=$HOME/src/go
export GOPATH
Enter fullscreen mode Exit fullscreen mode

4) and then adding this to my vscode settings.json

    "terminal.integrated.shellArgs.linux": ["-l"],
    "terminal.integrated.shell.linux": "/bin/bash",
    "go.gopath": "/home/dsw/src/go",
    "go.goroot": "/home/dsw/go",
    "go.inferGopath": true,
Enter fullscreen mode Exit fullscreen mode

So, call me a newb but it's solved. Would gladly hear of any alternative ways of solving it or perhaps similar flatpak-stories.

EOF!

Top comments (1)

Collapse
 
kakhavk profile image
Kakhaber Kashmadze

It works! thanks