-
Notifications
You must be signed in to change notification settings - Fork 645
Fixes #2122 tools are also found at GOBIN path #3001
Fixes #2122 tools are also found at GOBIN path #3001
Conversation
src/goPath.ts
Outdated
@@ -41,6 +41,15 @@ export function getBinPathWithPreferredGopath(toolName: string, preferredGopaths | |||
} | |||
|
|||
const binname = alternateTool && !path.isAbsolute(alternateTool) ? alternateTool : toolName; | |||
const env = Object.assign({}, process.env); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reason for making a copy of the env variables?
Since we are only reading the env var values, process.env
can be directly used.
src/goPath.ts
Outdated
@@ -41,6 +41,15 @@ export function getBinPathWithPreferredGopath(toolName: string, preferredGopaths | |||
} | |||
|
|||
const binname = alternateTool && !path.isAbsolute(alternateTool) ? alternateTool : toolName; | |||
const env = Object.assign({}, process.env); | |||
if (env['GOBIN'] != undefined){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This if
check can be removed. If no GOBIN is set, then getBinPathFromEnvVar()
will return null
anyway.
src/goPath.ts
Outdated
@@ -41,6 +41,15 @@ export function getBinPathWithPreferredGopath(toolName: string, preferredGopaths | |||
} | |||
|
|||
const binname = alternateTool && !path.isAbsolute(alternateTool) ? alternateTool : toolName; | |||
const env = Object.assign({}, process.env); | |||
if (env['GOBIN'] != undefined){ | |||
const path = getBinPathFromEnvVar(binname, env['GOBIN'], false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rename to pathFromGoBin
to match the patterns of pathFromGoRoot
and pathFromPath
names used later on
…tools-missing-when-gobin-2122
Commited the requested changes |
src/goInstallTools.ts
Outdated
}bin`; | ||
let binpath = toolsGopath + path.sep + "bin"; | ||
if(envForTools['GOBIN'] != undefined && envForTools['GOBIN'] != ''){ | ||
binpath = "GOBIN path " + envForTools['GOBIN'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If GOBIN is set, then we can essentially skip the code path
vscode-go/src/goInstallTools.ts
Lines 124 to 145 in 8660153
} else { | |
toolsGopath = getCurrentGoPath(); | |
outputChannel.appendLine(`go.toolsGopath setting is not set. Using GOPATH ${toolsGopath}`); | |
} | |
if (toolsGopath) { | |
const paths = toolsGopath.split(path.delimiter); | |
toolsGopath = paths[0]; | |
envForTools['GOPATH'] = toolsGopath; | |
} else { | |
const msg = 'Cannot install Go tools. Set either go.gopath or go.toolsGopath in settings.'; | |
vscode.window.showInformationMessage(msg, 'Open User Settings', 'Open Workspace Settings').then((selected) => { | |
switch (selected) { | |
case 'Open User Settings': | |
vscode.commands.executeCommand('workbench.action.openGlobalSettings'); | |
break; | |
case 'Open Workspace Settings': | |
vscode.commands.executeCommand('workbench.action.openWorkspaceSettings'); | |
break; | |
} | |
}); | |
return; | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We still have to set the current go path envForTools['GOPATH'] = toolsGopath;
since envForTools is passed as options when go get
child process is created. GOBIN is only setting the path where the executable should be installed. Right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm fair point
1f5fa4f
to
83e3360
Compare
If
go.toolsGopath
setting is set,goInstallTools.installTools
was already setting GOBIN env to ''. With nogo.toolsGopath
set but GOBIN defined the tools are installed in GOBIN path already. The log message had to be corrected (Installing x tools at ...).GOBIN was added to the list of places where the extension looks for the tools