简体   繁体   English

如何使用RVM卸载除rails之外的gemset中的所有gem?

[英]How to use RVM to uninstall all gem inside a gemset except rails?

如何卸载gemset期望轨道内的所有gem?

Doing this would be a bad idea. 这样做将不是一个好主意。
Rails depends on several gems (it is, in fact, several gems itself). Rails依赖于几个宝石(实际上,它本身就是几个宝石)。
Therefore, you're going to remove rails' dependencies and won't be able to run it anymore (and as rubygems is smart, it'll remove rails at the same time than the dependencies). 因此,您将要删除Rails的依赖项,并且将无法再运行它(并且rubygems很聪明,它将在删除依赖项的同时删除Rails)。

The best way would therefore to remove the gemset. 因此,最好的方法是删除宝石。

rvm gemset delete <your gemset>

Then to recreate it and install rails 然后重新创建它并安装导轨

rvm gemset create <your gemset>
gem install rails

Maybe you can use something like this. 也许您可以使用类似这样的东西。 Use your gemset rvm use 1.9.2@gemset Then enter this code. 使用您的gemset rvm use 1.9.2@gemset然后输入此代码。

gem list | grep -v rails | awk '{print $1}' | xargs echo

It will print every gem installed. 它将打印所有安装的宝石。 If it is ok then you can replace 'echo' with the gem uninstall comment. 如果还可以,则可以用gem卸载注释替换“ echo”。 I did not tested it, so be carefull. 我没有测试过,所以要小心。

But it is better to uninstall all gems and install rails again, because of the dependencies. 但是,由于存在依赖性,最好卸载所有gems并重新安装rails。 With this code, the dependencies are broken. 使用此代码,依赖关系被破坏。

If you go into Gemfile.lock you can get a definitive list of which gems the Rails system relies on. 如果您进入Gemfile.lock,则可以获取Rails系统所依赖的宝石的最终列表。 You have to be very careful doing this but you should be able to remove the ones that aren't nested under the main Rails gem. 您必须非常小心地执行此操作,但是您应该能够删除那些不嵌套在主要Rails gem下的对象。

Please note two things: going this direction may result in significant things being missing. 请注意两件事:朝这个方向前进可能会导致重大事情丢失。 I use 3.0.3 so I don't know if my response carries over to 3.1 or even things before 3.0. 我使用3.0.3,所以我不知道我的响应是否会延续到3.1甚至3.0之前的版本。

I agree with the other posters that the best way to go is clean house and just reinstall Rails. 我同意其他海报,最好的方法是打扫房间,然后重新安装Rails。 It's not that painful. 并不是那么痛苦。 A clean rvm gemset is likely the best approach. 干净的rvm gemset可能是最好的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM