tags:

views:

122

answers:

2

I am hosting a ruby gem repository which hosts several of my gems for my applications. I am running into some problems when I try to install one of my gems that has the same name as a gem on rubyforge.

gem.config

---
:benchmark: false
:update_sources: true 
:verbose: true
:backtrace: false
:sources:
- http://gems.rubyforge.org
- http://localhost:8888
:bulk_threshold: 1000

Using the command to install mygem:

gem install mygem --config-file gem.config

This will install the 'mygem' from the http://gems.rubyforge.org repository. When I re-order the sources in the gem.config file, I get the same results.

Is there a way to define my gem repository as the default and fallback to another repository if the gem can't be found?

A: 

If the gem repository is local you can use the --local option on the gem command:

gem install mygem --local --config-file gem.config 

Also I believe that if you switch the order of your sources (specifying localhost first) gem will try that repository first (and pick up the gems you have with the same name as rubygems repository)

ennuikiller
The repository is local for now but will eventually be hosted on another machine. Also, I tried re-ordering the sources and got the same result.
Trevor
+1  A: 

Gem names must be globally unique. If there are multiple gems with the same name, the results are undefined.

Jörg W Mittag
Do you know of any best practice when you have to install gems from a public repository (gemcutter.org) and a local repository? Adding a unique name before my gem name (ex: myuniquenamespace-mygem) or storing all required gems in my local repository and never having to install from a public repository?
Trevor