CodexBloom - Programming Q&A Platform

GitHub Actions cache not restoring dependencies for Ruby on Rails project despite correct setup

👀 Views: 71 đŸ’Ŧ Answers: 1 📅 Created: 2025-07-02
github-actions ruby-on-rails ci-cd YAML

I'm maintaining legacy code that I'm attempting to set up I need some guidance on I'm having trouble with caching dependencies in my GitHub Actions workflow for a Ruby on Rails application. I have set up the cache action to store my gems, but it seems that the cache isn't restoring correctly during subsequent runs. My workflow configuration looks like this: ```yaml name: CI on: push: branches: - main jobs: build: runs-on: ubuntu-latest steps: - name: Check out code uses: actions/checkout@v2 - name: Cache gems uses: actions/cache@v2 with: path: vendor/bundle key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }} restore-keys: | ${{ runner.os }}-gems- - name: Install dependencies run: | bundle install --path vendor/bundle - name: Run tests run: | bundle exec rspec ``` In the logs, I see the following message when the cache is supposed to be restored: `Cache not found for input keys: ubuntu-latest-gems-<hash>` I have confirmed that my `Gemfile.lock` is not changing frequently and I have also tried clearing the cache from the GitHub UI. However, the action still does not find the cache on subsequent runs. Additionally, I am using `actions/cache@v2`, and I've checked to ensure that I have the right permissions enabled for caching. I even tried changing the `restore-keys` to include a more generic key, but that did not help either. Can anyone suggest what might be going wrong or any additional steps I should take to troubleshoot this scenario? I've been using Yaml for about a year now. Could someone point me to the right documentation? My development environment is CentOS. Is this even possible? My development environment is Windows 10. What would be the recommended way to handle this?