no such file to load — rubygems (LoadError)

2019-01-03 06:14发布

I recently installed rails in fedora 12. I'm new to linux as well. Everything works fine on Windows 7. But I'm facing lot of problems in linux. Help please!

I've installed all the essentials to my knowledge to get the basic script/server up and running. I have this error from boot.rb popping up when I try script/server. Some of the details I'd like to give here:

The directories where rails, ruby and gem are installed,

[vineeth@localhost my_app]$ which ruby
/usr/local/bin/ruby

[vineeth@localhost my_app]$ which rails
/usr/bin/rails

[vineeth@localhost my_app]$ which gem
/usr/bin/gem

And when I run the script/server, this is the error.

[vineeth@localhost my_app]$ script/server
./script/../config/boot.rb:9:in `require': no such file to load -- rubygems (LoadError)
 from ./script/../config/boot.rb:9
 from script/server:2:in `require'
 from script/server:2

And the PATH file looks like this

[vineeth@localhost my_app]$ cat ~/.bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
 . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH="/usr/local/bin:/usr/local/sbin:/usr/bin/ruby:$PATH"

I suppose it is something to do with the PATH file. Let me know what I need to change here. If there are other changes I should make, please let me know.

14条回答
我命由我不由天
2楼-- · 2019-01-03 06:33

I had a similar problem on Ubuntu due to having multiple copies of ruby installed. (1.8 and 1.9.1) Unfortunately I need both of them. The solution is to use:

$ sudo update-alternatives --config ruby
There are 2 choices for the alternative ruby (providing /usr/bin/ruby).

  Selection    Path                Priority   Status
------------------------------------------------------------
* 0            /usr/bin/ruby1.8     50        auto mode
  1            /usr/bin/ruby1.8     50        manual mode
  2            /usr/bin/ruby1.9.1   10        manual mode

Press enter to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/bin/ruby1.9.1 to provide /usr/bin/ruby (ruby) in manual mode.

After doing that bundle install succeeded.

查看更多
smile是对你的礼貌
3楼-- · 2019-01-03 06:34

Try starting the project with:

./script/server

instead of script/server if you are using ruby 1.9.2 (from strange inability to require config/boot after upgrading to ruby 1.9.2)

查看更多
倾城 Initia
4楼-- · 2019-01-03 06:38

I also had this issue. My solution is remove file Gemfile.lock, and install gems again: bundle install

查看更多
成全新的幸福
5楼-- · 2019-01-03 06:43

If you have several ruby installed, it might be sufficient just to remove one of them, on MacosX with extra ports install, remove the ports ruby installation with:

sudo port -f uninstall ruby
查看更多
趁早两清
6楼-- · 2019-01-03 06:44

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:

  1. Remove ruby version installed via ports (yum or whatever package manager).
  2. Remove ruby version that came with OS (hardcore rm by hand).
  3. Install ruby version from ports with different prefix (/usr instead of /usr/local)
  4. Reinstall rubygems
查看更多
劳资没心,怎么记你
7楼-- · 2019-01-03 06:50

I would just like to add that in my case rubygems wasn't installed.

Running sudo apt-get install rubygems solved the issue!

查看更多
登录 后发表回答