Shotgun doesn't start after updating to Ruby 3.0.1 - ruby

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.

Related

Rubocop using wrong version of Ruby - Fails

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.

Padrino Project Generator Fails - Undefined Method `add_builtin_type'

I'm new to both Ruby and Sinatra/Padrino so I apologize if I'm missing something really simple.
I have Sinatra working fine, as I can build a very simple "hello" app and see it work.
I wanted to move on and generate a new Padrino project, but when I do this:
$ padrino g project foobar
I get this:
/Users/dave/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.0/lib/active_support/ordered_hash.rb:3:in `<top (required)>': undefined method `add_builtin_type' for Psych:Module (NoMethodError)
from /Users/dave/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:121:in `require'
from /Users/dave/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:121:in `require'
from /Users/dave/.rvm/gems/ruby-2.1.5/gems/padrino-gen-0.12.4/lib/padrino-gen.rb:3:in `<top (required)>'
from /Users/dave/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/dave/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/dave/.rvm/gems/ruby-2.1.5/gems/padrino-gen-0.12.4/bin/padrino-gen:12:in `<main>'
I have tried installing the Psych gem but this didn't change anything. I have no idea what to try next, or how to really interpret the error message. Any nudges in the right direction you can give me?
Bug reports show this may be an RVM issue.
I suggest changing from RVM to "ruby-install" and "chruby" because IMHO these are simpler, easier, and better at installing dependencies including psych and its libraries.
As joelparkerhenderson noted, the error message shows problems with gem files in the .rvm directory, suggesting some issue or conflict with rvm. Switching to system ruby solved the problem for me. I don't really need to use a specific version of ruby on this project, so that's a fine workaround for me.
I had this problem while using Ruby 2.1.5. After reading comments on here I realized it's not a RVM problem, but a ruby problem. I switched to 2.0.0-p576 and everything works. Psych must not be compatible with the new ruby versions.
However I don't understand how a different ruby version would cause this method to go missing. If anyone could explain that I would be grateful!
I ran into this using rbenv and padrino 0.13.0. Tried many versions of Ruby, including the system Ruby on OS X El Capitan, but found that that made no difference, so I'm now running the latest stable one (2.2.4).
Eventually I tried each version of the psych gem and found I could only get padrino g to work with an older version of the gem. Psych version 2.0.8 worked, while every newer version (up to the current 2.0.16) failed.
So: gem install psych -v=2.0.8 && gem uninstall psych -v '>= 2.0.9'
With me, after a lot of googling and reading various thread on S.O., it was only my rvm that was the problem. I was getting the rvm 'WARNING!' that rvm wasn't first in $PATH. You can check this with echo $PATH. Check out your ~/.bashrc see if there is anything like heroku toolbelt or linuxbrew, or whatever, loading themselves into your PATH at the FRONT i.e. PRE-PENDING your path, rather than APPENDING. This is indicated by something like export PATH="/usr/local/heroku/bin:$PATH". That sets heroku at the beginning of your PATH. Simply change it to export PATH="$PATH:/usr/local/heroku/bin".
I was trying to start a padrino project with activesupport, and this was causing problems. Changing to an earlier version of Ruby, as suggested in another thread, didn't cut it, because activesupport requires 2.2.0 or up.
Fixing my PATH, ensuring that rvm was initialized at the very beginning of the PATH, fixed my Padrino problem, and was able to initialize a project with the following command:
padrino g project sample_blog -t shoulda -e haml -c sass -s jquery -d activerecord -b
I know that's all a little off-tangent, but I think it's bound to help one or two people out there!
PS I'm using ruby 2.2.2p95 in this project folder.

Capistrano Using Old Ruby Version

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.

Compass no longer working after ruby update

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,

toy/doc undefined method 'available?'

I'm attempting to build local Ruby documentation as suggested here:
https://github.com/toy/doc
However when I use the default Rakefile I get the following:
[Documentation]$ rake build
configuring and updating: 100.0%
rake aborted!
undefined method `available?' for Gem:Module
/Users/snowcrash/.rvm/gems/ruby-2.0.0-p195/gems/sdoc-0.2.20/lib/sdoc/json_backend.rb:9:in `<top (required)>'
Any suggestions?
I don't know much about ruby (and even less about the gem ecosystem built up around it), but I believe a possible workaround for this issue is to find what gems the project requires and manually install them. In the case of this particular project, it looks like you need the gem "fspath".
At the project root, type
gem install fspath
and try re-running rake.
I honestly don't know the actual root cause of the issue, other than that presumably, your version of the 'gem' program is probably > v2, while some other program (rake?) expects it to be older and still support the "available?" method.
If installing "fspath" doesn't fix the issue, you could try downgrading your version of gem by doing
gem install -v [some version of gem older than v2]
Check gem install --help for more info on this.
This is just for future visitor who has the same issue.
As ekremkaraca said, you can just solve this by downgrading rubygems.
rvm install --force rubygems 1.4.2

Resources