From 077e928d6d8243ab5b483dde75409eef69e9ca33 Mon Sep 17 00:00:00 2001 From: Rebecca Stambler Date: Tue, 5 Nov 2019 19:40:28 -0500 Subject: [PATCH] run `go mod tidy` between tool installations (#2877) --- src/goInstallTools.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/goInstallTools.ts b/src/goInstallTools.ts index 5a748fb70..a99372a82 100644 --- a/src/goInstallTools.ts +++ b/src/goInstallTools.ts @@ -148,7 +148,16 @@ export function installTools(missing: Tool[], goVersion: GoVersion): Promise new Promise((resolve, reject) => { + const opts = { + env: envForTools, + cwd: toolsTmpDir, + }; const callback = (err: Error, stdout: string, stderr: string) => { + // Make sure to run `go mod tidy` between tool installations. + // This avoids us having to create a fresh go.mod file for each tool. + if (!modulesOff) { + cp.execFileSync(goRuntimePath, ['mod', 'tidy'], opts); + } if (err) { outputChannel.appendLine('Installing ' + getImportPath(tool, goVersion) + ' FAILED'); const failureReason = tool.name + ';;' + err + stdout.toString() + stderr.toString(); @@ -188,10 +197,6 @@ export function installTools(missing: Tool[], goVersion: GoVersion): Promise { if (stderr.indexOf('unexpected directory layout:') > -1) {