Chances are that if you have been using Ruby for a while, your system will be full of gems and more specifically, outdated gems.
Every time you perform an update with $ gem update the default behaviour is to install a new gem version maintaining the older one.
The update command does not remove the previous version.
Removing old unused gems
To remove older gems we use the
The cleanup command removes old versions of gems from GEM_HOME that are not required to meet a dependency. If a gem is installed elsewhere in GEM_PATH the cleanup command won't delete it.
If no gems are named all gems in GEM_HOME are cleaned.
We can choose to specify a gem to remove its older versions or remove every old gem:
$ gem cleanup Cleaning up installed gems... Attempting to uninstall test-unit-3.1.7 Unable to uninstall test-unit-3.1.7: Gem::InstallError: test-unit is not installed in GEM_HOME, try: gem uninstall -i /usr/share/rubygems-integration/all test-unit Attempting to uninstall public_suffix-2.0.4 Successfully uninstalled public_suffix-2.0.4 Attempting to uninstall power_assert-0.2.7 Unable to uninstall power_assert-0.2.7: Gem::InstallError: power_assert is not installed in GEM_HOME, try: gem uninstall -i /usr/share/rubygems-integration/all power_assert Attempting to uninstall nokogiri-18.104.22.168 Successfully uninstalled nokogiri-22.214.171.124 Attempting to uninstall minitest-5.9.0 Unable to uninstall minitest-5.9.0: Gem::InstallError: minitest is not installed in GEM_HOME, try: gem uninstall -i /usr/share/rubygems-integration/all minitest Attempting to uninstall rb-inotify-0.9.7 Successfully uninstalled rb-inotify-0.9.7 Attempting to uninstall kramdown-1.12.0 Successfully uninstalled kramdown-1.12.0 Attempting to uninstall jekyll-seo-tag-2.0.0 Successfully uninstalled jekyll-seo-tag-2.0.0 Attempting to uninstall jekyll-3.3.0 Successfully uninstalled jekyll-3.3.0 Attempting to uninstall jekyll-sass-converter-1.4.0 Successfully uninstalled jekyll-sass-converter-1.4.0 Attempting to uninstall sass-3.4.22 Successfully uninstalled sass-3.4.22 Attempting to uninstall kramdown-1.13.1 Successfully uninstalled kramdown-1.13.1 Attempting to uninstall html-proofer-3.3.1 Successfully uninstalled html-proofer-3.3.1 Attempting to uninstall parallel-1.9.0 Successfully uninstalled parallel-1.9.0 Attempting to uninstall nokogiri-1.7.0 Successfully uninstalled nokogiri-1.7.0
The above command uninstall most of the gems but it can’t deal with some of them showing messages like:
Attempting to uninstall minitest-5.9.0 Unable to uninstall minitest-5.9.0: Gem::InstallError: minitest is not installed in GEM_HOME, try: gem uninstall -i /usr/share/rubygems-integration/all minitest
To uninstall them we run the command again, executing the suggested
gem uninstall ...:
sudo gem cleanup | grep -Z "gem uninstall"| while read -r line ; do echo "Uninstalling $line"; tee sudo "$line"; done
- How To Uninstall Old Versions Of Ruby Gems
- Install Jekyll CMS on Ubuntu 18.10 in 3 steps THE RIGHT WAYJanuary 20, 2019
- What Are The Supported Language Highlighters In JekyllJanuary 25, 2017
- Accessing Specific Items From Data Files In JekyllJanuary 24, 2017
- Jekyll Configuration File OptionsJune 12, 2016
- Understanding Jekyll PostsJune 12, 2016
- Jekyll basic conceptsMay 8, 2016
- Jekyll Variables and Liquid template tags cheatsheetJuly 13, 2016
- Multilingual Jekyll Without PluginsMay 8, 2017
- Host a Jekyll Website With Pretty Urls In Amazon S3 and CloudfrontApril 24, 2017
- Get A List Of Categories Based In Subfolders In JekyllMarch 3, 2017
- 5 Steps To Add Bootstrap 4 To Jekyll The Right WayFebruary 27, 2017
- Automated Deployment Of Jekyll Websites To Github Pages With A Git Push To GithubNovember 8, 2016
- How To Use Bower Scss With JekyllJune 18, 2016
- How to implement breadcrumbs on a Jekyll site with nested categoriesJune 7, 2016
- How To Handle Adsense In A Jekyll Development EnvironmentJune 6, 2016
- How To Prevent Content Displaying In A Jekyll Development EnvironmentJune 6, 2016
- Double Versus Single Quotes In RubyAugust 9, 2016
- Ruby Language OverviewAugust 9, 2016
- What Is The Difference Between Modules And Classes In RubyAugust 9, 2016
- Managing Ruby Gems Version For Each ProjectJune 10, 2016
- The Idiomatically Correct Way To Make An Instance Of A Many To One Relationship ModelAugust 18, 2016
- Simple Debugging In RailsAugust 12, 2016
- Common Steps To Start A Rails ProjectAugust 8, 2016
- Building A Hello World App In Ruby On Rails AppAugust 7, 2016
- Ruby On Rails OverviewAugust 7, 2016