Since we're using ruby you could do something like this I guess:

bundle list | ruby -e 'ARGF.readlines[1..-1].each {|l| g = l.split(" ");  puts "Removing #{g[1]}"; `gem uninstall --force #{g[1]} -v #{g[2].gsub(/\(|\)/, "")}`; }'

NOTE: Only lightly tested.

Answer from rainkinz on Stack Overflow
🌐
Bundler
bundler.io › v2.0 › man › bundle-clean.1.html
Bundler: bundle clean
bundle-clean - Cleans up unused gems in your bundler directory ... This command will remove all unused gems in your bundler directory.
Discussions

bundle clean --force removes gems bundled with Ruby
If I run bundle clean --force (in an effort to remove old gem version when the bundle needs to be updated), bundler will removed "bundled gems" - gems that are packaged with ruby. (see ht... More on github.com
🌐 github.com
9
August 3, 2018
ruby on rails 3 - What is the best way to uninstall gems from a rails3 project? - Stack Overflow
This means that no gems will be installed at a global level and therefore when you remove one from your project's Gemfile and rerun bundle then it, obviously, won't be loaded in your project. Then, you can run bundle clean (with the project dir) and it will remove from the system all those gems ... More on stackoverflow.com
🌐 stackoverflow.com
Add option to clear bundle gem cache in bundle clean
Feature request The bundle clean command currently removes all the unused gems in the bundler directory. However, it would be nice to have an option for bundle clean to also remove the .gem files, ... More on github.com
🌐 github.com
5
November 15, 2023
ruby - rails bundle clean - Stack Overflow
If you're using RVM you may use rvm gemset empty for the current gemset - this command will remove all gems installed to the current gemset (gemset itself will stay in place). Then run bundle install in order to install actual versions of gems. More on stackoverflow.com
🌐 stackoverflow.com
🌐
GitHub
github.com › rubygems › bundler › issues › 6648
bundle clean --force removes gems bundled with Ruby · Issue #6648 · rubygems/bundler
August 3, 2018 - If I run bundle clean --force (in an effort to remove old gem version when the bundle needs to be updated), bundler will removed "bundled gems" - gems that are packaged with ruby. (see ht...
Author   jessebs
🌐
eMaxime Blog
emaxime.com › 2018 › how-to-uninstall-all-ruby-gems
How to uninstall all Ruby gems - eMaxime
October 21, 2018 - Sometimes you want to remove all installed gems from your computer. This was the case for me when I upgraded my projects from Ruby 2.5.1 to 2.5.3 in order to clean things up in 2.5.1 and regain disk space. Lots of Google entries for such a search point to: ... ERROR: While executing gem ... (Gem::InstallError) gem "bigdecimal" cannot be uninstalled because it is a default gem ... gem list --no-version | grep -vE "^(bigdecimal|bundler|cmath|csv|date|dbm|etc|fcntl|fiddle|fileutils|gdbm|io-console|ipaddr|openssl|psych|rdoc|scanf|sdbm|stringio|strscan|webrick|zlib)$" | xargs gem uninstall -aIx
🌐
GitHub
github.com › ruby › rubygems › issues › 7163
Add option to clear bundle gem cache in bundle clean · Issue #7163 · ruby/rubygems
November 15, 2023 - Feature request The bundle clean command currently removes all the unused gems in the bundler directory. However, it would be nice to have an option for bundle clean to also remove the .gem files, perhaps something like bundle clean --ca...
Author   wildmaples
Find elsewhere
🌐
Medium
channaly.medium.com › rails-tips-and-trick-1cb270fb0ab5
How to remove a default bundler gem | by Ly Channa | Medium
September 16, 2020 - The result show bundler 2.1.2 is the default. The default is the one that will be used. ... As default gems are not allowed to be uninstalled, I found this ruby code from https://github.com/rubygems/bundler/issues/7107#issuecomment-572296292
🌐
Coderwall
coderwall.com › p › mobeqa › remove-all-gems
Remove all gems (Example)
February 25, 2016 - If you are using rvm and accidentally install gems with the 'sudo' command you can quickly remove all gems: $ rvm use system && sudo gem list --no-versions | xargs sudo gem uninstall -a · Then you can just normally install bundler: $ gem install ...
🌐
GitHub
gist.github.com › IanVaughan › 2902499
Uninstall all rbenv gems · GitHub
#!/bin/bash gem_remove() { gem list --no-versions --no-verbose | xargs gem uninstall -aIx gem list } gem_remove_all() { #rbenv versions --bare RBENVPATH=`rbenv root` echo $RBENVPATH RUBIES=`ls $RBENVPATH/versions` for ruby in $RUBIES; do echo '---------------------------------------' echo $ruby rbenv local $ruby gem_remove done } I don't include gem install bundler at the end.
🌐
Reddit
reddit.com › r/rails › [deleted by user]
How to figure out unused gems and remove them : r/rails
October 7, 2023 - Uninstall all gems for the current Ruby version. Run bundle so you have the gems just required for that particular app. Run the tests and then after they’re finished boot the app locally and have a random browse around. Leave it an hour then run gem stale. This will list the access times ...
🌐
CircleCI
discuss.circleci.com › build environment › programming languages
Remove cached ruby gems in vendor/bundle path - Programming Languages - CircleCI Discuss
November 12, 2015 - In our RoR project I need to update the version for capybara-webkit gem that we're using on our builds. I found that CI automatically caches the gems between builds. How can I remove/override the vendor/bundle path in or…
🌐
DEV Community
dev.to › st0012 › completely-remove-the-default-bundler-from-ci-environment-j0c
Completely Remove Ruby 2.7's Default Bundler - DEV Community
August 9, 2020 - $ bundle -v Bundler version 2.1.4 $ gem install bundler:1.17.3 --default Successfully installed bundler-1.17.3 as a default gem Done installing documentation for bundler after 0 seconds 1 gem installed $ bundle -v Bundler version 2.1.4 $ bundle config default 1.17.3 $ bundle -v Bundler version 2.1.4 · From all the references I can find, the only way to remove it is to delete the bundler-2.1.4.gemspec file from the gem path.