Default Gems Bundled with Ruby
- Find out whether a gem is a default one
- List of the Default Gems
- Uninstall all but default gems
- Update RubyGems
- Install RubyGems
Ruby comes with some gems bundled (default gems), they are not supposed to be uninstalled, and if you do uninstall them, an error is given:
[[email protected] ~]$ gem uninstall json
ERROR: While executing gem ... (Gem::InstallError)
gem "json" cannot be uninstalled because it is a default gem
Find out whether a gem is a default one
Fortunately, RubyGems can tell whether a gem is a default one from v2.0.0 on. (See commit)
gem list -d
The above command lists the locally installed gems with detailed information.
Default gems are marked with (default)
in Installed at
lines.
For example, an user installed gem jekyll and a default gem json:
jekyll (3.1.2)
Author: Tom Preston-Werner
Homepage: https://github.com/jekyll/jekyll
License: MIT
Installed at: /home/zzz.buzz/.gem/ruby/2.3.0
A simple, blog aware, static site generator.
json (1.8.3)
Author:
Installed at (default): /usr/lib/ruby/gems/2.3.0
This json is bundled with Ruby
From RubyGems v2.6.3 (2016-04-05) on, output of gem list
(without the -d
option) marks default gems as well. (See related PR & issue)
Here is an example output:
bigdecimal (default: 1.2.8)
bundler (1.11.2)
List of the Default Gems
Here is a list of default gems, aka gems bundled with ruby.
bigdecimal
io-console
json
psych
rdoc
Uninstall all but default gems
If you ever want to uninstall all but default gems, use
gem list | cut -d' ' -f1 | grep -Ev 'bigdecimal|io-console|json|psych|rdoc' | xargs gem uninstall -aIx
Or follow this gist: gem-reset.
Reference:
Update RubyGems
The gem command allows you to interact with RubyGems.
Ruby 1.9 and newer ships with RubyGems.
To update rubygems
gem update --system
Install RubyGems
If you are using ruby with version lower than 1.9, you can install RubyGems manually.
To install rubygems, run command like
sudo apt-get install rubygems
or follow the instruction on https://rubygems.org/pages/download