question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use project directory's rvm ruby version

See original GitHub issue

The 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:open
  • Created 5 years ago
  • Reactions:1
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
yelvertcommented, Mar 7, 2020

This is a very hacky solution, but its working well for me. I created this file in my projects bin directory:

bin/vscode_rubocop

#! /usr/bin/env bash -l
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )/.."
cd "${DIR}"
rvm . do bin/rubocop "$@"

Then set the executePath to bin/vscode_, note the missing rubocop on the end, thats because it gets automatically appended to the executePath by the extension.

This assumes you have rubocop binstubbed.

1reaction
limcrosscommented, Nov 8, 2020

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 value rvm . do bin/bundle exec (with a space character at the end). Just that, is really easy. 👌

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found