diff --git a/x-pack/legacy/plugins/code/server/lsp/go_launcher.ts b/x-pack/legacy/plugins/code/server/lsp/go_launcher.ts index c8b707f9b5fb9..fcde0c5791a1b 100644 --- a/x-pack/legacy/plugins/code/server/lsp/go_launcher.ts +++ b/x-pack/legacy/plugins/code/server/lsp/go_launcher.ts @@ -87,7 +87,6 @@ export class GoServerLauncher extends AbstractLauncher { throw new Error('Cannot find executable go language server'); } - let envPath = process.env.PATH; const goToolchain = await this.getBundledGoToolchain(installationPath, log); if (!goToolchain) { throw new Error('Cannot find go toolchain in bundle installation'); @@ -95,7 +94,6 @@ export class GoServerLauncher extends AbstractLauncher { // Construct $GOROOT from the bundled go toolchain. const goRoot = goToolchain; const goHome = path.resolve(goToolchain, 'bin'); - envPath = process.platform === 'win32' ? envPath + ';' + goHome : envPath + ':' + goHome; // Construct $GOPATH under 'kibana/data/code'. const goPath = this.options.goPath; if (!fs.existsSync(goPath)) { @@ -104,17 +102,18 @@ export class GoServerLauncher extends AbstractLauncher { const goCache = path.resolve(goPath, '.cache'); const params: string[] = ['-port=' + port.toString()]; const golsp = path.resolve(installationPath, launchersFound[0]); + const env = Object.create(process.env); + env.PATH = process.platform === 'win32' ? goHome + ';' + env.PATH : goHome + ':' + env.PATH; const p = spawn(golsp, params, { detached: false, stdio: 'pipe', env: { - ...process.env, + ...env, CLIENT_HOST: '127.0.0.1', CLIENT_PORT: port.toString(), GOROOT: goRoot, GOPATH: goPath, GOCACHE: goCache, - PATH: envPath, CGO_ENABLED: '0', }, });