简体   繁体   中英

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).
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).

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.

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. I did not tested it, so be carefull.

But it is better to uninstall all gems and install rails again, because of the dependencies. 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. 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.

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.

I agree with the other posters that the best way to go is clean house and just reinstall Rails. It's not that painful. A clean rvm gemset is likely the best approach.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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