Skip to content
Open
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
9 changes: 5 additions & 4 deletions vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
{
"command": "rubyLsp.selectRubyVersionManager",
"title": "Select Ruby version manager",
"category": "Ruby LSP"
"category": "Ruby LSP",
},
{
"command": "rubyLsp.toggleFeatures",
Expand Down Expand Up @@ -389,6 +389,7 @@
},
"rubyLsp.rubyVersionManager": {
"type": "object",
"scope": "window",

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ruby version manager could be different depending on workspaces.

"properties": {
"identifier": {
"description": "The Ruby version manager to use",
Expand Down Expand Up @@ -440,7 +441,7 @@
"rubyLsp.customRubyCommand": {
"description": "A shell command to activate the right Ruby version or add a custom Ruby bin folder to the PATH. Only used if rubyVersionManager is set to 'custom'",
"type": "string",
"scope": "machine"
"scope": "window"

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is safe to use window scope because untrusted workspace cannot execute command thanks to capabilities.untrustedWorkspaces options.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this one makes sense to not be machine dependent. I know some people use a custom ruby command to add their own activation script, but I don't think this is something we want to support going forward.

capabilities.untrustedWorkspaces can help, but I don't think people inspect the contents of the .vscode folder of repositories they clone from the internet in order to click that "trust this workspace" button.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When someone resorts to custom rubyVersionManager, it is likely that they need something adhoc with maximum flexiblity and it is not unusual that solution differs from one project to another.

If Ruby LSP forces machine scope here, they have to maintain a lines of single shell script with mixed concerns from different, independent projects. I believe it makes Ruby LSP less convenient to use.

I feel clicking the "trust this workspace" button should be treated as "I know what I'm doing", and if they seriously care about security, they can prepare sandboxed environment outside of VS Code (and I think it would be the way to go as it is more generic solution not tied to IDE).

I will investigate if there is VS Code API that allows develops to customize the trust workspace popup to notice them that users should be pay extra attention to .vscode directory.

},
"rubyLsp.formatter": {
"description": "Which tool the Ruby LSP should use for formatting files",
Expand Down Expand Up @@ -478,7 +479,7 @@
"rubyLsp.bundleGemfile": {
"description": "Relative or absolute path to the Gemfile to use for bundling the Ruby LSP server. Do not use this if you're working on a monorepo or your project's Gemfile is in a subdirectory (look into multiroot workspaces instead). Only necessary when using a separate Gemfile for the Ruby LSP",
"type": "string",
"scope": "machine",
"scope": "window",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be window. @alexcrocha what was the reason to make it machine dependent? It is for sure a per-project config.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I agree. It shouldn't have been bundled with the other changes and we should relax it

"default": ""
},
"rubyLsp.testTimeout": {
Expand Down Expand Up @@ -509,7 +510,7 @@
"rubyLsp.rubyExecutablePath": {
"description": "Path to the Ruby installation. This is used as a fallback if version manager activation fails",
"type": "string",
"scope": "machine"
"scope": "window"
},
"rubyLsp.indexing": {
"description": "Indexing configurations. Modifying these will impact which declarations are available for definition, completion and other features",
Expand Down
6 changes: 4 additions & 2 deletions vscode/src/ruby/custom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ export class Custom extends VersionManager {

customCommand() {
const configuration = vscode.workspace.getConfiguration("rubyLsp");
const customCommand: string | undefined = configuration.get("customRubyCommand");

const inspectedCustomRubyCommand = configuration.inspect("customRubyCommand");
const customCommand = inspectedCustomRubyCommand.globalValue
?? inspectedCustomRubyCommand.workspaceValue
?? inspectedCustomRubyCommand.workspaceFolderValue
if (customCommand === undefined) {
throw new NonReportableError(
"The customRubyCommand configuration must be set when 'custom' is selected as the version manager. \
Expand Down
Loading