Rails Error - `require': no such file to load — rubygems (LoadError)

十年热恋 提交于 2019-12-10 23:31:54

问题


I recently followed some instructions with RVM to install ruby-debug and I think it might have caused some problems. The link that I found the instructions are here: http://beginrescueend.com/support/troubleshooting/

The commands I used to install are the following:

$ rvm reinstall 1.9.3 --patch debug --force-autoconf
$ gem install ruby-debug19 -- --with-ruby-include="${MY_RUBY_HOME/rubies/src}"

Now, when I try to start the rails server, I receive the following error:

./bundler_stubs/rails:13:in `require': no such file to load -- rubygems (LoadError)
from ./bundler_stubs/rails:13

This SO question would lead me to believe that I have more than one version of rails installed: no such file to load -- rubygems (LoadError)

However, when I run which -a ruby as the selected answer suggests, I only receive /usr/bin/ruby. Any thoughts on what to do here?


回答1:


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



回答2:


Try adding [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" to your .bash_profile (if you're on a Mac) or your .bashrc (if you're in Linux). Seems like your RVM path isn't being loaded, so the wrong Ruby version is being called.



来源:https://stackoverflow.com/questions/9933217/rails-error-require-no-such-file-to-load-rubygems-loaderror

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!