Recommend ruby/setup-ruby's bundler-cache: true option · actions/cache@1bfe3ac (original) (raw)

Original file line number Diff line number Diff line change
@@ -468,21 +468,18 @@ Replace `~/.local/share/renv` with the correct `path` if not using Ubuntu.
468 468
469 469 ## Ruby - Bundler
470 470
471 -```yaml
472 -- uses: actions/cache@v2
473 - with:
474 - path: vendor/bundle
475 - key: runner.os−gems−{{ runner.os }}-gems-runner.osgems{{ hashFiles('**/Gemfile.lock') }}
476 - restore-keys: |
477 - ${{ runner.os }}-gems-
478 -```
479 -When dependencies are installed later in the workflow, we must specify the same path for the bundler.
471 +Caching gems with Bundler correctly is not trivial and just using `actions/cache`
472 +is [not enough](https://github.com/ruby/setup-ruby#caching-bundle-install-manually).
473 +
474 +Instead, it is recommended to use `ruby/setup-ruby`'s
475 +[`bundler-cache: true` option](https://github.com/ruby/setup-ruby#caching-bundle-install-automatically)
476 +whenever possible:
480 477
481 478 ```yaml
482 -- name: Bundle install
483 - run: |
484 - bundle config path vendor/bundle
485 - bundle install --jobs 4 --retry 3
479 +- uses: ruby/setup-ruby@v1
480 + with:
481 + ruby-version: ...
482 + bundler-cache: true
486 483 ```
487 484
488 485 ## Rust - Cargo