Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow custom gemfile for debug #2707

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
16 changes: 16 additions & 0 deletions vscode/src/debugger.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand Down Expand Up @@ -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")) {
Expand Down
Loading