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 摘要。