开发者

avoid http checking when installing a home made gem

I'm working on a set of gems for my application.

When installing any of my own gems, the gem program will check rubugems specs (possibly for dependencies). With a verbose flag I can see messages like :

GET http://rubygems.org/latest_specs.4.8.gz
302 Found
GET http://production.s3.rubygems.org/latest_specs.4.8.gz
200 OK
GET http://rubygems.开发者_StackOverflow中文版org/specs.4.8.gz

The issue is that I'm working on those gems, and that I package/reinstall a number of times every day, and the installation process is quite long.

As I'm pretty sure that all the external gem dependencies are satisfied, is there a way to tel gem not to check the dependencies from rubygems.org, and avoid, possibly slow http traffic ?

Regards,

_dl


If you want to keep things like rubygems.org from being accessed as part of your build, you can use an internal gemserver like GemInABox to host the gems you'll use in your organization.

Then just make sure to pass both the --clear-sources and --source options to gem.

For example:

gem install bundler --clear-sources --source http://your.corporate.gemserver.here.com 

This will allow you to keep connectivity issues and network lag out of your CI build, thereby eliminating another source of build variance.

It used to be that gem's --source option was used as the only source for gem lookups. From somewhere in 2009 onwards, it changed to combine the source supplied as an option with the default sources defined for gems, one of which is http://rubygems.org.

Sadly, that meant that if you were running gem in a machine which was walled off and couldn't even access an http proxy, you'd find gem install failing with network issues since it would get homesick and attempt to lookup http://rubygems.org even though you'd told it not to look there.

The Rubygems manual is a little behind the curve, and the --clear-source option undocumented in the manual. It's only visible if you look in the source code. I hope this gets picked up and used by others to save them some time.

Cheers Stuart


Are you using jeweler to create the gem?

You can use rake install to install the gem

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜