Getting " `method_missing': undefined method `this'" error when running Capistrano [duplicate] - ruby-on-rails

This question already has answers here:
rails error method_missing': undefined method `this' for Gem::Specification
(3 answers)
Closed 6 years ago.
I’m using Ruby 2.3 with Rails 4.2.7. I'm trying to install Capistrano on my system but am getting a baffling error when I try and check the version using “cap —version”. Does anyone know what the error means and what I have done wrong when installing my gem? Below is the output of installing the gem and then running the command …
root#ubuntumachine:/home/rails/networkproject# gem install capistrano
Successfully installed capistrano-3.6.1
Parsing documentation for capistrano-3.6.1
Done installing documentation for capistrano after 1 seconds
1 gem installed
root#ubuntumachine:/home/rails/networkproject# cap --version
/usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/specification.rb:2158:in `method_missing': undefined method `this' for #<Gem::Specification:0xa16c74 capistrano-3.6.1> (NoMethodError)
from /usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/specification.rb:1057:in `find_active_stub_by_path'
from /usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:64:in `require'
from /usr/local/rvm/gems/ruby-2.3.0/gems/capistrano-3.6.1/bin/cap:2:in `<top (required)>'
from /usr/local/rvm/gems/ruby-2.3.0/bin/cap:23:in `load'
from /usr/local/rvm/gems/ruby-2.3.0/bin/cap:23:in `<main>'
from /usr/local/rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `eval'
from /usr/local/rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `<main>'

I ran into something like this a couple of months ago, but the problem was intermittent.
For an immediate/temporary fix, try running gem pristine --all.
For a permanent solution, make sure you're running the latest version of RubyGems by running gem update --system.

Related

Troubles with ruby update

I encountered some errors with my redmine installation.
I tried to update ruby and gems, but I'm not finding out a solution.
When I start the server, I got this answer :
:/usr/share/redmine# rails server
You must use Bundler 2 or greater with this lockfile.
So I tried to update it but I'm still stuck with it :
gem update --system
Installing RubyGems 3.2.16
/usr/lib/ruby/vendor_ruby/rubygems/defaults/operating_system.rb:43:in `<top (required)>': uninitialized constant Gem::BasicSpecification (NameError)
from /var/lib/gems/2.3.0/gems/rubygems-update-3.2.16/lib/rubygems.rb:1348:in `require'
from /var/lib/gems/2.3.0/gems/rubygems-update-3.2.16/lib/rubygems.rb:1348:in `<top (required)>'
from setup.rb:23:in `require'
from setup.rb:23:in `<main>'
Has anyone an idea ?
yes, but same at the end.
I finally "solved" the trouble by updating everything (redmine, debian 9->10 etc...)
Not a real solution but it works fine now...

Rails not running after Ruby update (possibly RVM related)

I resorted to upgrading Ruby from 2.3.0 to 2.3.1 because of a really weird error I was getting and not being able to even come close to finding more info around google/SO.
Now after trying to figure this out I am getting this error whenever I try to run the project, or run bundle or rails in bash
/usr/local/rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:127:in `require': cannot load such file -- bundler (LoadError)
from /usr/local/rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:127:in `rescue in require'
from /usr/local/rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:40:in `require'
from /usr/local/rvm/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.16.0/exe/bundle:10:in `<top (required)>'
from /usr/local/rvm/gems/ruby-2.3.1/bin/bundle:23:in `load'
from /usr/local/rvm/gems/ruby-2.3.1/bin/bundle:23:in `<main>'
from /usr/local/rvm/gems/ruby-2.3.1/bin/ruby_executable_hooks:15:in `eval'
from /usr/local/rvm/gems/ruby-2.3.1/bin/ruby_executable_hooks:15:in `<main>'
I have already tried reinstalling Ruby, RVM, bundler, but the error persists. I cannot find much info on that specific error around the web so I hope someone can help me troubleshoot this through here. Let me know if there are any specific logs I can provide and I will happily add more info.
EDIT:
I just noticed the path is ...ruby-2.3.1/lib/ruby/ 2.3.0 ... (the difference of 2.3.1 and 2.3.0)
When I upgraded to 2.3.1 I uninstalled previous versions. Could that be an issue since the error comes from a path that refers to a non-existing version of ruby?
Not sure why all this happened and what was wrong with the bundler, but what ended up fixing it for me was this command:
gem update --system

undefined method `source_index' for Gem:Module (NoMethodError)

I'm running a Rails 2.3.5 application and upon running script/server I am shown the following:
./script/../config/../vendor/rails/railties/lib/rails/gem_dependency.rb:21:in `add_frozen_gem_path': undefined method `source_index' for Gem:Module (NoMethodError)
from ./script/../config/boot.rb:60:in `load_initializer'
from ./script/../config/boot.rb:44:in `run'
from ./script/../config/boot.rb:17:in `boot!'
from ./script/../config/boot.rb:123
from script/server:2:in `require'
from script/server:2
If I comment out line 60 in boot.rb (Rails::GemDependency.add_frozen_gem_path) and run script/server, I get this:
=> Booting WEBrick
=> Rails 2.3.5 application starting on http://0.0.0.0:3000
./script/../config/../vendor/rails/railties/lib/rails/gem_dependency.rb:21:in `add_frozen_gem_path': undefined method `source_index' for Gem:Module (NoMethodError)
from ./script/../config/../vendor/rails/railties/lib/initializer.rb:298:in `add_gem_load_paths'
from ./script/../config/../vendor/rails/railties/lib/initializer.rb:132:in `process'
from ./script/../config/../vendor/rails/railties/lib/initializer.rb:113:in `send'
from ./script/../config/../vendor/rails/railties/lib/initializer.rb:113:in `run'
from /home/developer/bigpink/config/environment.rb:13
from /home/developer/bigpink/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in `require'
from /home/developer/bigpink/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in `require'
from /home/developer/bigpink/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in `new_constants_in'
from /home/developer/bigpink/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in `require'
from /home/developer/bigpink/vendor/rails/railties/lib/commands/server.rb:84
from script/server:3:in `require'
from script/server:3
So, not really sure what to do. Hoping I can get some quick help. Thanks!
I just ran into this problem myself while trying to upgrade an older Rails app from REE 1.8.7 to 1.9.3-p385. Oddly, Ruby 1.9.3-p327 works just fine. What it came down to was ruby-1.9.3-p385 had installed RubyGems version 2.0.2 for me, and 1.9.3-p327 has RubyGems v1.8.23 installed.
Gem.source_index has been deprecated for a while, but since Rails 2.3 is not getting any updates except critical security patches, this will never get fixed. RubyGems v2.0 finally removed that method. Downgrade to any rubygems version prior to 2.0.0, like 1.8.25 to get the functionality back for now. You can get a compatible version using gem update --system 1.8.25.
As a very important aside, Rails 2.3.5 needs to be updated to a minimum of 2.3.17. There are critical security vulnerabilities that open you up to some very nasty attacks. In the long term, upgrading to 3.x needs to be considered a very strong need.
for rvm users,
rvm install rubygems 1.8.2 --force
This helped me: http://djellemah.com/blog/2013/02/27/rails-23-with-ruby-20/
I did this in combination with gem update --system 1.8.25, which might not be needed for your case.
Another way to do this is to install slimgems: gem install slimgems. This is a drop-in fork of RubyGems that works better with old versions.
Update: In addition to the #uxp answer, if you running this command on a Mac running Catalina, there is a small change in command, you need to add -n.
So the command would be sudo gem update --system -n 1.8.25

Can't run rails server after accidentally running $ gem update --system

I ran gem update --system thinking it would solve a problem I was having, and now I can't run rails server. It won't load and instead, I keep getting the following. Can someone tell me how to undo this and revert back to before I ran the update?
I've already ran git checkout, but the problem persists...
/usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/bundler-1.1.5/lib/bundler/rubygems_integration.rb:187:in `stub_source_index170': uninitialized constant Gem::SourceIndex (NameError)
from /usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/bundler-1.1.5/lib/bundler/rubygems_integration.rb:353:in `stub_rubygems'
from /usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/bundler-1.1.5/lib/bundler/rubygems_integration.rb:250:in `replace_entrypoints'
from /usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/bundler-1.1.5/lib/bundler/runtime.rb:14:in `setup'
from /usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/bundler-1.1.5/lib/bundler.rb:107:in `setup'
from /usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/rubygems-bundler-1.0.7/lib/rubygems-bundler/noexec.rb:66:in `setup'
from /usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/rubygems-bundler-1.0.7/lib/rubygems-bundler/noexec.rb:78:in `<top (required)>'
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:110:in `require'
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:110:in `rescue in require'
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:35:in `require'
from /usr/local/rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:9:in `<main>'
I had the same issue today. Updating bundler to the latest version fixed the problem:
gem update bundler
And if you are running rbenv
rbenv rehash
Seems like the latest version of Rubygems is buggy.
You just have to revert back to an older version with the following command and everything should work fine :
gem update --system 1.8.24

Updating rspec gem has caused 'gem' command to become unstable/buggy. Help!

I have installed the latest rspec gem and now every 'gem' command, no matter what, throws this error:
egervari#egervari:~/Websites/training$ gem -v
Invalid gemspec in [/usr/local/lib/ruby/gems/1.9.1/specifications/rspec-core-2.6.2.gemspec]: invalid date format in specification: "2011-05-21 00:00:00.000000000Z"
/usr/local/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:277:in `block in _resort!': undefined method `name' for nil:NilClass (NoMethodError)
from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:276:in `sort!'
from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:276:in `_resort!'
from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:270:in `_all'
from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:402:in `each'
from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems.rb:477:in `map'
from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems.rb:477:in `find_files'
from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems.rb:1061:in `load_plugins'
from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/gem_runner.rb:85:in `<top (required)>'
from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /usr/local/bin/gem:9:in `<main>'
It has completely locked up my rails development. I can't do anything because of this.
I am on Ubuntu 11.04. I've googled this and it seems I am not the only person who has ran into this. However, I have not come across a solution.
If you don't know how to fix this, how can I manually get rid of all the gems and just start from scratch?
EDIT: It seems that opening up the file and changing it to "2011-05-21" fixes it... but how can this happen? I don't mean to bitch, but I run into weird things with Ruby and Rails all day long. 2 weeks into development and the "problems" I run into just never seem to stop. I'm getting really nervous/worried about my choice to use Rails :(
EDIT 2: My versions
egervari#egervari:~/Websites/training$ ruby -v
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux]
egervari#egervari:~/Websites/training$ gem -v
1.8.1
I had this issue in my Rails app under Ruby 1.9.2p0 (gem version 1.7.2). I manually uninstalled rspec-core 2.6.2 by going into (in my case) /Users/smei/.rvm/gems/ruby-1.9.2-p0 and removing all the rspec-core 2.6.2 stuff. It was not showing up in my list of rspec-core versions when I did gem uninstall.
Then I locked down rspec-core to 2.6.0, and that solved the problem.
What versions of ruby and rubyems are you using?
ruby -v
gem -v

Resources