Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

bundler-cache with no Gemfile.lock: constant cache key restores stale vendor/bundle (broken gem payloads)

未關閉
#941 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
3/5
預估耗時
1-2 天
新手友好度
65/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
github-actions, javascript, ruby
領域
backend, ci-cd, tooling

研究方向

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.lock in .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:

  1. skip the bundle cache entirely (fresh bundle install every run —
    slower but correct), or
  2. derive the cache key from Gemfile + *.gemspec hashes 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

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

ruby/setup-ruby 的其他 Issue

查看 ruby/setup-ruby 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。