LoginSignup
196
179

More than 3 years have passed since last update.

gem をクリーンにする。

Last updated at Posted at 2014-08-06

gem help uninstall を見ていた。
インストールされた gem をワンコマンドでアンインストールする方法を 1 つ思いついた。
(もっとよいオプション指定の組み合わせがあるかもしれないが、これで一応目的は達成できる)

$ gem uninstall -I -a -x --user-install --force

上の実行後 gem list すると、こうなる。

$ gem list
*** LOCAL GEMS ***

bigdecimal (1.2.4)
io-console (0.4.2)
json (1.8.1)
minitest (4.7.5)
psych (2.0.5)
rake (10.1.0)
rdoc (4.1.0)
test-unit (2.1.2.0)

ここからは 次のようにして、 rails 用の gem 環境を再構築する。

$ gem install bundler
$ rm Gemfile.lock
$ bundle install

必要に応じて次も実行するとよい。

$ gem update --system
$ gem update
$ gem cleanup

追記: 2017-06-25
こんなスクリプトを見つけた。
- https://gist.github.com/IanVaughan/2902499 Uninstall all rbenv gems

追記: 2021-05-05
こんな記事をみつけた。
- https://stackoverflow.com/questions/57306611/ Rails: How can I remove default version of bundler?

196
179
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
196
179