RVM doesn't set correct gem path

时光总嘲笑我的痴心妄想 提交于 2019-11-26 23:03:58

问题


On a clean OS X Snow Leopard install, I have a problem with RVM: It sets the ruby path correctly but doesn't set the gem path. When I start a rails server, it mixes versions which doesn't work.

To illustrate:

$ rvm system
$ which ruby
/usr/bin/ruby
$ which rails
/usr/bin/rails
$ rvm use 1.9.2-head
Using /Users/m/.rvm/gems/ruby-1.9.2-head
$ rvm gem list

LOCAL GEMS
[...]
rails (3.0.7)
[...]

$ which ruby
/Users/m/.rvm/rubies/ruby-1.9.2-head/bin/ruby
$ which rails
/usr/bin/rails

Any ideas what might be wrong?

Some additional info:

$ echo $GEM_PATH
/Users/m/.rvm/gems/ruby-1.9.2-p180:/Users/m/.rvm/gems/ruby-1.9.2-p180@global

$ echo $PATH
/Users/m/.rvm/gems/ruby-1.9.2-p180/bin:/Users/m/.rvm/gems/ruby-1.9.2p180@global/bin:/Users/m/.rvm/rubies/ruby-1.9.2p180/bin:/Users/m/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin


回答1:


So after 1 1/2 days of torture, reading through at least 50 post, and installing rvm / ruby / rails at least 15 different times, I am finally able to use Rails in my RVM install. This was the last series of events that I did after installing RVM and Ruby on last and then it worked. I hope this helps others...

Removed from .gemrc (back up your file if you do this)...

  • gemhome: /home/[user]/ruby/gems
  • gempath: []
  • --remote

THEN rvm use 1.9.3 --default

THEN gem install rails

It seems the trick for was:

  1. change the .gemrc file
  2. Don't create and use a gemset (rvm use 1.9.3@rails3) before installing rails.



回答2:


Make sure you're always 'using' your ruby version (ugh rvm can be so annoying).

rvm use 1.9.3 --default

Also what does your .gemrc look like? I had to take out --user from mine.




回答3:


make sure you do a gem install rails after setting the default Ruby version, e.g.

  rvm use 1.9.2-head
  gem install rails

and then check again 'which rails'



来源:https://stackoverflow.com/questions/5840366/rvm-doesnt-set-correct-gem-path

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