getting rid of ruby gems that won't die
Assuming that gem clean
(or sudo gem clean
) doesn't work, I would try the following to totally remove all gems from your system:
You can see where gems have been installed by running the command:
gem env paths
To remove all the gems on your system, simply remove the folders returned by this command.
Additionally, on OSX Leopard, default gems are installed in this folder:
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
If this folder exists on your system, as before you can remove this folder to ensure all gems are deleted.
What is the best way to uninstall gems from a rails3 project?
Bundler is launched from your app's root directory so it makes sure all needed gems are present to get your app working.If for some reason you no longer need a gem you'll have to run the
gem uninstall gem_name
as you stated above.So every time you run bundler it'll recheck dependencies
EDIT - 24.12.2014
I see that people keep coming to this question I decided to add a little something.
The answer I gave was for the case when you maintain your gems global. Consider using a gem manager such as rbenv or rvm to keep sets of gems scoped to specific projects.
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 that were once installed from your Gemfile (in the same dir) but at this given time are no longer listed there.... long story short - it removes unused gems.
Gem::Install Error
After some long searches it turns out the reason is because of a non-existent path. The cannot uninstall comes up because the system doesn't search /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
On a granular level, instead of gem cleanup rails
, you can simply use the uninstall command and type:
gem uninstall rails -i /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
Then you might hit another problem related to a non-existent path, at which point, you should create a directory using the command:
mkdir /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/bin
Now all uninstalls should work well. I recommend doing a clean gem reinstall by performing the following functions:
create a list of all existing gems
gem list --no-versions | sed -e '/^(*|$)/d' > installed_gems
uninstall all existing gems
gem list | cut -d" " -f1 | xargs gem uninstall -aIx
reinstalling latest gems
cat installed_gems | xargs sudo gem install
Removing all installed Gems and starting over
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
Having issues installing ruby gems after latest OS X El Capitan update
Don't forget that installing things into the system Ruby requires sudo
privileges, /Library
is usually restricted access.
Installing your own personal Ruby with rvm
or rbenv
avoids all this.
How to Reverse a Migration that Requires a Gem
Create the migration to do QC::Setup.drop
and run it.
Then delete the original AddQueueClassic
migration altogether.
Related Topics
How to Get the Current Time as 13-Digit Integer in Ruby
How Does Shovel (<<) Operator Work in Ruby Hashes
Rails - Sort by Join Table Data
What Does 'Def Self.Function' Name Mean
How to Configure Capistrano to Use My Rvm Version of Ruby
Rails 3. How to Display Two Decimal Places in Edit Form
Activerecord - Querying Polymorphic Associations
Differencebetween 'After_Create' and 'After_Save' and When to Use Which
Gem.Source_Index Is Deprecated, Use Specification. Should I Re-Install Gem or Rails
Get the Value of an Instance Variable Given Its Name
Convert a .Doc or .Pdf to an Image and Display a Thumbnail in Ruby
How to Cleanly Initialize Attributes in Ruby with New
"Which in Ruby": Checking If Program Exists in $Path from Ruby
Why Do This Ruby Object Have Both To_S and Inspect Methods That Appear to Do the Same Thing