用Rbenv更新ruby版本,但gem显然没有更新 [英] Updating ruby version with Rbenv but gems apparently not updated
问题描述
我刚刚使用 rbenv
从版本 1.9.3-p448 更新为 1.9.3-p484 在Ubuntu生产服务器上。更新似乎是成功的。 Ruby版本显示我刚刚更新的最新版本。 然而,当我查看目录下的这个版本 1.9.3-p484 的宝石时:
.rbenv / versions / 1.9.3-p484 / lib / ruby / gems / 1.9.1 / gems
。
我只找到那个目录中几个宝石。当我查看以前版本的目录时,那里有一大堆宝石。我是否错过了ruby更新过程中的某个步骤?
现在我正在使用新的ruby版本,是否需要重新安装此版本的所有gem?如果是的话,会不会运行 bundle install
来完成这项工作?
是,您需要为活动ruby版本运行 bundle install
。请确保应用程序的活动ruby版本和gemset设置正确。 ( Linux / MacOS ):
$ cat .ruby-version
ruby-1.9.3-p484
$ cat .ruby-gemset
your_app_name
在gem更新之前,请重新插入您的应用程序/ gem文件夹。
$ cd ..
$ cd your_app_name
我还有一个附注。如果您的应用程序是 gem ,则没有理由添加 .ruby-version
和 .ruby-gemset
文件添加到 存储库中,只需将它们添加到 .gitignore
文件中即可。当您的应用程序是一个 rails 应用程序时,将这些文件与 Gemfile.lock
一起添加到 git ,因为你修正了ruby版本,并且为web应用程序设置了gem,这些都是独一无二的。还有一些像 heroku 这样的云服务需要将 Gemfile.lock
添加到 回购库中。 b $ b
I have just updated Ruby from version 1.9.3-p448 to 1.9.3-p484 using rbenv
on a Ubuntu Production server. The updating seems to be successful. Ruby version shows the latest version I just updated.
However when I look at the gems for this version 1.9.3-p484 under the directory:
.rbenv/versions/1.9.3-p484/lib/ruby/gems/1.9.1/gems
.
I only find a few gems in that directory. And when I looked at the directory of the previous version, there is a whole bunch of gems in there. Did I miss a step somewhere in the ruby update process?
Now that I am using the new ruby version, do I need to reinstall all the gems for this version? If so, will running bundle install
does the job?
Yes, you need to run bundle install
for the active ruby version. Please make sure that the active ruby version, and the gemset for the application are set properly. Just do the following (in Linux/MacOS):
$ cat .ruby-version
ruby-1.9.3-p484
$ cat .ruby-gemset
your_app_name
And before gem update, please re-neter into the your application/gem folder.
$ cd ..
$ cd your_app_name
I have an additional note. If your application is a gem, there is no reason to add the .ruby-version
, and .ruby-gemset
files into the git repository, just add them into .gitignore
file. When your application is a rails app, adding the files along with the Gemfile.lock
into git repo has make sense, because you fix ruby version, and gem set for web-application to one that are those, which uniquely will work. Also some cloud services like heroku requires Gemfile.lock
to be added into a git repo.
这篇关于用Rbenv更新ruby版本,但gem显然没有更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!