two versions of ruby installed, how to fix that?

青春壹個敷衍的年華 提交于 2021-02-11 08:10:37

问题


I found out that I have two versions of ruby installed on OSX 10.6.2 how can I uninstall the older version and make sure that everything is fine, the path point to the other one?

bash-3.2$  /usr/local/bin/ruby -v 
ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin9.7.0]

bash-3.2$ /usr/bin/ruby -v
ruby 1.8.7 (2008-08-11 patchlevel 72) [universal-darwin10.0]


bash-3.2$ $PATH
bash: /usr/local/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/libexec: No such file or directory

bash-3.2$ whereis ruby
/usr/bin/ruby

回答1:


The version of Ruby in /usr/bin is the system-installed version, and should be left in place.

The version you have in /usr/local/bin can probably be safely removed. Was it installed using a package manager (ie, MacPorts, Homebrew?). If so, remove it using your package manager.

If you compiled and installed it manually, you can try removing the binaries from /usr/local/bin, but you may still have gems and other files lying around (most likely in /usr/local/lib/ruby.)

Alternatively, you can leave them in place and manage your Ruby environment through RVM: http://rvm.beginrescueend.com/




回答2:


You don't have to uninstall the the older version. ALternatively you can use alias like and save it in the ~/.profile file of your the OSX directory.

alias ruby="<path_to_ruby_version_that_you_want_to_use>"

That should call ruby from the proper directory that you want.

Alternatively you can use symlink like this post suggests here How to uninstall Ruby from /usr/local?. Hope it helps!




回答3:


You should locate the Ruby you're actively using with which ruby, not whereis ruby. My whereis ruby outputs /usr/bin/ruby, but which ruby gives /Users/BinaryMuse/.rvm/rubies/ruby-1.9.2-p136/bin/ruby, because I manage my Ruby versions with RVM. Since /usr/local/bin is first in your PATH, which ruby will probably return /usr/local/bin/ruby, which appears to be what you want. A quick ruby -v can confirm this too.

All that being said, I second the recommendation of using RVM to manage version of Ruby and also what RVM calls gemsets, allowing you to have "buckets" of gems that you can use one at a time. It's quite a powerful and extremely useful tool.



来源:https://stackoverflow.com/questions/5213878/two-versions-of-ruby-installed-how-to-fix-that

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