-
Notifications
You must be signed in to change notification settings - Fork 284
Support for ${workspaceRoot} in ruby.lint.rubocop.path #187
Description
Your environment
vscode-rubyversion: 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?