Bell Bell - 1 month ago 23x
Ruby Question

Force bundle install to use https:// instead of git:// for GitHub-based gems

I am trying to build a rails project and because the host I am working on doesn't have access to the Internet for the the git:// protocol (port 9418) I get errors like

Fetching git://
fatal: unable to connect to[0:]: errno=Connection refused

when running
bundle install

The relevant line in the GemFile doesn't specify git:// as a protocol, it just points to GitHub as the source for the gem

gem 'jasmine', :github => 'pivotal/jasmine-gem'

What do I have to do to make bundler to use https:// rather than git:// for pulling gems from GitHub?


Is there a way other than editing every affected line in the GemFile? I'd prefer to avoid any merging issues down the line if the project's GemFile is updated.


Git provides URL rewriting functionality using the url..insteadOf configuration option.

So to make all connections to use https:// rather than git://

git config --global url."".insteadOf git://

The --global switch sets the config option for all git operations by the current user, so there are times where it may be too intrusive. But it does avoid changing the git config in the current project.