I've re-installed RVM, Ruby and all gems using rvm implode. When I run rubocop, I receive an error that it is using 2.5 (which I did not explicitly install but seems to come with RVM's Ruby 2.5.1)
Note the line I have highlighted with * * - this may be the issue?
$ which ruby
/Users/Will/.rvm/rubies/ruby-2.5.1/bin/ruby
$ rvm use 2.5.1
Using /Users/Will/.rvm/gems/ruby-2.5.1
$ rubocop
Inspecting 604 files
0 files inspected, no offenses detected
Unknown Ruby version: 2.5
/Users/Will/.rvm/gems/ruby-2.5.1/gems/rubocop-0.49.1/lib/rubocop/processed_source.rb:131:in `parser_class’
/Users/Will/.rvm/gems/ruby-2.5.1/gems/rubocop-0.49.1/lib/rubocop/processed_source.rb:138:in `create_parser’
/Users/Will/.rvm/gems/ruby-2.5.1/gems/rubocop-0.49.1/lib/rubocop/processed_source.rb:94:in `parse’
/Users/Will/.rvm/gems/ruby-2.5.1/gems/rubocop-0.49.1/lib/rubocop/processed_source.rb:36:in `initialize’
/Users/Will/.rvm/gems/ruby-2.5.1/gems/rubocop-0.49.1/lib/rubocop/processed_source.rb:17:in `new’
/Users/Will/.rvm/gems/ruby-2.5.1/gems/rubocop-0.49.1/lib/rubocop/processed_source.rb:17:in `from_file’
/Users/Will/.rvm/gems/ruby-2.5.1/gems/rubocop-0.49.1/lib/rubocop/runner.rb:334:in `get_processed_source’
/Users/Will/.rvm/gems/ruby-2.5.1/gems/rubocop-0.49.1/lib/rubocop/runner.rb:110:in `block in file_offenses’
/Users/Will/.rvm/gems/ruby-2.5.1/gems/rubocop-0.49.1/lib/rubocop/runner.rb:121:in `file_offense_cache’
/Users/Will/.rvm/gems/ruby-2.5.1/gems/rubocop-0.49.1/lib/rubocop/runner.rb:109:in `file_offenses’
/Users/Will/.rvm/gems/ruby-2.5.1/gems/rubocop-0.49.1/lib/rubocop/runner.rb:100:in `process_file’
/Users/Will/.rvm/gems/ruby-2.5.1/gems/rubocop-0.49.1/lib/rubocop/runner.rb:78:in `block in each_inspected_file’
/Users/Will/.rvm/gems/ruby-2.5.1/gems/rubocop-0.49.1/lib/rubocop/runner.rb:75:in `each’
/Users/Will/.rvm/gems/ruby-2.5.1/gems/rubocop-0.49.1/lib/rubocop/runner.rb:75:in `reduce’
/Users/Will/.rvm/gems/ruby-2.5.1/gems/rubocop-0.49.1/lib/rubocop/runner.rb:75:in `each_inspected_file’
/Users/Will/.rvm/gems/ruby-2.5.1/gems/rubocop-0.49.1/lib/rubocop/runner.rb:67:in `inspect_files’
/Users/Will/.rvm/gems/ruby-2.5.1/gems/rubocop-0.49.1/lib/rubocop/runner.rb:39:in `run’
/Users/Will/.rvm/gems/ruby-2.5.1/gems/rubocop-0.49.1/lib/rubocop/cli.rb:82:in `execute_runner’
/Users/Will/.rvm/gems/ruby-2.5.1/gems/rubocop-0.49.1/lib/rubocop/cli.rb:28:in `run’
/Users/Will/.rvm/gems/ruby-2.5.1/gems/rubocop-0.49.1/bin/rubocop:13:in `block in <top (required)>'
*/Users/Will/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/benchmark.rb:308:in `realtime’*
/Users/Will/.rvm/gems/ruby-2.5.1/gems/rubocop-0.49.1/bin/rubocop:12:in `<top (required)>'
/Users/Will/.rvm/gems/ruby-2.5.1/bin/rubocop:23:in `load’
/Users/Will/.rvm/gems/ruby-2.5.1/bin/rubocop:23:in `<main>'
/Users/Will/.rvm/gems/ruby-2.5.1/bin/ruby_executable_hooks:24:in `eval’
/Users/Will/.rvm/gems/ruby-2.5.1/bin/ruby_executable_hooks:24:in `<main>'
Support for Ruby 2.5 was added to Rubocop in version 0.52.0. But you are using 0.49.1.
You need to update Rubocop to at least version 0.52.0 or even better update to the latest version (which is 0.63.1 as of today).
Depending on your setup you simply need to run bundle update rubocop or you might need to specify the desired version in your Gemfile first.
Found this thread when my VScode was looking for rubo cop gem installed within ruby 2.6 when it should have been looking within 2.7.
Not sure if this was the fix or if it was a number of other things but last thing I tried that work was setting the ruby version globally to 2.7
I use rbenv so was able to do rbenv global 2.7.4 and quit/restart vscode and the errors went away.
Related
I'm trying to start Shotgun for a Sinatra app after having upgraded to Ruby 3.0.1, and get this:
$ shotgun
== Shotgun/Thin on http://127.0.0.1:9393/
/Users/me/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/rack-2.2.3/lib/rack/handler/thin.rb:11:in `run': wrong number of arguments (given 2, expected 1) (ArgumentError)
from /Users/me/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/shotgun-0.9.2/bin/shotgun:156:in `<top (required)>'
from /Users/me/.rbenv/versions/3.0.1/bin/shotgun:23:in `load'
from /Users/me/.rbenv/versions/3.0.1/bin/shotgun:23:in `<main>'
Running gem list, I get:
shotgun (0.9.2)
What's going on? Thanks!
Ruby v3.0 introduces a breaking change, relating to keyword vs positional arguments.
The shotgun gem hasn't been updated for a long time; the latest version (0.9.2) was released in September 2016.
Looking at the gem in github, I see there's an open issue about this exact problem you've raised, and someone has already - helpfully - forked the project with a fix.
Unless the original author merges this fix and releases a new version of the gem, you'll need to use a forked version such as the above. For example, update your Gemfile to say:
gem 'shotgun', git: 'https://github.com/delonnewman/shotgun.git'
And then run bundle install.
There's also this open PR with the exact same fix, so you could equally use that fork instead.
... Or alternatively, stick to ruby 2.7 for now.
I'm using my work laptop to contribute to a non-work open-source project. At work we use rbenv to manage Ruby versions, but the open-source project appears to expect gem dependencies to be located in the system Ruby install folder. So when I try to run certain of the project's commands, I'm running into missing gem errors.
The project is Homebrew, and the command I'm running is brew style. When I run the command in my local, I get the following:
Ignoring rainbow-2.2.2 because its extensions are not built. Try: gem pristine rainbow --version 2.2.2
/usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.3/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- rainbow (LoadError)
from /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.3/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/richie.thomas/.gem/ruby/2.3.0/gems/rubocop-0.50.0/lib/rubocop.rb:4:in `<top (required)>'
from /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.3/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.3/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/richie.thomas/.gem/ruby/2.3.0/gems/rubocop-0.50.0/bin/rubocop:6:in `<top (required)>'
from /Users/richie.thomas/.gem/ruby/2.3.0/bin/rubocop:22:in `load'
from /Users/richie.thomas/.gem/ruby/2.3.0/bin/rubocop:22:in `<main>'
Running gem environment returns the following:
RubyGems Environment:
- RUBYGEMS VERSION: 2.6.10
- RUBY VERSION: 2.3.3 (2016-11-21 patchlevel 222) [x86_64-darwin15]
- INSTALLATION DIRECTORY: /Users/richie.thomas/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0
- USER INSTALLATION DIRECTORY: /Users/richie.thomas/.gem/ruby/2.3.0
- RUBY EXECUTABLE: /Users/richie.thomas/.rbenv/versions/2.3.3/bin/ruby
- EXECUTABLE DIRECTORY: /Users/richie.thomas/.rbenv/versions/2.3.3/bin
- SPEC CACHE DIRECTORY: /Users/richie.thomas/.gem/specs
....
I've been advised by other contributors that the easiest path forward would be to disable or uninstall rbenv in order to run the command. I'd really like to avoid uninstalling and reinstalling rbenv every time I want to run this command, but there is nothing in the rbenv documentation that mentions this.
Is there any one-time command I can run, or any configuration setting I can change, so that I can do what I need to do?
I re-ran gem environment and noticed that the following environment variables were defined:
INSTALLATION DIRECTORY: /Users/richie.thomas/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0
USER INSTALLATION DIRECTORY: /Users/richie.thomas/.gem/ruby/2.3.0
The value of INSTALLATION DIRECTORY is what I expected to be used to run the command, and I noticed the value of USER INSTALLATION DIRECTORY is what showed up in the error stacktrace.
Since I was unable to figure out how my machine was determining which variable to use, I simply renamed ~/.gem/ to ~/.gem2/ and re-ran the brew style command I originally wanted. This was successful!
I have installed ruby 2.2.5 / gem 2.3.0 in CygWin but I am getting installation errors in using gem install.
As suggested in some places, I also tried gem update --system but even that did not help.
How to correct this issue?
I have attached the output of the commands I ran:
$ gem install napa --backtrace
ERROR: While executing gem ... (TypeError)
no implicit conversion of nil into String
/usr/local/share/ruby/site_ruby/rubygems/installer.rb:168:in `check_executable_overwrite'
/usr/local/share/ruby/site_ruby/rubygems/installer.rb:409:in `block in generate_bin'
/usr/local/share/ruby/site_ruby/rubygems/installer.rb:396:in `each'
/usr/local/share/ruby/site_ruby/rubygems/installer.rb:396:in `generate_bin'
/usr/local/share/ruby/site_ruby/rubygems/installer.rb:236:in `install'
/usr/local/share/ruby/site_ruby/rubygems/request_set.rb:156:in `block in install'
/usr/local/share/ruby/site_ruby/rubygems/request_set.rb:140:in `each'
/usr/local/share/ruby/site_ruby/rubygems/request_set.rb:140:in `install'
/usr/local/share/ruby/site_ruby/rubygems/commands/install_command.rb:249:in `install_gem'
/usr/local/share/ruby/site_ruby/rubygems/commands/install_command.rb:291:in `block in install_gems'
/usr/local/share/ruby/site_ruby/rubygems/commands/install_command.rb:287:in `each'
/usr/local/share/ruby/site_ruby/rubygems/commands/install_command.rb:287:in `install_gems'
/usr/local/share/ruby/site_ruby/rubygems/commands/install_command.rb:202:in `execute'
/usr/local/share/ruby/site_ruby/rubygems/command.rb:307:in `invoke_with_build_args'
/usr/local/share/ruby/site_ruby/rubygems/command_manager.rb:167:in `process_args'
/usr/local/share/ruby/site_ruby/rubygems/command_manager.rb:137:in `run'
/usr/local/share/ruby/site_ruby/rubygems/gem_runner.rb:54:in `run'
/usr/bin/gem:21:in `<main>'
$ gem update --system
Updating rubygems-update
ERROR: While executing gem ... (TypeError)
no implicit conversion of nil into String
Skip to the bottom for the short answer and not join me on my journey.
So I've been working on this today because for the life of me, what worked last year to get it working did not work this year. All the steps are attempted while using admin permissions. I had done some questionable commands from other threads that required me to downgrade gem to something 6 years ago, don't do that I could not figure out how to revert so I deleted my Cygwin install and started fresh and clean for this. Windows 10 is my operating system.
I used cygwin's installer to install the current version of ruby, gem and sass. (I'm positive as time goes on these will numbers will become out of date).
ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-cygwin]
ruby-devel 2.3.3-1
gem 2.6.11
Sass 3.4.21 selective steve
Side note I tend to use 'Category' under the View drop down and select the devel category. I also let cygwin select dependencies for me automatically.
At this point I am having the same error. Looking at the log provided by the output I decided to try out some of the commands smashed in there like 'gcc' which was absent. Loading up the cygwin installer again, installed gcc version 5.4.0 (Package called gcc-core: GNU Compiler Collection (C, OpenMP))
Attempting to run 'gem install compass' again, another error, it cant find 'make'. Warm up the installer again and locate 'make: The GNU Version of the 'make' utility (4.2.1-2)
Running the compass install command again and checking the log: 'libffi' doesnt look like its there. In our cygwin installer says under the libs category I have libffi6 v2.2.1-2 already. I'm going to give libffi-devel a shot because I'm desperate to get compass installed.
This worked! Navigate to your directory and run the command 'compass watch' I'm pretty excited. Running 'compass -v' in the command line shows us the version 1.0.3
Short answer:
Useing the Cygwin installer to install the following Packages
ruby: interpreted object oriented scripting language
ruby-devel: interpreted object oriented scripting language
ruby-gems: Ruby Module management system
ruby-sass: Ruby css compiler extension
make: The GNU version of the make utility
gcc-core: GNU Compiler Collection(c, OpenMP)
libffi-devel: Portable foreign function interface libary
Then run cygwin as a administrator and input the command 'gem install compass'.
I'm trying to get Capistrano to work on my MacBook (OSX Mountain Lion) but am having a lot of difficulties. It started with it throwing an error:
cillosis:myapp macbook$ cap deploy
/Library/Ruby/Gems/1.8/gems/sshkit-1.2.0/lib/sshkit.rb:32: undefined method `require_relative' for main:Object (NoMethodError)
from /Library/Ruby/Site/1.8/rubygems/core_ext/kernel_require.rb:55:in `gem_original_require'
from /Library/Ruby/Site/1.8/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Library/Ruby/Gems/1.8/gems/capistrano-3.0.1/lib/capistrano/all.rb:2
from /Library/Ruby/Site/1.8/rubygems/core_ext/kernel_require.rb:55:in `gem_original_require'
from /Library/Ruby/Site/1.8/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Library/Ruby/Gems/1.8/gems/capistrano-3.0.1/bin/cap:2
from /usr/bin/cap:19:in `load'
from /usr/bin/cap:19
It seemed I had Ruby 1.8 installed and it doesn't work correctly with Capistrano (found this Googling around).
So I installed Ruby 2.0 using rvm. RVM starting throwing a bunch of errors so I got rid of it using rvm implode and found that the 2.0 version was still on my computer. I checked my $PATH and the locations it pointed at contained the Ruby 1.8. So I renamed that to *ruby_old* and copied the new ruby to that folder (/usr/bin). Then when I did a ruby -v it came back as version 2.0. So I thought, great, now we can finally run Capistrano.
Just to be sure, I did a gem update which came back as having updated the sshkit gem which was throwing the error before. So I go to deploy, and get the same exact error as I started with.
I know the deploy.rb script is correct because I use it all the time on another Mac.
TL;DR; After some fumbling, when I type ruby -v it comes back as using version 2.0 but when I do a cap deploy with Capistrano, it tries to use version 1.8 of ruby. How do I fix this?
The dumb, but simple way out would be to completely remove RVM and both ruby versions, then install again from scratch. I would recommend 1.9.x over 2.0 due to some gems not being up to speed yet, but that's up to you.
Another option would be to specify the ruby version in your gemfile (as heroku does it), then do a "bundle exec cap deploy". Again, no guarantees - but it might force capistrano to behave the way you want until you find a proper solution.
After installing RVM the other day I can no longer use compass watch as I could.
I've tried updating the system, installing compass again, as well as sass, all to no avail.
Here's the error I get in Terminal:
/Users/john/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/definition.rb:16:in `build': /Gemfile not found (Bundler::GemfileNotFound)
from /Users/john/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler.rb:148:in `definition'
from /Users/john/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler.rb:116:in `setup'
from /Users/john/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler.rb:132:in `require'
from /Users/john/.rvm/gems/ruby-2.0.0-p247/gems/compass-0.12.2/bin/compass:26:in `<top (required)>'
from /Users/john/.rvm/gems/ruby-2.0.0-p247/bin/compass:23:in `load'
from /Users/john/.rvm/gems/ruby-2.0.0-p247/bin/compass:23:in `<main>'
from /Users/john/.rvm/gems/ruby-2.0.0-p247/bin/ruby_executable_hooks:15:in `eval'
from /Users/john/.rvm/gems/ruby-2.0.0-p247/bin/ruby_executable_hooks:15:in `<main>'
I've attempted to use bundle update sass-rails per this question, but get the error Could not locate Gemfile
I've also tried to follow the advise here to no avail.
At this point I'm a bit lost. I'm brand new to the Ruby world as well as RVM, and am not the most proficient Terminal user to begin with.
Thanks for any assistance or insight-
/Gemfile not found was a bug in older version of rubygems-bundler gem, run:
rvm #global do gem update rubygems-bundler
and it should work fine
I don't have the answer as to how to fix the problem itself, but I did go through with simply removing it for the time being.
I used rvm implode to remove rvm from my machine per this post.
Everything worked fine after that. Unfortunately that'll delay my experimenting with the Ruby world for a little while longer as I don't have time to figure out how to have RVM without the complications it seemingly brought.
Best,