Skip to content

Commit 05087f7

Browse files
joelhawksleyCopilot
andcommitted
Update gemfile locks via sed instead of bundle lock
The rails_main and rails_main_head appraisals target ruby-head / a future Ruby (e.g. 4.1.0.dev). Running `bundle lock` on them from the release job's Ruby 4.0 — even with BUNDLE_IGNORE_RUBY_VERSION=1 — produces lockfiles that CI on ruby-head then wants to rewrite, and rejects because Bundler is running in frozen mode: Cannot write a changed lockfile while frozen. The running version of Bundler (4.0.16) does not match the version of the specification installed for it (4.1.0.dev). The only thing that actually changes in a lockfile during a release is the view_component version pinned by the path gemspec (e.g. 4.13.0 → 4.14.0). Replace the bundle lock loop with a targeted sed that rewrites that version in every Gemfile.lock / gemfiles/*.gemfile.lock. This is robust across mismatched Ruby versions and avoids running bundler at all for appraisals whose Ruby isn't installed. Verified locally: sed rewrites both the PATH-section spec line and the bottom DEPENDENCIES pin, matching only the view_component entry. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 217f0a0d-a9f2-4607-9643-5fcb3e34f20f
1 parent 356ccc4 commit 05087f7

1 file changed

Lines changed: 16 additions & 10 deletions

File tree

‎script/release‎

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,22 @@ update_ruby_version() {
6161
}
6262

6363
update_gemfiles() {
64-
# Update Gemfile.lock. Use `bundle lock` (not `bundle install`) so we
65-
# only rewrite the lockfile with the new version — no gem installs
66-
# needed, and it avoids re-triggering the bundler-cache frozen check.
67-
bundle lock
68-
69-
# Update appraisal gemfile locks.
70-
# BUNDLE_IGNORE_RUBY_VERSION is needed because the gemfiles declare ruby
71-
# versions that don't match the local Ruby (e.g. 3.2, 3.3, 4.1.0.dev).
72-
for gemfile in gemfiles/*.gemfile; do
73-
BUNDLE_GEMFILE="$gemfile" BUNDLE_IGNORE_RUBY_VERSION=1 bundle lock
64+
major=$1
65+
minor=$2
66+
patch=$3
67+
new_version="$major.$minor.$patch"
68+
69+
# The only lockfile change during a release is the view_component
70+
# version pinned by the path gemspec. Update it in place across every
71+
# lockfile. Running `bundle lock` from a mismatched Ruby (e.g. ruby-head
72+
# appraisals from Ruby 4.0) produces lockfiles CI cannot consume in
73+
# frozen mode, so we edit them directly instead.
74+
for lockfile in Gemfile.lock gemfiles/*.gemfile.lock; do
75+
[ -f "$lockfile" ] || continue
76+
sed -i \
77+
-e "s/^\( view_component \)([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*)/\1($new_version)/" \
78+
-e "s/^\( view_component \)([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*)/\1($new_version)/" \
79+
"$lockfile"
7480
done
7581
}
7682

0 commit comments

Comments
 (0)