Skip to content
This repository was archived by the owner on Jul 31, 2023. It is now read-only.

Support for ${workspaceRoot} in ruby.lint.rubocop.path #187

@scottohara

Description

@scottohara

Your environment

  • vscode-ruby version: 0.12.1
  • Ruby version: 2.4.1
  • VS Code version: 1.14.2
  • Operating System: macOS Sierra 10.12.6
  • Hardware (optional): MacBook Pro

Expected behavior

A common practice is to have a project's gems vendored, i.e. installed using bundle install --path vendor/bundle --binstubs.

This enables each project to specify their own (potentially different) version of rubocop, rather than a single globally installed version.

I'm trying to configure vscode-ruby to always lint my project's *.rb files using the executable found in ${workspaceRoot}/bin/rubocop.

Actual behavior

Attempt 1

vscode settings.json file:

"ruby.lint": {
  "rubocop": {
    "path": "${workspaceRoot}/bin"
  }
}

In the Developer Tools, the following messages are shown when vscode launches:

[Extension Host] Rubocop not installed
[Extension Host] Linter error: rubocop Error: spawn ${workspaceRoot}/bin/rubocop ENOENT

Linting fails because vscode-ruby is unable to find the rubocop executable, as the ${workspaceRoot} variable is not expanded/resolved.

Attempt 2

vscode settings.json file:

"ruby.lint": {
  "rubocop": {
    "path": "./bin"
  }
}

In the Developer Tools, the following messages are shown when vscode launches:

[Extension Host] Rubocop not installed

Despite this, linting does sometimes work, but not always.

I suspect that it is executing the command relative to cwd, so when cwd == workspaceRoot it works, and when cwd !== workspaceRoot it doesn't.

There is an open issue regarding expanding/resolving variables in settings.json (microsoft/vscode#2809), but it has been discussed for over a year and doesn't seem to be nearing resolution any time soon.

In lieu of this, some extensions such as the pythonVSCode implement their own support for expanding environment variables in their config.

Any chance of implementing something similar in vscode-ruby?

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestAdds currently unsupported functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions