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
Related
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...
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
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
I created a fresh project using rails new Project -d=postgresql. If I then run rails server, I get the following error message:
C:/GemRepository/gems/actionpack-3.1.3/lib/action_dispatch.rb:34:in `require': cannot load such file -- active_model (LoadError)
from C:/GemRepository/gems/actionpack-3.1.3/lib/action_dispatch.rb:34:in `<top (required)>'
from C:/GemRepository/gems/railties-3.1.3/lib/rails/commands/server.rb:3:in `require'
from C:/GemRepository/gems/railties-3.1.3/lib/rails/commands/server.rb:3:in `<top (required)>'
from C:/GemRepository/gems/railties-3.1.3/lib/rails/commands.rb:48:in `require'
from C:/GemRepository/gems/railties-3.1.3/lib/rails/commands.rb:48:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
I also tried
gem which active_model
which returned
C:/GemRepository/gems/activemodel-3.1.1/lib/active_model.rb
Please help me.
Had this problem, came across this post. This fixed it for me:
rvm gemset pristine
Well, I managed to solve it.
I restarted my computer, deleted everything from my gem repository, reinstalled rubygems (ruby setup.rb) and reinstalled rails (gem install rails).
Thanks anyway :)
What version of rails is in the gem file? And have you run 'bundle install'?
I notice that Actionpack is 3.1.3 is called by the server, but the activemodel found is 3.1.1.
Run the bundle command from the project directory
I had a similar error and it was due to accidentally corrupting my Gemfile, so it is worth checking that. If it is version controlled then just git checkout Gemfile and bundle update to rebuild.
gem uninstall active-model and perfomr gem install active-model
I try to run a working rails project from OSX to Debian. I use on both systems RVM and created the same gemsets and rvmrc for the project. On Debian I installed only ruby with rvm no system installation of ruby exists.
when I jump in the project folder rvm is switching to version 1.8.7 and is using the project gemset everything looks fine.
But when I fire up a rake -T I get this error:
$ rake -T --trace
(in /home/i/project/src)
rake aborted!
uninitialized constant ActiveSupport::Dependencies::Mutex
/home/i/.rvm/gems/ruby-1.8.7-p249#project/gems/rake-0.8.7/lib/rake.rb:2503:in `const_missing'
/home/i/.rvm/gems/ruby-1.8.7-p249#project/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:55
/home/i/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
/home/i/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
/home/i/.rvm/gems/ruby-1.8.7-p249#project/gems/activesupport-2.3.5/lib/active_support.rb:56
/home/i/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
/home/i/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
/home/i/.rvm/gems/ruby-1.8.7-p249#project/gems/rails-2.3.5/lib/tasks/misc.rake:18
/home/i/.rvm/gems/ruby-1.8.7-p249#project/gems/rails-2.3.5/lib/tasks/rails.rb:4:in `load'
/home/i/.rvm/gems/ruby-1.8.7-p249#project/gems/rails-2.3.5/lib/tasks/rails.rb:4
/home/i/.rvm/gems/ruby-1.8.7-p249#project/gems/rails-2.3.5/lib/tasks/rails.rb:4:in `each'
/home/i/.rvm/gems/ruby-1.8.7-p249#project/gems/rails-2.3.5/lib/tasks/rails.rb:4
/home/i/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
/home/i/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
/home/i/ws/project/src/Rakefile:10
/home/i/.rvm/gems/ruby-1.8.7-p249#project/gems/rake-0.8.7/lib/rake.rb:2383:in `load'
/home/i/.rvm/gems/ruby-1.8.7-p249#project/gems/rake-0.8.7/lib/rake.rb:2383:in `raw_load_rakefile'
/home/i/.rvm/gems/ruby-1.8.7-p249#project/gems/rake-0.8.7/lib/rake.rb:2017:in `load_rakefile'
/ home/i/.rvm/gems/ruby-1.8.7-p249#project/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/home/i/.rvm/gems/ruby-1.8.7-p249#project/gems/rake-0.8.7/lib/rake.rb:2016:in `load_rakefile'
/home/i/.rvm/gems/ruby-1.8.7-p249#project/gems/rake-0.8.7/lib/rake.rb:2000:in `run'
/home/i/.rvm/gems/ruby-1.8.7-p249#project/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/home/i/.rvm/gems/ruby-1.8.7-p249#project/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/home/i/.rvm/gems/ruby-1.8.7-p249#project/gems/rake-0.8.7/bin/rake:31
/home/i/.rvm/gems/ruby-1.8.7-p249#project/bin/rake:19:in `load'
/home/i/.rvm/gems/ruby-1.8.7-p249#project/bin/rake:19
For me, adding require 'thread' didn't work either.
The problem was solved by downgrading rubygems to 1.4.2:
It's a compatibility issue between newer versions of rubygems (in my case, 1.8.5) and old versions of rails (in my case 2.3.5)
$ gem install rubygems-update -v='1.4.2'
$ gem uninstall rubygems-update -v='1.8.5'
$ update_rubygems
My working solution. Add the following line:
require 'thread'
At the first line of Rakefile in your rails project root. And magically all will run ;-)
I ran into this myself not too long ago. If you google for it you'll find a couple of blog and mailing list posts advising you to explicitly require "threads" in your environment.rb. However this did not work for me, but downgrading rubygems did:
sudo gem update --system 1.3.7
Some of the posts also mention upgrading to a newer version of Rails, which was not an option in our case at the moment.
you can solve it by upgrading rails
gem install rails --version 2.3.11
or downgrade gem
sudo gem update --system 1.5.3