Bundler deployment Looks in vendor/bundle but Gems Are Elsewhere in CI
Deployment mode implies a vendored install under vendor/bundle, but your cache restored gems to a different path (or the install step used the default system path). Bundler then cannot find the bundle where deployment expects it.
What this error means
Under deployment mode a later step reports gems are missing even though an earlier step installed them, because the install path and the path deployment looks in disagree. Typically a cache-key or path-config mismatch between steps.
Bundler::GemNotFound: Could not find rake-13.1.0 in vendor/bundle
# the install step wrote gems to ~/.gem, but deployment mode reads vendor/bundleCommon causes
Install path differs from deployment path
bundle config set --local deployment true forces vendor/bundle, but an earlier install (or the cache) targeted the default system gem dir, so the gems are not where deployment looks.
Cache restored to the wrong directory
The actions/cache path does not match the bundle path, so restored gems land somewhere Bundler will not search under deployment.
How to fix it
Set a consistent path for install, cache, and deployment
Pin the bundle path once and cache that exact directory.
bundle config set --local path vendor/bundle
bundle config set --local deployment true
bundle installMatch the cache path to the bundle path
- uses: actions/cache@v4
with:
path: vendor/bundle
key: gems-${{ hashFiles('Gemfile.lock') }}How to prevent it
- Set bundle path explicitly and cache that same directory.
- Keep the path config identical across install, cache, and run steps.
- Use the official ruby/setup-ruby bundler-cache option, which wires path and cache together.