# RubyGems question: install vs. update

**URL:** <https://www.ruby-forum.com/t/rubygems-question-install-vs-update/166826>\
**Category:** Ruby\
**Created:** [April 29, 2009, 11:17pm UTC](https://www.ruby-forum.com/t/rubygems-question-install-vs-update/166826 "2009-04-29T23:17:02Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [April 29, 2009, 11:17pm UTC](https://www.ruby-forum.com/t/rubygems-question-install-vs-update/166826/1 "2009-04-29T23:17:02Z")

</div>

This must be obvious, but what’s the difference between “gem install”  
and “gem update”?

I would have thought that “gem update” would do a gem install plus a  
gem cleanup, effectively updating your current version. But that  
doesn’t seem to be the case.

Jeff

---

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [April 30, 2009, 12:17am UTC](https://www.ruby-forum.com/t/rubygems-question-install-vs-update/166826/2 "2009-04-30T00:17:57Z")

</div>

On Apr 29, 2009, at 14:16, Jeff wrote:

> This must be obvious, but what’s the difference between “gem install”  
> and “gem update”?
> 
> I would have thought that “gem update” would do a gem install plus a  
> gem cleanup, effectively updating your current version. But that  
> doesn’t seem to be the case.

gem update will update a named gem if there’s a newer version, gem  
install will always install.

gem update can update all gems if you don’t list any.

---

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [April 30, 2009, 3:02am UTC](https://www.ruby-forum.com/t/rubygems-question-install-vs-update/166826/3 "2009-04-30T03:02:15Z")

</div>

On Apr 29, 5:16 pm, Eric H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> install will always install.  
> Hi Eric,

But when I try to update a named gem, I get the new version, but also  
still have the old version (if I do gem list I can see both  
versions). So maybe I’m missing what you mean by “update” - looks to  
me like it simply installed the new one alongside the old one, no  
different than if I had done “gem install” to install the latest  
version.

I’m currently on RubyGems 1.3.2.

Thanks again,  
Jeff

---

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [April 30, 2009, 3:40am UTC](https://www.ruby-forum.com/t/rubygems-question-install-vs-update/166826/4 "2009-04-30T03:40:59Z")

</div>

On Wed, Apr 29, 2009 at 9:01 PM, Jeff [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> But when I try to update a named gem, I get the new version, but also  
> still have the old version (if I do gem list I can see both  
> versions). So maybe I’m missing what you mean by “update” - looks to  
> me like it simply installed the new one alongside the old one, no  
> different than if I had done “gem install” to install the latest  
> version.
> 
> I’m currently on RubyGems 1.3.2.

RubyGems supports having many versions of a gem installed on the same  
system, which is often necessary for dealing with libraries that  
depend on a particular version of a project.

The difference between gem update gemname and gem install gemname is  
that gem update is essentially a no-op if you already have the latest  
gem installed, where gem install will download and install the gem  
even if you already have it.

-greg

---

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [April 30, 2009, 7:06am UTC](https://www.ruby-forum.com/t/rubygems-question-install-vs-update/166826/5 "2009-04-30T07:06:42Z")

</div>

7stud – wrote:

> Gregory B. wrote:
> 
> > The difference between gem update gemname and gem install gemname is  
> > that gem update is essentially a no-op if you already have the latest  
> > gem installed, where gem install will download and install the gem  
> > even if you already have it.
> 
> In addition,

…oh, yeah. Sometimes updating doesn’t work! For instance, I was  
unable to _update_ rubygems itself using rubygems. I eventually had to  
download the latest version of rubygems and _install_ locally.

---

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [April 30, 2009, 7:04am UTC](https://www.ruby-forum.com/t/rubygems-question-install-vs-update/166826/6 "2009-04-30T07:04:36Z")

</div>

Gregory B. wrote:

> The difference between gem update gemname and gem install gemname is  
> that gem update is essentially a no-op if you already have the latest  
> gem installed, where gem install will download and install the gem  
> even if you already have it.

In addition, if you issue the update command with no filename, for  
example:

$ gem update

rubygems will search your local gem directory and update all the gems  
contained therein with the latest versions.

If you don’t need the old versions, then after either updating or  
installing you can use the command

$ gem cleanup

to get rid of the old versions.

---

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [April 30, 2009, 7:13am UTC](https://www.ruby-forum.com/t/rubygems-question-install-vs-update/166826/7 "2009-04-30T07:13:53Z")

</div>

On Thu, Apr 30, 2009 at 1:04 AM, 7stud – [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> $ gem update
> 
> rubygems will search your local gem directory and update all the gems  
> contained therein with the latest versions.

Read upwards. Eric already let the OP know about this.

---

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [April 30, 2009, 1:30pm UTC](https://www.ruby-forum.com/t/rubygems-question-install-vs-update/166826/8 "2009-04-30T13:30:26Z")

</div>

On Thu, Apr 30, 2009 at 1:06 AM, 7stud – [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> …oh, yeah. Sometimes updating doesn’t work! For instance, I was  
> unable to _update_ rubygems itself using rubygems. I eventually had to  
> download the latest version of rubygems and _install_ locally.

(sudo) gem update --system

normally works to install the latest version of ruby gems, although it  
has been known to fail for certain combinations of old installed, and  
new versions.

–  
Rick DeNatale

Blog: [http://talklikeaduck.denhaven2.com/](http://talklikeaduck.denhaven2.com/)  
Twitter: [http://twitter.com/RickDeNatale](http://twitter.com/RickDeNatale)  
WWR: [http://www.workingwithrails.com/person/9021-rick-denatale](http://www.workingwithrails.com/person/9021-rick-denatale)  
LinkedIn: [http://www.linkedin.com/in/rickdenatale](http://www.linkedin.com/in/rickdenatale)
