no such file to load -- rubygems (LoadError)
I have a hunch that you have two ruby versions. Please paste the output of following command:
$ which -a ruby
updated regarding to the comment:
Nuke one version and leave only one. I had same problem with two versions looking at different locations for gems. Had me going crazy for few weeks. Put up a bounty here at SO got me same answer I'm giving to you.
All I did was nuke one installation of ruby and left the one managable via ports. I'd suggest doing this:
- Remove ruby version installed via ports (yum or whatever package manager).
- Remove ruby version that came with OS (hardcore rm by hand).
- Install ruby version from ports with different prefix (
/usr
instead of/usr/local
) - Reinstall
rubygems
cannot load such file -- rubygems.rb (LoadError)
It seems that the rspec binary was only installed for your previous ruby version. Therefore it is found, but not guaranteed to work.
I'd recommend to use something like rvm
(https://rvm.io/) or rbenv
(https://github.com/rbenv/rbenv). Both of them can easily handle different ruby versions while maintaining dependencies (e.g. different load paths, different gem versions, etc.). I'd even use rvm
if there is only one single ruby version installed on a system.
/usr/bin/gem:8:in `require': no such file to load -- rubygems
You will have to use apt-get to uninstall, then reinstall ruby. You say you have installed two different versions of ruby (1.8.x, and 1.9.x), so both will have to go.
sudo apt-get uninstall ruby1.8
sudo apt-get uninstall ruby
sudo apt-get purge ruby1.8
sudo apt-get purge ruby
sudo apt-get autoremove --purge
Do not worry if the purge and autoremove commands tell you nothing was done.
Now do:
sudo apt-get install ruby
This will get you ruby version 1.9.3 --that's the latest on my box using apt-get. Once that is done, then do:
gem list --local
and you should get a short list.
To get rails do:
sudo apt-get install rails
Rails Error - `require': no such file to load -- rubygems (LoadError)
You need to explicitly activate the installed Ruby version before using it.
rvm use 1.9.3
which ruby
should now point to the new version.
You can set a default Ruby version with
rvm --default 1.9.3
Another option is to have that Ruby version activated in your project folder. This can be achieved by placing a .rvmrc file there. E.g.
echo "rvm use 1.9.3" >> /project/folder/.rvmrc
Now you will need to install all your gems (including rubygems, rails etc.) for that particular (rvm) Ruby version, e.g.
gem install ruby-debug19
Related Topics
What Does the (Unary) * Operator Do in This Ruby Code
Ruby: String Comparison Issues
How to Determine If One Array Contains All Elements of Another Array
How to Get a Single Character Without Pressing Enter
Actioncontroller::Unknownformat
How to Remove Emoji from String
Get List of a Class' Instance Methods
Query , Can Not Select Column Count
Cannot Load Such File - Zlib Even After Using Rvm Pkg Install Zlib
How to Change Default Timezone For Active Record in Rails
Ruby MySQL2 Gem Installation on Windows 7
String Concatenation Vs. Interpolation in Ruby
Rescue_From Actioncontroller::Routingerror in Rails 4