Updating rspec gem has caused 'gem' command to become unstable/buggy. Help! - ruby-on-rails

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

Related

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

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

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.

Error compiling Compass LoadError on line ["179"] .. data.rb: Cannot load such file

I've trawled every possible Ruby resource looking for a solution to this error but can't for the life of me figure out what I'm doing wrong.
I'm trying to get my sass compiler working for a Drupal build from a previous project. Using the following stack: Ruby 2.3.0, Sass 3.4.22, Compass & Compass Core 1.0.3, Bundler 1.11.2. I've already tried uninstalling and reinstalling the gems but to no avail.
The error occurs when I run the bundle exec compass watch command, which results in the following output:
LoadError on line ["179"] of /Users/somedude/.rvm/gems/ruby-2.3.0/gems/compass-core-1.0.3/lib/compass/configuration/data.rb: cannot load such file -- breakpoint
/Users/somedude/.rvm/gems/ruby-2.3.0/gems/compass-core-1.0.3/lib/compass/configuration/data.rb:179:in `require'
/Users/somedude/Sites/devdesktop/taronga-dev/docroot/sites/tarongazoo/themes/custom/taronga/config.rb:9:in `get_binding'
/Users/somedude/.rvm/gems/ruby-2.3.0/gems/compass-1.0.3/lib/compass/configuration/serialization.rb:24:in `eval'
/Users/somedude/.rvm/gems/ruby-2.3.0/gems/compass-1.0.3/lib/compass/configuration/serialization.rb:24:in `parse_string'
/Users/somedude/.rvm/gems/ruby-2.3.0/gems/compass-1.0.3/lib/compass/configuration/serialization.rb:15:in `block in _parse'
/Users/somedude/.rvm/gems/ruby-2.3.0/gems/compass-1.0.3/lib/compass/configuration/serialization.rb:14:in `open'
/Users/somedude/.rvm/gems/ruby-2.3.0/gems/compass-1.0.3/lib/compass/configuration/serialization.rb:14:in `_parse'
/Users/somedude/.rvm/gems/ruby-2.3.0/gems/compass-1.0.3/lib/compass/configuration/file_data.rb:7:in `block in new_from_file'
/Users/somedude/.rvm/gems/ruby-2.3.0/gems/compass-core-1.0.3/lib/compass/configuration/inheritance.rb:207:in `with_defaults'
/Users/somedude/.rvm/gems/ruby-2.3.0/gems/compass-1.0.3/lib/compass/configuration/file_data.rb:6:in `new_from_file'
/Users/somedude/.rvm/gems/ruby-2.3.0/gems/compass-1.0.3/lib/compass/configuration/helpers.rb:19:in `configuration_for'
/Users/somedude/.rvm/gems/ruby-2.3.0/gems/compass-1.0.3/lib/compass/configuration/helpers.rb:69:in `add_project_configuration'
/Users/somedude/.rvm/gems/ruby-2.3.0/gems/compass-1.0.3/lib/compass/commands/project_base.rb:37:in `add_project_configuration'
/Users/somedude/.rvm/gems/ruby-2.3.0/gems/compass-1.0.3/lib/compass/commands/project_base.rb:25:in `configure!'
/Users/somedude/.rvm/gems/ruby-2.3.0/gems/compass-1.0.3/lib/compass/commands/project_base.rb:15:in `initialize'
/Users/somedude/.rvm/gems/ruby-2.3.0/gems/compass-1.0.3/lib/compass/commands/update_project.rb:41:in `initialize'
/Users/somedude/.rvm/gems/ruby-2.3.0/gems/compass-1.0.3/lib/compass/exec/sub_command_ui.rb:42:in `new'
/Users/somedude/.rvm/gems/ruby-2.3.0/gems/compass-1.0.3/lib/compass/exec/sub_command_ui.rb:42:in `perform!'
/Users/somedude/.rvm/gems/ruby-2.3.0/gems/compass-1.0.3/lib/compass/exec/sub_command_ui.rb:15:in `run!'
/Users/somedude/.rvm/gems/ruby-2.3.0/gems/compass-1.0.3/bin/compass:30:in `block in '
/Users/somedude/.rvm/gems/ruby-2.3.0/gems/compass-1.0.3/bin/compass:44:in `'
/Users/somedude/.rvm/gems/ruby-2.3.0/bin/compass:23:in `load'
/Users/somedude/.rvm/gems/ruby-2.3.0/bin/compass:23:in `'
/Users/somedude/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `eval'
/Users/somedude/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `'
Has anyone else encountered something similar when trying to get their SASS compiler to run? ANY help would be much appreciated.
Thanks,
Mark.
Resolved! It was such a simple oversight.
It turns out I just needed to call the missing gems via my Gemfile:
gem 'compass'
gem 'sass'
gem 'sass-globbing'
gem 'breakpoint'
There were also a few version conflicts, but these were resolved by reinstalling gems by specific version, for example:
gem install breakpoint -v 2.5.0
Hopefully this points anyone else having similar issues in the right direction.
Cheers.
Dependencies should automatically be installed, but you could try manually installing the breakpoint gem that it can't find:
gem install breakpoint

I am trying to install Rails on Mac however it wont let me

I am trying to install Rails on my Mac however everytime i try to install it I receive this:
$ gem install rails
/Users/macbook/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/psych.rb:369:in `parse': (<unknown>): mapping values are not allowed in this context at line 2 column 4 (Psych::SyntaxError)
from /Users/macbook/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/psych.rb:369:in `parse_stream'
from /Users/macbook/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/psych.rb:317:in `parse'
from /Users/macbook/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/psych.rb:244:in `load'
from /Users/macbook/.rvm/rubies/ruby-2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/config_file.rb:332:in `load_file'
from /Users/macbook/.rvm/rubies/ruby-2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/config_file.rb:197:in `initialize'
from /Users/macbook/.rvm/rubies/ruby-2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/gem_runner.rb:74:in `new'
from /Users/macbook/.rvm/rubies/ruby-2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/gem_runner.rb:74:in `do_configuration'
from /Users/macbook/.rvm/rubies/ruby-2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/gem_runner.rb:39:in `run'
from /Users/macbook/.rvm/rubies/ruby-2.1.0/bin/gem:21:in `<main>'
I have searched hours trying to figure this out so any help would be greatly appreciated. I take it this is a simple fix, so apologize in advance for this easy question.
It could be that you are using newer version of ruby i.e 2.1.0 which was just released today and the relevant gems for rails are not fully compatible with it.
You can install rails in ruby 2.0.0 through RMV i.e
$ rvm install 2.0.0
$ rvm use 2.0.0
$ ruby -v
# should retrun 2.0.0-p...
$ gem install rails

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

Resources