Rails Error - `require': no such file to load

2019-07-20 04:34发布

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?

2条回答
干净又极端
2楼-- · 2019-07-20 05:23

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
查看更多
虎瘦雄心在
3楼-- · 2019-07-20 05:26

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.

查看更多
登录 后发表回答