GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Error using default `cache: ''` option since v3.7.0 · Issue #797 · actions/setup-node

Error using default cache: '' option since v3.7.0 #797

New issue
Copy link
New issue
Copy link
Closed
Closed
Error using default cache: '' option since v3.7.0#797
Copy link
Assignees
dmitry-shibanovdusan-trickovic
Labels
bugSomething isn't working

Description

@colinrotherham
colinrotherham
opened on Jul 6, 2023
Issue body actions

Description:
We've noticed that the default cache: '' option throws an error since v3.7.0

Post job cleanup.
Error: Cache folder paths are not retrieved for npm with cache-dependency-path = 

It's documented in README.md Usage

# Used to specify a package manager for caching in the default directory. Supported values: npm, yarn, pnpm.
# Package manager should be pre-installed
# Default: ''
cache: ''

Hope this report helps fix the issue for others. Thanks 😊

Action version:
v3.7.0

Platform:

  • Ubuntu
  • macOS
  • Windows

Runner type:

  • Hosted
  • Self-hosted

Tools version:
Node.js v18.16.1 with default npm 9.5.1

Repro steps:
Add a GitHub Action workflow step with the default cache: '' option

Here we toggle inputs.use-cache to skip cache restoration of /home/runner/.npm when node_modules is already cached. This speeds up our GitHub Actions workflow runs on Windows

runs:
  using: composite

  steps:
    - name: Setup Node.js
      uses: actions/setup-node@v3
      id: setup-node

      with:
        cache: ${{ inputs.use-cache != 'false' && 'npm' || '' }}
        node-version-file: .nvmrc

See the full action.yml for more information

Here's our related PR to pin to version v3.6.0 as a fix:

  • [support/4.x] Pin GitHub actions/setup-node to v3.6.0 alphagov/govuk-frontend#3909

Expected behavior:
The default cache: '' option to continue working

Actual behavior:
An error is thrown:

Post job cleanup.
Error: Cache folder paths are not retrieved for npm with cache-dependency-path = 

See examples of the error output:

  • https://github.com/alphagov/govuk-frontend/actions/runs/5474554095/jobs/9969468646
  • https://github.com/alphagov/govuk-frontend/actions/runs/5474554095/jobs/9971533338 (+ debug logs)

Activity

  1. colinrotherham
    added
    bugSomething isn't working
    needs triage
    on Jul 6, 2023
  2. dusan-trickovic commented on Jul 6, 2023

    @dusan-trickovic
    dusan-trickovic
    on Jul 6, 2023
    More actions

    Hello, @colinrotherham ! Thank you for submitting the issue, we will take a closer look at it and see what can be done :)

    Reacted by Colin Rotherham
  3. dusan-trickovic
    removed
    needs triage
    on Jul 6, 2023
  4. dusan-trickovic
    self-assigned this
    on Jul 10, 2023
  5. dmitry-shibanov commented on Jul 12, 2023

    @dmitry-shibanov
    dmitry-shibanov
    on Jul 12, 2023
    Contributor
    More actions

    Hello @colinrotherham. I took a look at your logs and it looks like that during the post job you have different values because cache-hit does not exist at post job but the cache-hit is true during set up step.

  6. dmitry-shibanov
    self-assigned this
    on Jul 12, 2023
  7. colinrotherham commented on Jul 12, 2023

    @colinrotherham
    colinrotherham
    on Jul 12, 2023
    Author
    More actions

    Thanks for taking a look @dmitry-shibanov

    Yeah that's right

    We intentionally set cache: '' because we know we'll skip npm ci later on

    On Windows it's too slow to restore the npm get cache directory when we don't need it

  8. dmitry-shibanov commented on Jul 12, 2023

    @dmitry-shibanov
    dmitry-shibanov
    on Jul 12, 2023
    Contributor
    More actions

    Thank you for your response @colinrotherham. I think it is not the issue from actions/setup-node. I've tried to specify cache: '' and it works as expected. I think in your case because the condition changes to post jobs. During the set up step the action gets empty string but during post it gets npm because cache-hit becomes null that is why on post step the setup-node gets npm.

  9. colinrotherham commented on Jul 12, 2023

    @colinrotherham
    colinrotherham
    on Jul 12, 2023
    Author
    More actions

    Unless I'm reading the log messages wrong they're for our node_modules cache restore?

    key: npm-install-${{ runner.os }}-${{ hashFiles('package-lock.json', '**/package.json') }}

    Do you think our cache-hit is true log messages affect actions/[email protected]?

    Cache restored successfully
    Cache restored from key: npm-install-Linux-XXXXXXX
    ##[debug]Node Action run completed with exit code 0
    ##[debug]Save intra-action state CACHE_KEY = npm-install-Linux-XXXXXXX
    ##[debug]Save intra-action state CACHE_RESULT = npm-install-Linux-XXXXXXX
    ##[debug]Set output cache-hit = true

    Do our cache key names clash?

    Composite action inputs

    Otherwise thanks for pointing out our inputs.use-cache != 'false' check

    During the set up step the action gets empty string but during post it gets npm because cache-hit becomes null that is why on post step the setup-node gets npm.

    We hadn't noticed that the input changed from 'false' (set up step) to null (post step)

    I presume in actions/[email protected] this was handled a bit better?

    We'll harden our checks for actions/[email protected] but good to discuss for anyone else facing the issue

    Appreciate it

  10. dmitry-shibanov commented on Jul 12, 2023

    @dmitry-shibanov
    dmitry-shibanov
    on Jul 12, 2023
    Contributor
    More actions

    You didn't face this issue before because previously the action was getting cached paths during the save-step through tools commands.Now the action gets cached paths during the setup steps and pass it to save step that is why now it fails for you because in your case the action during the setup step has empty string for cache but during (no paths for cache were saved) but during post step it gets cache as npm. It does not have cached paths that is why it fails.

    It was working previously because the action could save the cache because it could get paths and they were not empty because from the initial run of npm i command the global cache directory was also generated.

  11. colinrotherham commented on Jul 12, 2023

    @colinrotherham
    colinrotherham
    on Jul 12, 2023
    Author
    More actions

    Ah that's a great explanation. Hope this helps others that hadn't realised

    I'll update our input checks to include null which appears to fall under:

    • Boolean inputs are not actually booleans in composite actions runner#2238

    Will come back and close this issue if it all works

    Thanks again


    Update: All working 👍

  12. colinrotherham
    added 2 commits that reference this issue on Jul 12, 2023

    Fix GitHub Action “Setup Node.js” `use-cache` default

    6724309

    Fix GitHub Action “Setup Node.js” `use-cache` default

    7874ca4
  13. colinrotherham
    closed this as completedon Jul 13, 2023
  14. colinrotherham
    added a commit that references this issue on Jul 13, 2023

    Fix GitHub Action “Setup Node.js” `use-cache` default

    b8165f9
  15. eddiemonge commented on Jul 18, 2023

    @eddiemonge
    eddiemonge
    on Jul 18, 2023
    More actions
              I'm getting the same error `Error: Cache folder paths are not retrieved for npm with cache-dependency-path = ` but using this setup: (no `cached-dependency-path` and using npm`)
    
    runs:
      using: 'composite'
      steps:
        - uses: actions/checkout@v3
        - uses: actions/setup-node@v3
          with:
            node-version: 18
            registry-url: https://npm.pkg.github.com/
            cache: ${{ hashFiles('**/package-lock.json') && 'npm' || null }}
        - run: npm install --ignore-scripts
          shell: bash
        - run: npm rebuild && npm run prepare --if-present
          shell: bash
    

    I wonder if it has to do with removing the optional part of this check 8170e22#diff-55f15e2366942ad15f71a41ac983f8ce9a9882b28b7fd9082f3a26c799783064L16

    Originally posted by @eddiemonge in #801 (comment)

    @colinrotherham how did you actually fix it?

  16. colinrotherham commented on Jul 18, 2023

    @colinrotherham
    colinrotherham
    on Jul 18, 2023
    Author
    More actions

    For the cache option you have to default to '' now not null

  17. eddiemonge commented on Jul 18, 2023

    @eddiemonge
    eddiemonge
    on Jul 18, 2023
    More actions

    That should really have been a breaking change requiring a bump to version 4 then.

  18. eddiemonge commented on Jul 18, 2023

    @eddiemonge
    eddiemonge
    on Jul 18, 2023
    More actions

    That did not fix it for me.

    I'm using a custom reusable action:

    name: Setup NodeJS
    description: Setups NodeJS and install dependencies
    
    runs:
      using: 'composite'
      steps:
        - uses: actions/checkout@v3
        - uses: actions/setup-node@v3
          with:
            node-version: 18
            cache: ${{ hashFiles('**/package-lock.json') && 'npm' || '' }}
        - run: npm install --ignore-scripts
          shell: bash
        - run: npm rebuild && npm run prepare --if-present
          shell: bash
    

    The consuming action is:

    name: Build Node App
    
    runs:
      using: 'composite'
      steps:
        - uses: custom/setup-node
        - run: npm run build
    

    Output is

    Post job cleanup.
    Error: Cache folder paths are not retrieved for npm with cache-dependency-path = 
    
  19. colinrotherham commented on Jul 18, 2023

    @colinrotherham
    colinrotherham
    on Jul 18, 2023
    Author
    More actions

    Sorry it didn't help, this was our fix in alphagov/govuk-frontend@b8165f9

  20. colinrotherham
    added 3 commits that reference this issue on Jul 24, 2023

    Fix GitHub Action “Setup Node.js” `use-cache` default

    7c85d71

    Fix GitHub Action “Setup Node.js” `use-cache` default

    f4c451c

    Fix GitHub Action “Setup Node.js” `use-cache` default

    9034932
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @dmitry-shibanov
    dmitry-shibanov
  • @dusan-trickovic
    dusan-trickovic

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.