From ec50daf756b0368609a471ba04b9997c6624348c Mon Sep 17 00:00:00 2001 From: Vinicius Stock Date: Fri, 14 Jul 2023 15:00:06 -0600 Subject: [PATCH] Manually activate shadow env instead of depending on extension --- src/ruby.ts | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/src/ruby.ts b/src/ruby.ts index 182eaafc..5999c39f 100644 --- a/src/ruby.ts +++ b/src/ruby.ts @@ -111,16 +111,6 @@ export class Ruby { } private async activateShadowenv() { - const extension = vscode.extensions.getExtension( - "shopify.vscode-shadowenv" - ); - - if (!extension) { - throw new Error( - "The Ruby LSP version manager is configured to be shadowenv, but the shadowenv extension is not installed" - ); - } - if (!fs.existsSync(path.join(this.workingFolder, ".shadowenv.d"))) { throw new Error( "The Ruby LSP version manager is configured to be shadowenv, \ @@ -128,10 +118,17 @@ export class Ruby { ); } - await extension.activate(); - await this.delay(500); + const result = await asyncExec("shadowenv hook --json", { + cwd: this.workingFolder, + }); + + const env = JSON.parse(result.stdout).exported; + + // The only reason we set the process environment here is to allow other extensions that don't perform activation + // work properly // eslint-disable-next-line no-process-env - this._env = { ...process.env }; + process.env = env; + this._env = env; } private async activateChruby() { @@ -297,12 +294,6 @@ export class Ruby { } } - private async delay(mseconds: number) { - return new Promise((resolve) => { - setTimeout(resolve, mseconds); - }); - } - private async activateCustomRuby() { const configuration = vscode.workspace.getConfiguration("rubyLsp"); const customCommand: string | undefined =