I have created a private gem that I have hosted myself. Everything was going well up until someone has created a gem with the same name on rubygems.org. Since rubygems.org has a highest precedence over my gem server url. I am not able to install my gem anymore. I tried to remove the rubygems source:
$ sudo gem source -r http://rubygems.org
and reinstall it so it comes after in the gem source list, but it does not work.
Is there a way to change the lookup order of the gem source?
Note that I don't want to rename my gem.
Managing Gem Sources Sometimes you want to manage your source list–typically when a gem's source changes locations. Ruby Gems gives you several options for managing your gem source list. To list all gem sources, use the -l flag. To remove a gem source, use the r flag followed by the URL of the source to be removed.
GitHub is the main Ruby-related content repository. Most often a gem source code will be hosted on GitHub while being published as a fully-fledged gem to RubyGems.org. The Ruby Toolbox is a project that makes it easy to explore open source Ruby projects.
Note that you need an account at RubyGems.org to do this. From the main menu, select Tools | Gem | Push Gem. In the Run tool window, specify your RubyGems credentials. Your gem will be published to RubyGems.org.
You may try the specific_install
gem:
gem install specific_install
gem specific_install -l <git-url>
Another way is to explicitly state the gem server like so:
gem install mygem -s http://gems.example.com
The best option, in my opinion, is to use Bundler. In your Gemfile add:
gem 'mygem', :git => 'git://git.example.com/myrepo.git'
It seems like you can't have an empty gem cache. If you delete the http://rubygems.org cache manually with gem source -r http://rubygems.org
, and there are no other sources defined, it automatically gets repopulated. Kind of an annoying misfeature, really.
What did the trick for me was adding my source (an internal server) and then readding rubygems manually.
$ gem source add http://internal-server/
$ gem source
*** CURRENT SOURCES ***
http://rubygems.org/
http://internal-server/
$ gem source -r http://rubygems.org/
$ gem source
*** CURRENT SOURCES ***
http://internal-server/
$ gem source -a http://rubygems.org/
$ gem source
*** CURRENT SOURCES ***
http://internal-server/
http://rubygems.org/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With