-
Notifications
You must be signed in to change notification settings - Fork 645
Working with multiple GOPATHs #220
Comments
There was an issue with VS Code at one point where if you had any existing VS Code windows open before launching Also - do you have a |
I always closed all windows.
Yes. I did. in Do you have an idea why? As you see above Also this means that in my setup I would need to re-install all the analysis tool for each project. Correct? |
Looks like this extension overwrites: process.env.GOPATH Other environment variables persist. shell> GOPATH="/foo/bar" FOOBAR="/foo/bar" code . After VSCode is launched, go to Help > Toggle Developer Tools and check the following in Console: > process.env.GOPATH
"/home/saml/go" // eh?
> process.env.FOOBAR
"/foo/bar" // this is expected Expected behavior is:
Isn't above expected behavior sane? |
@saml That expected behaviour should be what is implemented. In your example, I expect the results you are seeing come from having If it's not, could you (a) make sure you close all Code windows and see if you get the same results? and (b) do you have a ~/.bash_profile or similar which is configuring the GOPATH? That shouldn't cause a problem, but curious if it's the case in your setup. |
@lukehoban I'm using zsh, ubuntu. # No workspace settings
➜ cat .vscode/settings.json
cat: .vscode/settings.json: No such file or directory
# User settings, but no go.gopath
➜ cat ~/.config/Code/User/settings.json
// Place your settings in this file to overwrite the default settings
{
"editor.fontSize": 18,
"rust.rustfmtPath": "/home/sam/.multirust/toolchains/stable/cargo/bin/rustfmt",
"go.buildOnSave": true,
"go.lintOnSave": true,
"go.vetOnSave": true,
"go.buildFlags": [],
"go.lintFlags": [],
"go.vetFlags": [],
"go.formatOnSave": true,
"go.formatTool": "gofmt"
}
# Defining GOPATH in .zlogin
➜ grep GOPATH ~/.zshrc
➜ grep GOPATH ~/.zshenv
➜ grep GOPATH ~/.zlogin
GOPATH="$HOME/code" It's weird. Even if I use the following 'use strict';
function activate(ctx) {
}
exports.activate = activate; And launch vscode as: # vscode is symlink to /opt/VSCode/code
➜ GOPATH=/tmp/1 GOPATH_=/tmp/2 GoPath=/tmp/3 FOOBAR=/tmp/4 vscode . I get the following: process.env.GOPATH
"/home/sam/code"
process.env.GOPATH_
"/tmp/2"
process.env.GoPath
"/tmp/3" It looks like it's related to the way vscode is executing. Variables defined in # This is zsh
➜ grep FOOBAR ~/.zlogin
FOOBAR=1 # I define this variable in ~/.zlogin
➜ echo $FOOBAR
1
➜ bash
# Now bash
$ echo $FOOBAR
$ FOOBAR=foobar notdefinedinzshenv=wow vscode .
process.env.FOOBAR
"1"
process.env.notdefinedinzshenv
"wow" Maybe vscode executes zsh (my default shell) as login shell overriding variables passed on commandline... EDIT: VSCode does seem to execute shell as login shell. Tested this with bash as well. chsh -s /bin/bash
vim ~/.bash_login # export FOOBAR=1
# logout and login
FOOBAR=2 vscode .
process.env.FOOBAR
"1" Out of curiosity, tested this with Atom editor as well:
atom respects FOOBAR=2 passed in command line. |
Thanks @saml for the investigation, and for opening microsoft/vscode#4779. Based on that, it sounds like the root issue is in VS Code, and is now being tracked there. So I'm going to close this issue. Let us know if there's something seperate you see that we could do in |
My current setup: I have a default GOPATH and I'm usually setting a new GOPATH to the current project I'm working on. Like
export GOPATH=$(PWD)
.From what I've read the Readme this setup should be supported:
But the GOPATH doesn't seemed to be used:
Note: I've installed the
Analysis Tools
in the default GOPATH (/Users/mdl/workspace/golang) and I'm not asked to reinstall them when opening with a new GOPATH.Should the work? How can I debug this problem?
The text was updated successfully, but these errors were encountered: