Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

VS tell me my $GOPATH is wrong #708

Closed
Wang-Kai opened this issue Jan 5, 2017 · 8 comments
Closed

VS tell me my $GOPATH is wrong #708

Wang-Kai opened this issue Jan 5, 2017 · 8 comments

Comments

@Wang-Kai
Copy link

Wang-Kai commented Jan 5, 2017

The vs code show that :

2017-01-05 8 21 14

But my $GOPATH is :
➜ ~ echo $GOPATH
/Users/Elegant/go

@ramya-rao-a
Copy link
Contributor

Run the command Go: Current GOPATH in VS Code. What does that give?
Check your User and Workspace settings. Maybe you have set GOPATH there to a different value.

@ghost
Copy link

ghost commented Jan 7, 2017

I have the same problem. Go: Current GOPATH outputs "undefined". My GOPATH and GOROOT are set in .bashrc, I'm using Linux.

It only works if I manually add "go.gopath" into the settings.json which is far from ideal.

@ramya-rao-a
Copy link
Contributor

@skmlcd Can you try opening VS Code from the command line? code .

@ghost
Copy link

ghost commented Jan 7, 2017

Opening from command line works without the problem (GOPATH is correct).

@ghost
Copy link

ghost commented Jan 7, 2017

[Desktop Entry]
Name=Visual Studio Code
Comment=Visual Studio Code
GenericName=Text Editor
Exec=code-oss %U
Icon=code-oss
Type=Application
Terminal=false
StartupNotify=true
StartupWMClass=visual-studio-code
Categories=Development;TextEditor;
MimeType=text/plain;

This is the desktop file (shortcut) for launching vscode. code-oss is the same as code, this is only distribution package name. VS Code version is 1.8.1.

Tell me if there is anything else I can provide to help with any potential bug. :)

@ramya-rao-a
Copy link
Contributor

@skmlcd In that case, this is as expected.
When opening from command line, the process running the Go extension inherits all the env variables from the shell, and so it can use the GOPATH you have set in .bashrc
When you open from the shortcut, it doesnt have access the env variables from the shell.

@Tyriar Can you confirm the above statement, in case my understanding is wrong?

@Tyriar
Copy link
Member

Tyriar commented Jan 8, 2017

Yes this is likely a case of confusion with .bashrc. You probably want to put the environment variable stuff in your ~/.profile file as you want them to apply globally, not just to bash. Check out http://serverfault.com/a/261807 for more info.

@ghost
Copy link

ghost commented Jan 8, 2017

@Tyriar Thanks, putting it in .profile that solved the problem.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants