diff --git a/vscode/package.json b/vscode/package.json index 575ccfbca..7a6dd4979 100644 --- a/vscode/package.json +++ b/vscode/package.json @@ -390,6 +390,11 @@ "type": "string", "default": "" }, + "rubyLsp.debugGemfile": { + "description": "Relative or absolute path to the Gemfile to use when running debug. If unset, the Gemfile used for the Ruby LSP server will be used", + "type": "string", + "default": "" + }, "rubyLsp.testTimeout": { "description": "The amount of time in seconds to wait for a test to finish before timing out. Only used when running tests from the test explorer", "type": "integer", diff --git a/vscode/src/debugger.ts b/vscode/src/debugger.ts index 12e7547dc..5b55574a5 100644 --- a/vscode/src/debugger.ts +++ b/vscode/src/debugger.ts @@ -1,6 +1,7 @@ import net from "net"; import os from "os"; import { ChildProcessWithoutNullStreams, spawn } from "child_process"; +import path from "path"; import * as vscode from "vscode"; @@ -129,6 +130,21 @@ export class Debugger const customBundleUri = vscode.Uri.joinPath(workspaceUri, ".ruby-lsp"); + const customDebugGemfile: string = vscode.workspace + .getConfiguration("rubyLsp") + .get("debugGemfile")!; + + // allow user to override the default of using the RubyLsp Gemfile + // when debugging + if (customDebugGemfile.length > 0) { + debugConfiguration.env.BUNDLE_GEMFILE = path.isAbsolute( + customDebugGemfile, + ) + ? customDebugGemfile + : path.resolve(path.join(workspaceUri.fsPath, customDebugGemfile)); + return debugConfiguration; + } + return vscode.workspace.fs.readDirectory(customBundleUri).then( (value) => { if (value.some((entry) => entry[0] === "Gemfile")) {