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
For me just installed bundler. This makes everything work again.
gem install bundler --no-ri --no-rdoc
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.
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 !
I think below command will work
gem pristine rails
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
Related
Bundler can not find Rake.
How do I fix my Gem path so that my Ruby gems get installed in a place where Bundler can find it?
If I do:
gem env
I see:
RubyGems Environment:
- RUBYGEMS VERSION: 2.0.14
- RUBY VERSION: 2.0.0 (2015-04-13 patchlevel 645) [universal.x86_64-darwin15]
- INSTALLATION DIRECTORY: /Library/Ruby/Gems/2.0.0
- RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
- EXECUTABLE DIRECTORY: /usr/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- universal-darwin-15
- GEM PATHS:
- /Library/Ruby/Gems/2.0.0
- /Users/lkrubner/.gem/ruby/2.0.0
- /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/gems/2.0.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- "install" => "--no-ri --no-rdoc"
- "update" => "--no-ri --no-rdoc"
- REMOTE SOURCES:
- https://rubygems.org/
And Rake is there:
ls -al /Library/Ruby/Gems/2.0.0/gems
rake-0.9.6
rake-10.4.2
rake-11.2.2
rdoc-4.0.0
test-unit-2.0.0.0
But none of this matters for the current project.
I am taking over a Rails project from another developer.
Rails 4.2
Rake 11..2.2
Ruby 2.0.0
If I look in
.bundler/config
I see:
BUNDLE_PATH: vendor/cache
BUNDLE_DISABLE_SHARED_GEMS: '1'
If I use "find" I can see that I've installed several versions of Rake:
vendor/cache/rake-11.2.2.gem
vendor/cache/ruby/2.1.0/gems/rake-10.5.0/
vendor/cache/ruby/2.1.0/gems/rake-11.2.2
vendor/cache/ruby/2.1.0/gems/rake-10.4.2
But most of these are going to a ruby 2.1 folder, instead of 2.0.
But if I try:
bundle exec rake db:setup
I get:
Could not find rake-11.2.2 in any of the sources
I've tried "bundle install".
I've tried deleting Gemfile.lock.
I've tried to avoid using "bundle exec".
I can't get anything to work.
I just need to get the system to use one path. The versions are not very important.
How do I get everything to agree on one path?
If I run "bundle install" then in the output I see "Using rake 11.2.2". So the "bundle" command sees rake when Bundler is doing the "install" task, but not when it is doing the "exec" task.
By the way:
which rake
/usr/local/bin/rake
This is hard-coded to the 2.0 version of Ruby:
#!/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
#
# This file was generated by RubyGems.
#
# The application 'rake' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'rubygems'
version = ">= 0"
if ARGV.first
str = ARGV.first
str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
if str =~ /\A_(.*)_\z/
version = $1
ARGV.shift
end
end
gem 'rake', version
load Gem.bin_path('rake', 'rake', version)
[[ UPDATE ]]
[[ UPDATE ]]
I deleted:
.bashrc
.bash_profile
.zshrc
and I ran:
chsh -s /bin/bash
I am on a Mac. This should have changed my shell from zsh to bash.
I then started over in a terminal window, to be sure all changes were loaded.
Now, if I run "bundle install" the gems seem to install into vendor/cache/ but I get this error:
Installing paperclip 5.0.0
Gem::InstallError: paperclip requires Ruby version >= 2.1.0.
So I run:
rbenv install 2.1.0
and I run "bundle install" again, and I get the same error.
The ruby version is:
ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
Any advice?
If I run:
gem env
I see:
- GEM PATHS:
- /Users/lkrubner/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0
- /Users/lkrubner/.gem/ruby/2.3.0
I guess this is fixed now. Deleting all of .bashrc and .bash_profile and .zshrc and changing the default shell back to bash and deleting all mentions of rvm and reinstalling rbenv and reinstalling "gem" and then "Bundler" seemed to fix at least some of the problems with paths. And I fixed the issue with Paperclip by doing "gem install paperclip" which I guess installed paperclip globally, but at least it works on my local Mac. Very fragile, but things are working.
I wish I could use Clojure for this project. Every time I tangle with Ruby I end up wrestling with this endless maze of path problems. With Clojure, I am protected by Leiningen, which seems to figure this stuff out with pure magic.
I just ran gem update bundler to fix this issue.
I made the switch from RVM to rbenv following this guideline and now I can use bundler and run pure ruby, but when I run bin/rails s, bin/rails g model ModelName, or rails g model ModelName I get the below error:
Warning: Running `gem pristine --all` to regenerate your installed gemspecs (and deleting then reinstalling your bundle if you use bundle --path) will improve the startup performance of Spring.
/Users/home/Development/blogger/vendor/bundle/gems/json-1.8.3/lib/json/ext/parser.bundle: [BUG] Segmentation fault at 0x00000000000418
ruby 2.1.4p265 (2014-10-27 revision 48166) [x86_64-darwin15.0]
There is also a massive crash report following this, but I have chose not to include it because it is longer than the allowed StackOverflow post length, and I don't think it says anything of value.
I have tried the same thing with ruby 2.1.2 and got the same result. I have also done gem install rubygems-update which runs successfully and gem pristine --all which gets this error:
ERROR: While executing gem ... (Gem::Exception)
Failed to find gems ["==all"] >= 0
Here is the result of gem env
RubyGems Environment:
- RUBYGEMS VERSION: 2.2.2
- RUBY VERSION: 2.1.4 (2014-10-27 patchlevel 265) [x86_64-darwin15.0]
- INSTALLATION DIRECTORY: /Users/home/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0
- RUBY EXECUTABLE: /Users/home/.rbenv/versions/2.1.4/bin/ruby
- EXECUTABLE DIRECTORY: /Users/home/.rbenv/versions/2.1.4/bin
- SPEC CACHE DIRECTORY: /Users/home/.gem/specs
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-15
- GEM PATHS:
- /Users/home/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0
- /Users/home/.gem/ruby/2.1.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/home/.rbenv/versions/2.1.4/bin
- /usr/local/Cellar/rbenv/0.4.0/libexec
- /Users/home/.rbenv/shims
- /Users/home/.rbenv/bin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
Under GEM PATHS, why is the path going into 2.1.0? This is my old version of ruby which I'm pretty sure is not even on my machine any more. It is not listed under rbenv versions. Is this the problem? How do I change the gem path and what do I change it to?
I set the $PATH in my .bash_profile
[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile
export PATH="$HOME/.rbenv/bin:$PATH"
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
My .profile is empty, and echo $PATH results in:/Users/home/.rbenv/shims:/Users/home/.rbenv/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
which ruby results in /Users/home/.rbenv/shims/ruby
Another issue is if I try to use the bundle command in my home directory I get Could not locate Gemfile or .bundle/ directory
even though bundler is included in my gem list.
I have tried uninstalling and reinstalling ruby at least three times, and I get the same errors every time. Once again I believe the problem is with my GEM PATH but I don't have enough experience to know how to fix it. Thank you.
Turns out the solution was just to delete my rails project and start a new one. I also uninstalled and reinstalled my gems, and did rbenv rehash before creating a new project. I figured I should post an answer and not just delete the question, because I did not not see delete and remake the rails app in any other responses to the few questions about this error out there.
#usernm ... I think you should have a GEMFILE in your directory . Problem is pretty confusing . So just try to add ruby 'version' on the top line. I hope this is one option to look at . Well example would be:
ruby '2.1.4'
I have installed ruby on rails following the 310 railcasts on railcast.com. Now I was able to run and create a new rails and run it using rail s. The issue comes as soon has I close the terminal and restarted it i get the following error
The program 'rails' is currently not installed. You can install it by typing:
sudo apt-get install rails
Here ruby version
ruby -v
ruby 1.9.3p286 (2012-10-12 revision 37165) [i686-linux]
if i do rails -v i get following
The program 'rails' is currently not installed. You can install it by typing:
sudo apt-get install rails
whereis rails
rails:
gem environment gives me this
- RUBYGEMS VERSION: 1.8.24
- RUBY VERSION: 1.9.3 (2012-10-12 patchlevel 286) [i686-linux]
- INSTALLATION DIRECTORY: /home/john/.rvm/gems/ruby-1.9.3-p286
- RUBY EXECUTABLE: /home/john/.rvm/rubies/ruby-1.9.3-p286/bin/ruby
- EXECUTABLE DIRECTORY: /home/john/.rvm/gems/ruby-1.9.3-p286/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-linux
- GEM PATHS:
- /home/john/.rvm/gems/ruby-1.9.3-p286
- /home/john/.rvm/gems/ruby-1.9.3-p286#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
I also believe the answer his the path and seem to the same has this questions Installed Rails but the rails command says it's not installed. But i do not know how to place the path. Any help would be appreciated
try to type rvm -v, if an error occurs, you have a problem with your rvm installation, if so try to source your shell configuration file ie if you are using bash on a mac : "source ~/.profile"
I am using Mac OSX, and in my .bashrc which is under my home directory.
There is a line :
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
By the way, you should tell the rvm to use 1.9.3 of ruby by the command rvm use 1.9.3
Your problem could be the thing that rvm switches between your ruby versions and when you restart the terminal it is not the old ruby version that you were using before exiting. So one solution can be. You create ".rvmrc" file in your rails application folder and inside you put just one line:
rvm use 1.x.x
where 1.x.x is the ruby version that you will use. Once you have gem rails in this version it will always work for you. This file simply tells which ruby shell be used when you work in your aplication direcotry
#user1022209 your solution will also work if the problem is with the ruby version but the point is that you always have to set ruby when your enter your folder and this can somethimes be anoying. I think that the best way to set default ruby version is using .rvmrc file.
3 lines of writing:
vim .rvmrc #creates new file, after which you have to press "i" for Insert mode
rvm use 1.x.x #contains only this line inside after which you press "ESC" and you type
:wq or :wq!
Finally press Enter and you are
done forever :)
Hope it will solve your problem
gem install rails
Do not sudo or apt-get when installing Rails with an installation of Ruby that was compiled from source. You may need to remove the Rails package first since you have already attempted to install it using the apt-get package manager.
apt-get remove --purge rails
apt-get clean
After installing rvm, updating .gmrc file, updating rubygems and running gem install rails -v ">=3.1.0rc", I now seem to have a complete mess:
$ rails -v
/usr/local/lib/site_ruby/1.8/rubygems/dependency.rb:247:in `to_specs': Could not find rails (>= 0) amongst [] (Gem::LoadError)
from /usr/local/lib/site_ruby/1.8/rubygems/dependency.rb:256:in `to_spec'
from /usr/local/lib/site_ruby/1.8/rubygems.rb:1182:in `gem'
from /var/lib/gems/1.8/bin/rails:18
myhome#myhome-mini:~$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.6.2
- RUBY VERSION: 1.9.2 (2011-02-18 patchlevel 180) [i686-linux]
- INSTALLATION DIRECTORY: /home/myhome/gems
- RUBY EXECUTABLE: /home/myhome/.rvm/rubies/ruby-1.9.2-p180/bin/ruby
- EXECUTABLE DIRECTORY: /home/myhome/gems/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-linux
- GEM PATHS:
- /home/myhome/gems
- /usr/lib/ruby/gems/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- "gemhome" => "/home/myhome/gems"
- "gempath" => ["/home/myhome/gems", "/usr/lib/ruby/gems/1.8"]
- REMOTE SOURCES:
- http://rubygems.org/
I've had a similiar problem. Not sure if that helps you, but you might try to install gems with rvmsudo gem install [gemname] instead of just doing gem install [gemname] or sudo gem install [gemname].
I try to explain this a bit because of the upvotes:
This basically is a path issue. If you set up gems via gem install, they mostly likely will be in another directory (e.g. /usr/local/) compared to gems set up via bundler (where you can override it with --path). Using sudo may also set them up into another directory since sudo starts a subshell which has a different environment then. This is why you have rvmsudo.
If you want to see the differences, compare $PATH, $GEM_HOME, $GEM_PATH and $BUNDLE_PATH when echoing directly, with sudo and with rvmsudo.
I had to sudo gem install bundler to make it work again.
I got a problem similar to this, there may be a compatible problem of rvm.
I fixed by updating rvm to latest version:
curl -L https://get.rvm.io | bash -s stable --ruby
Then you should reload rvm or just open new terminal window.
Then I reinstalled the bundler 'gem install bundler' and ran 'bundle install' as normal
rvm rubygems current
did the trick for me.
remove ruby first
then
sudo apt-get install build-essential libssl-dev libreadline5 libreadline5-dev zlib1g zlib1g-dev
to install all needed lib
then you could install ruby and rails
rvm install 1.9.3
rvm --default use 1.9.3
rvm gem install rails
I had pretty much the same message when trying to generate a controller after installing IntelliJ IDEA and the associated Plugin for Rail Dev. From my app directory I just executed bundle install and was then able to generate controllers again.
I know this is a really old question but I just recently decided to move to RVM on a server I had setup a while ago and was having this same problem where gems were being installed in the wrong place and it was just messing everything up.
After a few hours of crawling through SO, I finally figured out that in my .gemrc file in my root folder, I had previously setup the gemhome: and gempath: variables and they were messing with the whole system.
After removing these lines, all my gems were working property.
Just thought I would post my answer in case someone was in the same position.
I just set up a fresh Mac OS X 10.5 environment for Rails. I installed Ruby 1.8.7, renamed the packaged version of Ruby in /usr/bin, and updated the packaged version of RubyGems from 1.0.1 to 1.3.4. Here's the flow:
$ rails -v
Rails 2.3.4
$ gem -v
1.3.4
$ which gem
/usr/bin/gem
$ whereis gem
/usr/bin/gem
$ which rails
/usr/bin/rails
$ whereis rails
/usr/bin/rails
$ /usr/bin/gem -v
1.3.4
$ /usr/bin/rails -v
Rails 2.3.4
$ rails testapp
...
...
testapp $ script/console
Rails requires RubyGems >= 1.3.2. Please install RubyGems and try again: http://rubygems.rubyforge.org
The thing is I've updated RubyGems and didn't install another version of it. gem list rails displays two versions of Rails (2.3.4 and 1.2.6), though.
How can I fix this so I can use Rails?
One suggestion is to not change the system versions, instead install in /usr/local or use MacPorts.
The guys over at HiveLogic cover Rails, as well as MySQL and other development tools.
Using these techniques i've successfully installed rails into /usr/local Then it's a simple matter of adjusting the path settings in your terminal shell via (export PATH=/usr/local/bin:$PATH)
Have you tried:
sudo gem update --system
That should get you the latest version of rubygems, which is something like 1.3.5.
Rails will tell you the version of RubyGems you have if it's loading an incompatible version. The error message you're getting means it can't load RubyGems at all, so I'm thinking it's a path issue.
What do you get from $: in irb? Is there a rubygems.rb in any of those locations?
Make your life easier and use Macports instead of trying updatre and repalce the core system libraries. :-)
I second that emotion and, if I could, would up-vote the answer from prodigitalson -- MacPorts is your friend... Recommend you run specifically:
$ sudo port install rubygem
$ gem install rails
Key is making your which ruby and your rubygems which gem in synch. and in harmony...both should be in /opt/local/bin/
So Ruby on Rails 2.3.8 working on my MacOS 10.5.8 - and the gem environment no longer lies after the MacPorts install and reports the correct version, 1.8.7.
$ gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.4
- RUBY VERSION: 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin9]
- INSTALLATION DIRECTORY: /opt/local/lib/ruby/gems/1.8
- RUBY EXECUTABLE: /opt/local/bin/ruby
- EXECUTABLE DIRECTORY: /opt/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-darwin-9
- GEM PATHS:
- /opt/local/lib/ruby/gems/1.8
- /Users/saleram/.gem/ruby/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://gems.rubyforge.org/
Though the question is rather old, and comments stale, current searchers may find that these instructions:
Installing Rails on Mac OS X 10.6 (SL)
work fine for installing Ruby / Rails 3 on new OS X 10.6 installs, GIVEN that you install a recent version of RubyGems:
http://rubyforge.org/frs/?group_id=126
... particularly, do this in place of typing
sudo update_rubygems
in the first of my links
Had the same problem, here's what I did that solved it:
First, update gem
gem update --system
Navigate to the primary path in gem env, in my case /Library/Ruby/Gems/1.8
cd /Library/Ruby/Gems/1.8
Then, navigate to the gem itself:
cd gems/rubygems-update-1.3.5
Run setup.rb
sudo setup.rb
And that's it.
Have you considered BitNami Rubystack as an alternative? It is a free installer that provides a out-of-the-box Rails environment with MySQL (and a bunch of preconfigured, commonly used third-party libraries and apps). Please note I am one of the contributors to RubyStack, so I am biased. It is free and distributed under the Apache 2.0 open source license