Describe the problem as clearly as you can
I have recently changed the default branch in a number of my gem repositories from master to main. In doing so, this seems to have broken updates from dependent projects which use a git source (with no explicit branch) in their Gemfiles.
Post steps to reproduce the problem
- Create a new gem (using
bundle gem) and push to GitHub. I've used https://github.com/spohlenz/test_gem.
- Create a Gemfile in another folder referencing this gem. Run
bundle install.
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem 'test_gem', github: 'spohlenz/test_gem'
- Rename the gem repo's default branch on GitHub. Then push a change to the repo.
- Run
bundle update within the dependent project. The Gemfile.lock still references the old default branch and commit pushed in step 3 isn't reflected.
I thought I could perhaps explicitly specify a branch for the repo in the Gemfile, and then remove it. e.g.
gem 'test_gem', github: 'spohlenz/test_gem', branch: 'renamed'
Running bundle update with the explicit branch option in place does bring in the new changes, but when it is removed, a subsequent bundle update reverts it back to the original default branch.
If this isn't an easy fix within bundler itself, is there an easy way to clear the cached git checkout? I've scoured the command options and couldn't find a relevant one that worked.
If not included with the output of your command, run bundle env and paste the output below
In case it is relevant:
Environment
Bundler 2.3.19
Platforms ruby, x86_64-darwin-21
Ruby 2.7.5p203 (2021-11-24 revision f69aeb83146be640995753667fdd6c6f157527f5) [x86_64-darwin-21]
Full Path /Users/sam/.rvm/rubies/ruby-2.7.5/bin/ruby
Config Dir /Users/sam/.rvm/rubies/ruby-2.7.5/etc
RubyGems 3.1.6
Gem Home /Users/sam/.rvm/gems/ruby-2.7.5
Gem Path /Users/sam/.rvm/gems/ruby-2.7.5:/Users/sam/.rvm/rubies/ruby-2.7.5/lib/ruby/gems/2.7.0
User Home /Users/sam
User Path /Users/sam/.gem/ruby/2.7.0
Bin Dir /Users/sam/.rvm/gems/ruby-2.7.5/bin
Tools
Git 2.32.1 (Apple Git-133)
RVM 1.29.12 (latest)
rbenv not installed
chruby not installed
rubygems-bundler (1.4.5)
Bundler Build Metadata
Built At 2022-07-27
Git SHA 4f496f93e6
Released Version true
Bundler settings
gem.changelog
Set for the current user (/Users/sam/.bundle/config): true
gem.ci
Set for the current user (/Users/sam/.bundle/config): false
gem.coc
Set for the current user (/Users/sam/.bundle/config): false
gem.linter
Set for the current user (/Users/sam/.bundle/config): false
gem.mit
Set for the current user (/Users/sam/.bundle/config): false
gem.test
Set for the current user (/Users/sam/.bundle/config): false
Gemfile
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem 'test_gem', github: 'spohlenz/test_gem'
Gemfile.lock
GIT
remote: https://github.com/spohlenz/test_gem.git
revision: 78543de0c3929011b347073df15bf10f394b1cf3
specs:
test_gem (0.1.0)
GEM
remote: https://rubygems.org/
specs:
PLATFORMS
x86_64-darwin-21
DEPENDENCIES
test_gem!
BUNDLED WITH
2.3.19
Describe the problem as clearly as you can
I have recently changed the default branch in a number of my gem repositories from
mastertomain. In doing so, this seems to have broken updates from dependent projects which use a git source (with no explicit branch) in their Gemfiles.Post steps to reproduce the problem
bundle gem) and push to GitHub. I've used https://github.com/spohlenz/test_gem.bundle install.bundle updatewithin the dependent project. TheGemfile.lockstill references the old default branch and commit pushed in step 3 isn't reflected.I thought I could perhaps explicitly specify a branch for the repo in the Gemfile, and then remove it. e.g.
Running
bundle updatewith the explicit branch option in place does bring in the new changes, but when it is removed, a subsequentbundle updatereverts it back to the original default branch.If this isn't an easy fix within bundler itself, is there an easy way to clear the cached git checkout? I've scoured the command options and couldn't find a relevant one that worked.
If not included with the output of your command, run
bundle envand paste the output belowIn case it is relevant:
Environment
Bundler Build Metadata
Bundler settings
Gemfile
Gemfile.lock