Use project directory's rvm ruby version
See original GitHub issueThe VSCode Rubocop extension should be using the current project’s rvm/ruby version instead of the system default. The extension should be utilizing the same dependencies as the current project.
Not sure if #23 is related
Problem
When you are using something like rubocop-rspec
it will install to the project’s ruby version, but the rubocop extension will not have access to the correct dependant gems because it’s using a different version that doesn’t have that gem installed.
Error Codes
When the extension tries to run I see something like this pop up:
cannot load such file -- rubocop-rspec /Users/codyswartz/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:120:in `require' /Users/codyswartz/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:120:in `require' /Users/codyswartz/.rvm/gems/ruby-2.4.1/gems/rubocop-0.58.2/lib/rubocop/config_loader_resolver.rb:15:in `block in resolve_requires' /Users/codyswartz/.rvm/gems/ruby-2.4.1/gems/rubocop-0.58.2/lib/rubocop/config_loader_resolver.rb:11:in `each' /Users/codyswartz/.rvm/gems/ruby-2.4.1/gems/rubocop-0.58.2/lib/rubocop/config_loader_resolver.rb:11:in `resolve_requires' /Users/codyswartz/.rvm/gems/ruby-2.4.1/gems/rubocop-0.58.2/lib/rubocop/config_loader.rb:43:in `load_file' /Users/codyswartz/.rvm/gems/ruby-2.4.1/gems/rubocop-0.58.2/lib/rubocop/config_loader.rb:82:in `configuration_from_file' /Users/codyswartz/.rvm/gems/ruby-2.4.1/gems/rubocop-0.58.2/lib/rubocop/config_store.rb:44:in `for' /Users/codyswartz/.rvm/gems/ruby-2.4.1/gems/rubocop-0.5...
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Ruby Version Manager - Typical RVM Project Workflow
RVM supports multiple types of files to allow configuring a project for automated ruby switching. In any case make sure to add those...
Read more >RVM: specify a ruby version to use
I use project-specific rvmrc files, so I can use different rubies and gemsets for each project, and changing into the directory ...
Read more >How to use RVM as a Ruby Version Manager
Navigate to the root folder of your Ruby or Ruby on Rails project in the terminal. Before you type in the command below,...
Read more >Easy way to setting Ruby Version Manager (RVM) on ...
RVM is Ruby Version Manager. It's a command-line tool that allows you to easily install, manage, and work with different Ruby environments.
Read more >Ruby Version Managers
If you need Ruby 2.3.1, RVM uses the files in the ruby-2.3.1 directory; if you need Ruby 2.2.2, it gets the files from ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This is a very hacky solution, but its working well for me. I created this file in my projects bin directory:
bin/vscode_rubocop
Then set the
executePath
tobin/vscode_
, note the missingrubocop
on the end, thats because it gets automatically appended to theexecutePath
by the extension.This assumes you have rubocop binstubbed.
I think I have found a more maintainable way to fix this among all the projects you have. On the settings set the
Execute Path
(ruby.rubocop.executePath
) with the valuervm . do bin/bundle exec
(with a space character at the end). Just that, is really easy. 👌