Removing all installed Gems and starting over

家住魔仙堡 提交于 2019-12-02 13:57:29
michaelmichael

From the RVM support site:

RVM installs everything into ~/.rvm. To remove RVM from your system run 'rm -rf ~/.rvm'. You may have one additional config file in ~/.rvmrc and of course the RVM hook in your bash/zsh startup files.

So, just go to the command line and type rm -rf ~/.rvm

All the installed gems are in the ~/.rvm folders, so doing the above will remove the gems and installed rubies in one go.

Gems you added pre-RVM with the default ruby install can be removed by typing this at the command prompt:

for x in `gem list --no-versions`; do gem uninstall $x -a -x -I; done
Pants
gem uninstall -aIx

Uninstalls all gems without prompt.

Options

-a, --[no-]all                   Uninstall all matching versions
-I, --[no-]ignore-dependencies   Ignore dependency requirements while
                                 uninstalling
-x, --[no-]executables           Uninstall applicable executables without
                                 confirmation
Haris Krajina

For Windows and Unix copy/paste in command prompt (Ruby 1.9.x).

ruby -e "`gem list`.split(/$/).each { |line| puts `gem uninstall -Iax #{line.split(' ')[0]}` unless line.strip.empty? }"
mfittko

using RVM, you could just type...

rvm gemset empty GEMSET

where GEMSET is the gemset which you would like to empty. then...

install bundle

yum install bundler and finally

bundle install

rvm implode (see cli docs) seems to work - and it even tells you where to look at for leftovers

  1. This is work for me on Ubuntu 16.04. For me, when I was executing command rails -v it throw errors because of NameError. I have installed 3 version of rails (4.2.0, 4.2.6, 5.0.0.1). I was trying to uninstall unnecessary gem using command gem uninstall rails -v version number but I won't able to, but I find a way to solve this problem. In order to uninstall all gems, you have to loop through all entries in gem list with bash scripting. This method is very inconvenient. Thanks to Rubygems 2.1.0, you now could do it with one command.

    STEP - 1

    Firstly, please make sure you upgrade your Rubygems to 2.1.0 or newer. For this run this command (Incase you are working on an older version. You can check your gem version using this command any one of them gem -v or gem --version)

    gem update --system

    gem --version

    STEP - 2

    Run this command in you terminal

    gem uninstall --all

    Step - 3

    Install gem bundles (it is not necessary I think just for precautions) gem install bundle

    Step - 4
    Install the rails on your system using this command gem install rails -v specific version you want to install you can check the rails version on the official site rails all versions example :- I have installed rails 4.2.6 version, you install as per requirement. gem install rails -v 4.2.6

    Step - 5

    Finally check the version of installed rails framework application by Using basic command rails -v. It will echoed the current version of rails frameworks. Enjoy :)

    References

http://ruby-journal.com/how-to-uninstall-all-ruby-gems/ http://guides.rubyonrails.org/v4.1/getting_started.html

John R Perry

Step 1:

I first kept running into an error that said:

You don't have write permissions for the /usr/bin directory

To get permission, I became a root user with (this is potentially dangerous for reasons beyond my current understanding):

sudo -s

Credit

Step 2:

Then, I kept running into an error that said:

[gem] cannot be uninstalled because it is a default gem

This allowed me to uninstall everything:

for i in `gem list --no-versions`; do gem uninstall -aIx $i; done

Credit

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