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

[mac os x] GOPATH isn't taken from current terminal session #141

Closed
voelzmo opened this issue Dec 3, 2015 · 6 comments
Closed

[mac os x] GOPATH isn't taken from current terminal session #141

voelzmo opened this issue Dec 3, 2015 · 6 comments

Comments

@voelzmo
Copy link

voelzmo commented Dec 3, 2015

I have a global GOPATH (i.e. ~/go) but for many of my projects I have an .envrc setting the GOPATH to the project's directory so they install their dependencies in their own context. When I start code . from such a directory, it doesn't seem to respect the local GOPATH setting.

Steps to reproduce:

  • have a global GOPATH in your .bash_profile
  • my function to start visual studio code looks like this code () { VSCODE_CWD="$PWD" open -n -b "com.microsoft.VSCode" --args $* ;}
  • open a terminal session
  • switch to some directory with your go code in it
  • set your GOPATH to this directory
  • open code .

Expected:

  • all dependencies installed in PWD/src/... are found

Actual:

  • errors that the referenced dependencies cannot be found anywhere. The error message is referencing my global GOPATH
@lukehoban
Copy link
Contributor

It sounds like you might be hitting microsoft/vscode#560. Could you try quitting out of VS Code completely, then opening with code . from the folder you want to work in? Then, what do you see from Go: Current GOPATH?

Edit: Note that microsoft/vscode#560 is fixed, but has not yet been deployed in a VS Code update.

@voelzmo
Copy link
Author

voelzmo commented Dec 4, 2015

Thanks @lukehoban for the quick reply!

Could you try quitting out of VS Code completely, then opening with code . from the folder you want to work in?

That's exactly what I'm doing. Atom has the same problems, so I'm already battle-proven concerning that :)

Then, what do you see from Go: Current GOPATH?

It's still my GOPATH defined in the ~/.bash_profile, not the env set in the current terminal window I'm starting it from.

@lukehoban
Copy link
Contributor

Okay - I can reproduce this now. It seems that somehow the environment settings in ~/.bash_profile are being allowed to override those exported in the local terminal session. If there is nothing set in ~/.bash_profile the local settings work fine, but if there is something in ~/.bash_profile, it wins out over anything defined locally.

Unfortunately though, I have no idea how to fix it :-). I have to assume this is a bug with either vscode or the way that open works on OS X.

@lukehoban
Copy link
Contributor

I've opened microsoft/vscode#1033 to understand the root cause here.

You can probably work around this by setting go.gopath in your settings file in .vscode/settings.json relative to the working folder of your project. That should force the tools to use that instead of the setting inherited from the environment.

@voelzmo
Copy link
Author

voelzmo commented Dec 10, 2015

Thanks for submitting the vscode bug, @lukehoban!

@lukehoban
Copy link
Contributor

Closing this one out for now - since I don't think there's anything we can/should do in the Go extension beyond what we currently do with go.gopath to workaround this. We'll just need to wait for the vscode issue to be fixed.

@vscodebot vscodebot bot locked and limited conversation to collaborators Jan 23, 2018
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

2 participants