Skip to content

Replace Gemfile with Gemfile.next#1

Open
arielj wants to merge 4 commits into
mainfrom
hardcode-gemfile-next
Open

Replace Gemfile with Gemfile.next#1
arielj wants to merge 4 commits into
mainfrom
hardcode-gemfile-next

Conversation

@arielj
Copy link
Copy Markdown
Collaborator

@arielj arielj commented Jun 2, 2026

This PR replaces all references of Gemfile and Gemfile.lock with Gemfile.next and Gemfile.next.lock.

@arielj arielj requested a review from JuanVqz June 2, 2026 22:26
Comment thread .github/CODEOWNERS Outdated
Copy link
Copy Markdown
Member

@JuanVqz JuanVqz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arielj I noticed we need to set the BUNDLE_GEMFILE=Gemfile.next to make this work because we are still reading it, and if for some reason they forget to set it to the Gemfile.next, they might run into runtime issues as the previous approach.

This is due to buildpack reads Gemfile.next at build but dyno defaults to Gemfile/Gemfile.lock at runtime.

Here is the test I ran if you want to copy-paste:

  1. confirm app uses the PR buildpack
heroku buildpacks -a app-staging
  1. the manual config var that makes runtime work
heroku config -a app-staging | grep -i bundle
  1. the two lockfiles differ
heroku run --no-tty -a app-staging 'grep "^    rails " Gemfile.lock; grep "^    rails " Gemfile.next.lock'
  1. Probe A: current behavior (config var present): WORKS
heroku run --no-tty -a app-staging 'bundle exec ruby -e "require %q{rails}; puts Rails::VERSION::STRING"'
  1. Probe B: simulate no-fix state (force default Gemfile): CRASHES
heroku run --no-tty -a app-staging 'BUNDLE_GEMFILE=$HOME/Gemfile bundle exec ruby -e "require %q{rails}; puts Rails::VERSION::STRING"'

Logs when running Probe B:

➜  heroku-buildpack-ruby-gemfile-next git:(hardcode-gemfile-next) ✗ heroku run --no-tty -a app-staging 'BUNDLE_GEMFILE=$HOME/Gemfile bundle exec ruby -e "require %q{rails}; puts Rails::VERSION::STRING"'                                   
Running BUNDLE_GEMFILE=$HOME/Gemfile bundle exec ruby -e "require %q{rails}; puts Rails::VERSION::STRING" on ⬢ app-staging... up, run.7494
/app/vendor/bundle/ruby/4.0.0/gems/bundler-4.0.10/lib/bundler/definition.rb:703:in 'Bundler::Definition#materialize': Could not find rails-8.0.3, sidekiq-7.3.9, railties-8.0.3, activesupport-8.0.3, thor-1.5.0, actionpack-8.0.3, activemodel-8.0.3, rack-3.2.6, actioncable-8.0.3, actionmailbox-8.0.3, actionmailer-8.0.3, actiontext-8.0.3, actionview-8.0.3, activejob-8.0.3, activerecord-8.0.3, activestorage-8.0.3, i18n-1.14.8, redis-client-0.28.0, bigdecimal-4.1.2, concurrent-ruby-1.3.6, logger-1.7.0, connection_pool-2.5.5, irb-1.18.0, rackup-2.3.1, rake-13.4.2, zeitwerk-2.7.5, nokogiri-1.19.3-x86_64-linux-gnu, benchmark-0.5.0, minitest-6.0.6, rack-session-2.1.2, rails-html-sanitizer-1.7.0, json-2.19.3, mail-2.8.1, rdoc-7.2.0, reline-0.6.3, loofah-2.25.1, net-imap-0.5.12, erb-6.0.4 in locally installed gems (Bundler::GemNotFound)
	from /app/vendor/bundle/ruby/4.0.0/gems/bundler-4.0.10/lib/bundler       /definition.rb:240:in 'Bundler::Definition#specs'
	from /app/vendor/bundle/ruby/4.0.0/gems/bundler-4.0.10/lib/bundler       /definition.rb:313:in 'Bundler::Definition#specs_for'
	from /app/vendor/bundle/ruby/4.0.0/gems/bundler-4.0.10/lib/bundler       /runtime.rb:18:in 'Bundler::Runtime#setup'
	from /app/vendor/bundle/ruby/4.0.0/gems/bundler-4.0.10/lib/bundler       .rb:165:in 'Bundler.setup'
	from /app/vendor/bundle/ruby/4.0.0/gems/bundler-4.0.10/lib/bundler       /setup.rb:32:in 'block in <top (required)>'
	from /app/vendor/bundle/ruby/4.0.0/gems/bundler-4.0.10/lib/bundler       /ui/shell.rb:177:in 'Bundler::UI::Shell#with_level'
	from /app/vendor/bundle/ruby/4.0.0/gems/bundler-4.0.10/lib/bundler       /ui/shell.rb:122:in 'Bundler::UI::Shell#silence'
	from /app/vendor/bundle/ruby/4.0.0/gems/bundler-4.0.10/lib/bundler       /setup.rb:32:in '<top (required)>'
	from /app/vendor/ruby-4.0.2/lib/ruby/4.0.0/rubygems.rb:1455:in 'Ke       rnel#require'
	from /app/vendor/ruby-4.0.2/lib/ruby/4.0.0/rubygems.rb:1455:in '<t       op (required)>'
	from <internal:gem_prelude>:2:in '<internal:gem_prelude>'

For that reason, I'm suggesting "forcing" the usage of the Gemfile.next and the user does not need to set the BUNDLE_GEMFILE anymore.

Thoughts?

Comment thread README.md Outdated
Comment thread lib/language_pack/ruby.rb
Comment thread lib/language_pack/ruby.rb
set_env_default "BUNDLE_WITHOUT", ENV["BUNDLE_WITHOUT"]
set_env_default "BUNDLE_BIN", ENV["BUNDLE_BIN"]
set_env_default "BUNDLE_DEPLOYMENT", ENV["BUNDLE_DEPLOYMENT"] if ENV["BUNDLE_DEPLOYMENT"] # Unset on windows since we delete the Gemfile.lock
set_env_default "BUNDLE_DEPLOYMENT", ENV["BUNDLE_DEPLOYMENT"] if ENV["BUNDLE_DEPLOYMENT"] # Unset on windows since we delete the Gemfile.next.lock
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Force the running dyno to use Gemfile.next/Gemfile.next.lock instead of bundler's default Gemfile/Gemfile.lock

Suggested change
set_env_default "BUNDLE_DEPLOYMENT", ENV["BUNDLE_DEPLOYMENT"] if ENV["BUNDLE_DEPLOYMENT"] # Unset on windows since we delete the Gemfile.next.lock
set_env_default "BUNDLE_DEPLOYMENT", ENV["BUNDLE_DEPLOYMENT"] if ENV["BUNDLE_DEPLOYMENT"] # Unset on windows since we delete the Gemfile.next.lock
set_env_default "BUNDLE_GEMFILE", "$HOME/Gemfile.next"

arielj and others added 2 commits June 3, 2026 18:17
Co-authored-by: Juan Vásquez <javasgon@gmail.com>
Signed-off-by: Ariel Juodziukynas <arieljuod@gmail.com>
Co-authored-by: Juan Vásquez <javasgon@gmail.com>
Signed-off-by: Ariel Juodziukynas <arieljuod@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants