reinstall every gem for each ruby version?

感情迁移 提交于 2019-12-03 09:19:06

问题


I just installed Ruby 2.0.0 using rbenv and set it to the global ruby version for my system. Since 2.0 is compatible with 1.9.3, I tried to start up a Rails project with it, but got the following error. I did rbenv rehash after installing 2.0

The `rails' command exists in these Ruby versions:
  1.9.3-p327

Does this mean that every gem I installed on my system with 1.9.3 has to be reinstalled if I wish to use it with 2.0?


回答1:


Yes. Rbenv (and RVM) have separate "gem home" directories for each installed version of Ruby. There may be ways to symlink certain directories to get them to share, but this will likely lead to problems, particularly with gems that include native C extensions, which may or may not compile and run cleanly in multiple versions.

If you have a Gemfile, easiest thing is to just bundle install again for Ruby 2.0, giving you duplicate copies of many gems and Ruby-2.0 compiled versions of any native gems.




回答2:


As seen here:

You need to reinstall bundler for each version of Ruby you use. See Ruby versions where you have it installed:

rbenv whence bundle

See your current version:

rbenv version

Install bundler for that version, if missing:

gem install bundler



回答3:


Another solution to this is to copy (or reinstall) the gems from your previous version to the newly installed version. How to do that is answered in detail in this question, which has two scripts -- one to install from local cache, one to reinstall from the internet (mine).



来源:https://stackoverflow.com/questions/15327319/reinstall-every-gem-for-each-ruby-version

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