bundler-cache with no Gemfile.lock: constant cache key restores stale vendor/bundle (broken gem payloads)
還沒有人認領這個 Issue。
評估
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 新手友好度
- 65/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 活躍
- 技術堆疊
- github-actions, javascript, ruby
研究方向
Look at the action's source code, likely in the lib/ or src/ directories, to find where the bundler-cache key is computed. The key currently uses hashFiles('Gemfile.lock'). Understand the GitHub Actions cache API. The fix involves detecting the absence of Gemfile.lock and either skipping the cache or generating a key from Gemfile, *.gemspec, and the commit SHA. Test the change in a fork with a repository that has no Gemfile.lock committed. 'Done' is when a CI run with a lockless workflow correctly installs gems without restoring a stale cache.
由索引模型根據 Issue 內容生成。
描述
Summary
With bundler-cache: true and no Gemfile.lock committed (lockless
workflow, e.g. lock deliberately untracked), the bundle cache key
degenerates: hashFiles('Gemfile.lock') is empty, so the
vendor/bundle cache key becomes effectively constant across runs and
dependency changes. Jobs restore a stale or partially-invalid
vendor/bundle from an arbitrary earlier run. In our case the restored
rspec-support gem was missing lib/rspec/support/source.rb, and the
run then crashed fatally inside rspec's summary formatter
(LoadError), hiding all real test failures.
Observed on
- ruby/setup-ruby@v1,
bundler-cache: true - Repository with
Gemfile.lockin .gitignore (CI re-resolves deps) - ubuntu 22.04, Ruby 3.3.12
- run: metanorma/uniword PR CI, 2026-09-24
Expected
When no Gemfile.lock exists, either:
- skip the bundle cache entirely (fresh
bundle installevery run —
slower but correct), or - derive the cache key from
Gemfile+*.gemspechashes and
git rev-parse HEAD(or the run id), so every dependency change
produces a distinct cache entry and stale bundles are never
restored.
A warning (::warning::) that the bundle cache was skipped/derated
for lockless workflows would also make the failure mode diagnosable.
Workaround we applied
rm -rf vendor/bundle in a pre-setup step (forces pristine install).
Versions
- ruby/setup-ruby@v1 (current main as of 2026-09-24)
- Bundler 4.0.x
- 主要語言
- JavaScript
- 星號
- 990
- 分支
- 369
- 平均合併
- 1 小時 5 分鐘
- 30 天內合併 PR
- 5
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
ruby/setup-ruby 的其他 Issue
-
難度 4/5 3-5 天 新手友好度 25/100
ruby/setup-ruby#818 · 6 則留言 ·
-
難度 4/5 3-5 天 新手友好度 25/100
ruby/setup-ruby#801 · 3 則留言 ·
-
難度 3/5 1-2 天 新手友好度 42/100
ruby/setup-ruby#791 · 3 則留言 ·
-
難度 4/5 3-5 天 新手友好度 35/100
ruby/setup-ruby#752 · 12 則留言 ·
-
難度 2/5 1-3 小時 新手友好度 38/100
ruby/setup-ruby#673 · 3 則留言 · 1 個 reaction ·
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 70/100
-
難度 2/5 1-3 小時 新手友好度 75/100
mksglu/context-mode#1200 ·
-
難度 2/5 1-3 小時 新手友好度 75/100
neondatabase/website#5944 ·
-
module: core
難度 2/5 1-3 小時 新手友好度 75/100
bigbluebutton/bigbluebutton#25849 ·
-
難度 2/5 1-3 小時 新手友好度 75/100
jaegertracing/jaeger-ui#4506 ·