Cache: ~/.npm is 1.2G on a new macos-latest hosted runner

Created on 13 Feb 2020  路  12Comments  路  Source: actions/cache

On the ubuntu-latest hosted runner ~/.npm doesn't exist initially, as expected, but on the macos-latest hosted runner ~/.npm is 1.2G initially. This makes a cache restore or save take 1.5 minutes on macos-latest, verses seconds on ubuntu-latest.

2020-02-13T03:30:07.3173048Z ##[section]Starting: Request a runner to run this job
2020-02-13T03:30:07.3562194Z Requesting a hosted runner in current repository's account/organization with labels: 'macos-latest', require runner match: True
2020-02-13T03:30:07.7405114Z Labels matched hosted runners has been found, waiting for one of them get assigned for this job.
2020-02-13T03:30:07.7925180Z ##[section]Finishing: Request a runner to run this job
2020-02-13T03:30:23.3667460Z Current runner version: '2.164.0'
2020-02-13T03:30:23.3668900Z Prepare workflow directory
2020-02-13T03:30:23.3958520Z Prepare all required actions
2020-02-13T03:30:23.4418000Z ##[group]Run du -sh ~/.npm
2020-02-13T03:30:23.4418540Z du -sh ~/.npm
2020-02-13T03:30:23.6135780Z shell: /bin/bash -e {0}
2020-02-13T03:30:23.6136090Z ##[endgroup]
2020-02-13T03:30:25.5609940Z 1.2G   /Users/runner/.npm
2020-02-13T03:30:25.5653360Z Cleaning up orphan processes

Is the macos-latest npm cache being primed on purpose or did I find a bug?

question

Most helpful comment

You can also use such a configuration file as a temporary workaround.

name: Main workflow

on:
  push:
  pull_request:

jobs:
  build:
    strategy:
      matrix:
        os:
          - macos-latest
          - ubuntu-latest
          - windows-latest
        node-version:
          - 13.x

    runs-on: ${{ matrix.os }}

    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v1
        with:
          node-version: ${{ matrix.node-version }}

      - name: Clean npm cache directory
        run: npm cache clear --force

      - name: Get npm cache directory
        id: npm-cache
        run: echo "::set-output name=dir::$(npm config get cache)"

      - name: Restore npm cache
        uses: actions/cache@v1
        with:
          path: ${{ steps.npm-cache.outputs.dir }}
          key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
          restore-keys: |
            ${{ runner.os }}-node-

      - name: Install packages
        run: npm ci

All 12 comments

I observed the same issue on Windows.

I've opened an issue in https://github.com/actions/virtual-environments/issues/427 to help get feedback on why that cache is so large initially.

Clearly these are the causes. The same goes for other operating systems.
https://github.com/actions/virtual-environments/blob/master/images/linux/scripts/installers/nodejs.sh

I just opened a PR to fix this issue.

@mjgallag @merlinnot Could you try execute npm list --global in CI and send me the results? It will probably list some tools you have never installed.

You can also use such a configuration file as a temporary workaround.

name: Main workflow

on:
  push:
  pull_request:

jobs:
  build:
    strategy:
      matrix:
        os:
          - macos-latest
          - ubuntu-latest
          - windows-latest
        node-version:
          - 13.x

    runs-on: ${{ matrix.os }}

    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v1
        with:
          node-version: ${{ matrix.node-version }}

      - name: Clean npm cache directory
        run: npm cache clear --force

      - name: Get npm cache directory
        id: npm-cache
        run: echo "::set-output name=dir::$(npm config get cache)"

      - name: Restore npm cache
        uses: actions/cache@v1
        with:
          path: ${{ steps.npm-cache.outputs.dir }}
          key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
          restore-keys: |
            ${{ runner.os }}-node-

      - name: Install packages
        run: npm ci

Update: https://github.com/actions/virtual-environments/issues/427#issuecomment-623858143

Could someone confirm that this issue is resolved for their macOS caches?

I will check it.

Note that nothing has progressed on this issue. The following is a summary of the latest environment.

| | macos-latest | ubuntu-latest | windows-latest |
| ---- | ------------ | -------------- | -------------- |
| npm | 209M | does not exist | 1.2G |
| yarn | 0B | 8.0K | 0B |

Running du -sh ~/.npm on macos-latest shows 4.0K /Users/runner/.npm, marking this issue as closed.

Thank you all for your feedback, see https://github.com/actions/virtual-environments/issues/427 for more details on this issue.

Glad to hear that. Thank you, too.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

thisismydesign picture thisismydesign  路  4Comments

wrightak picture wrightak  路  4Comments

mands picture mands  路  5Comments

Cerberus picture Cerberus  路  5Comments

hugovk picture hugovk  路  6Comments