Reputation: 1095
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
Upvotes: 27
Views: 64602
Reputation: 1
issue => can't find gem rails - Gem::GemNotFoundException
Solution for Mac M1 Chip
Remove Gemfile.lock
run rm Gemfile.lock
run bundle install
run pod update && pod install
Upvotes: -1
Reputation:
You can switch version between Ruby with $ rvm use --default 2.4.0
for example
But for your problem try this :
$ gem install bundler
$ gem install rails
Hope it helps !
Upvotes: 11
Reputation: 663
For me just installed bundler. This makes everything work again.
gem install bundler --no-ri --no-rdoc
Upvotes: 34
Reputation: 5716
If you use the command bundle install
to install your gems off of a GEMFILE
, it will install the gems into your default system location for gems, as outlined in the bundler docs here. After that, you can use bundlers bundle exec
command to execute a command in the context of the bundle, as outlined in the docs here. This will ensure that the version of the gem you installed using bundle install
is executed.
If you look at the homepage for bundler, which provides an overview of the docs, it states the following:
In some cases, running executables without bundle exec may work, if the executable happens to be installed in your system and does not pull in any gems that conflict with your bundle.
However, this is unreliable and is the source of considerable pain. Even if it looks like it works, it may not work in the future or on another machine.
I'm guessing that you run gem which rails
in your console, and then run bundle show rails
in your console, the default installed rails installation for your system differs from the one installed for your bundle.
You say that you are using rvm
for your ruby
and gem
management. I'm thinking you may not have properly configured it. Trying executing the rvm notes
command in your console to ensure that you have addressed all of the required/recommended steps for installation on your OS. You want to ensure that the executables for rvm
are the first things included in your path when you run echo $PATH
ideally. This will ensure that the gems installed for rvm
will be the ones executed when you try executing them without prefixing bundle exec
. If rvm notes
doesn't give you the hints necessary to accomplish that, then try carefully reviewing the docs for installation on the RVM website.
Upvotes: 23