<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>loopkid: uninstall all gems</title>
    <link>http://loopkid.net/articles/2008/05/31/uninstall-all-gems</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>sad songs make me happy</description>
    <item>
      <title>uninstall all gems</title>
      <description>&lt;p&gt;To perform batch operations in MacPorts you can use the predefined pseudo-portnames. RubyGems has no such thing, but instead it can handle regular expressions. So to uninstall all gems of your default RubyGems installation you can simply issue the following command.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;sudo gem uninstall --a --ignore-dependencies .+
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;For some weird reason in my case I had to call it twice, but then all gems where gone.&lt;/p&gt;

&lt;p&gt;Bharat Ruparel asked in the comments if there is a way to automatize the reinstallation of the gems. Yes, there is. This solution generates a file containing a list of all the gems and after removing all gems reads the gem names from this file to reinstall them. The solution does not however honor the installed version of the gems, so if you care about the versions you&amp;#8217;re going to have to find a different way. I have tested this on Mac OS X, if you&amp;#8217;re using Linux you&amp;#8217;d want to replace the &lt;code&gt;-E&lt;/code&gt; with an &lt;code&gt;-r&lt;/code&gt;.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;gem list --no-versions | sed -E '/^(*|$)/d' &amp;gt; installed_gems
sudo gem uninstall --a --ignore-dependencies .+
cat installed_gems | xargs sudo gem install
rm installed_gems
&lt;/code&gt;&lt;/pre&gt;</description>
      <pubDate>Sat, 31 May 2008 16:15:00 +0200</pubDate>
      <guid isPermaLink="false">urn:uuid:59735da9-134a-4533-b809-10d68678ac62</guid>
      <author>Stefan</author>
      <link>http://loopkid.net/articles/2008/05/31/uninstall-all-gems</link>
      <category>English</category>
      <category>Ruby</category>
      <trackback:ping>http://loopkid.net/articles/trackback/7567</trackback:ping>
    </item>
    <item>
      <title>"uninstall all gems" by Stefan</title>
      <description>&lt;p&gt;I have edited the posting. If you haven&amp;#8217;t already wiped your gems, this might be what you&amp;#8217;re looking for.&lt;/p&gt;</description>
      <pubDate>Thu, 03 Jul 2008 22:52:48 +0200</pubDate>
      <guid isPermaLink="false">urn:uuid:b7b79f21-32bc-4d1a-b606-fde271081a1f</guid>
      <link>http://loopkid.net/articles/2008/05/31/uninstall-all-gems#comment-8509</link>
    </item>
    <item>
      <title>"uninstall all gems" by Bharat Ruparel</title>
      <description>&lt;p&gt;Thank you.  This saves me all kinds of time.  Is there an automated way of installing gems so  rebuilding is just as easy?&lt;/p&gt;</description>
      <pubDate>Thu, 03 Jul 2008 17:00:05 +0200</pubDate>
      <guid isPermaLink="false">urn:uuid:1ec5f834-b0b3-4b2d-bb2b-664f0ade6a0d</guid>
      <link>http://loopkid.net/articles/2008/05/31/uninstall-all-gems#comment-8505</link>
    </item>
  </channel>
</rss>
