Changing the reading order of Rubygem sources

谁说我不能喝 提交于 2020-01-01 11:33:10

问题


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.


回答1:


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'




回答2:


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/


来源:https://stackoverflow.com/questions/16112381/changing-the-reading-order-of-rubygem-sources

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!