Sean Mackesey
Sean Mackesey

Reputation: 10939

Exclude certain gems from rubygems "gem update" command

I have a gem that I maintain purely for personal use that happens to have a name conflict with an old gem hosted on rubygems.org. When I run gem update, the rubygems.org version is downloaded. I would like to keep this from happening. I know that I can specify explicitly what gems to include with gem update, but can I specify what to exclude?

Upvotes: 0

Views: 616

Answers (2)

Kelsey Hannan
Kelsey Hannan

Reputation: 2947

Following on Joshua's answer, to selectively exclude gems from updating during bundle update, you can also do the following:

bundle list --name-only | awk '{print $1}' | grep -v YOUR_GEMNAME | grep -v YOUR_OTHER_GEMNAME | xargs -t bundle update

with the additional pipe grep -v YOUR_OTHER_GEMNAME showing how you can exclude multiple gems from the bundle update if desired.

Upvotes: 0

Joshua Cheek
Joshua Cheek

Reputation: 31726

Pretty sure you can't, but you can script a solution fairly easily (on unix) with

gem list --local | awk '{print $1}' | grep -v YOUR_GEMNAME | xargs gem update

Also, I've been really impressed with the Rubygems source code the last several times I've looked at it, it probably wouldn't be very difficult to add this feature. They might accept a pull request for it.

Upvotes: 5

Related Questions