Force bundle install to use https:// instead of git:// for GitHub-based gems
Use bundle config github.https true
Git provides URL rewriting functionality using the url..insteadOf configuration option.
So to make all connections to github.com use https:// rather than git://
git config --global url."https://github.com".insteadOf git://github.com
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.
You can do:
gem 'jasmine', git: 'https://github.com/pivotal/jasmine-gem.git'
If you want this just for all the gems in one Gemfile you can add these lines at the top of the file:
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
Alternatively you can use bundle config github.https true
. But this affects only your current environment.
This won't be necessary anymore with Bundler 2.0.
if you're deploying to heroku, you can just add BUNDLE_GITHUB__HTTPS
(note the double underscore) as an environment variable and set it to true
(in your heroku app's dashboard under the Settings
tab in the Config Vars
section). this will switch the protocol from git://
to https://
for all such requests.