'can't find gem rails - Gem::GemNotFoundException

Using ubuntu 10.04, rvm. At first, I've installed ruby 1.9.2 with rvm, gem rails and generated some new project and started it successfully. Everything was working fine. But after changing to another project, executing bundle install command (output looks OK) and starting rails server - error occurs:

rails s

/home/jacek/.rvm/rubies/ruby-1.9.2-p318/lib/ruby/site_ruby/1.9.1/rubygems.rb:316:in `bin_path': can't find gem rails ([">= 0"]) with executable rails (Gem::GemNotFoundException)
from /home/jacek/.rvm/gems/ruby-1.9.2-p318/bin/rails:19:in `<main>'

gem list rails

*** LOCAL GEMS ***
rails (3.2.2)

gem env

RubyGems Environment:
  - RUBYGEMS VERSION: 1.8.18
  - RUBY VERSION: 1.9.2 (2012-02-14 patchlevel 318) [i686-linux]
  - INSTALLATION DIRECTORY: /home/jacek/.rvm/gems/ruby-1.9.2-p318
  - RUBY EXECUTABLE: /home/jacek/.rvm/rubies/ruby-1.9.2-p318/bin/ruby
  - EXECUTABLE DIRECTORY: /home/jacek/.rvm/gems/ruby-1.9.2-p318/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-linux
  - GEM PATHS:
     - /home/jacek/.rvm/gems/ruby-1.9.2-p318
     - /home/jacek/.rvm/gems/ruby-1.9.2-p318@global
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/

My Path (includes EXECUTABLE DIRECTORY: /home/jacek/.rvm/gems/ruby-1.9.2-p318/bin )

/home/jacek/.rvm/gems/ruby-1.9.2-p318/bin:/home/jacek/.rvm/gems/ruby-1.9.2-p318@global/bin:/home/jacek/.rvm/rubies/ruby-1.9.2-p318/bin:/home/jacek/.rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

I would be grateful for any help



Solution 1:[1]

For me just installed bundler. This makes everything work again.

gem install bundler --no-ri --no-rdoc

Solution 2:[2]

You can switch version between Ruby with $ rvm use --default 2.4.0 for example

But for your problem try this :

  1. $ gem install bundler

  2. $ gem install rails

Hope it helps !

Solution 3:[3]

I think below command will work

gem pristine rails

Solution 4:[4]

issue => can't find gem rails - Gem::GemNotFoundException

Solution for Mac M1 Chip

  1. Remove Gemfile.lock

    run rm Gemfile.lock

  2. run bundle install

  3. run pod update && pod install

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Gonzalo Aguilar Delgado
Solution 2
Solution 3 Jagdish
Solution 4 Harsh