Skip to content

[BUG] EEXIST: file already exists, open 'C:\npm\cache\_cacache\tmp\e21a7cda' in GitHub Actions CI inconsistently when running under Windows #7308

@vladfrangu

Description

@vladfrangu

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

When running npm ci on a Windows runner on GH Actions (via the provided runners), npm inconsistently consistently throws EEXIST: file already exists, open 'C:\npm\cache\_cacache\tmp\e21a7cda' errors when trying to run npm ci (and even when using --force.

Here's an example run log: https://github.com/apify/apify-cli/actions/runs/8378040031/job/22941626321?pr=527

What I mean by inconsistently consistently is that it works randomly, then it stops working, then it works again. I'm not sure what else to do at this point to make this not work or why it's having issues. In the PR attached to the above run, I tried turning off the cache configuration from setup-node, but that had no effect.

This hasn't happened once on ubuntu, which makes me think there might be a Windows-specific issue. What's even stranger is that the cache directory is actually empty, yet these issues happen,

Expected Behavior

npm shouldn't encounter caching issues on Windows, and should have some form of retry mechanisms for these issues.

Steps To Reproduce

  1. Setup an action workflow that runs on windows on github actions
  2. Try to install dependencies with npm ci

You might need a few runs of the flow to see it happening, which is not ideal either.

Example flow:

name: Check & Release

on:
    push:

jobs:
    build_and_test:
        name: Build & Test
        runs-on: ${{ matrix.os }}

        strategy:
            fail-fast: false
            matrix:
                os: [ubuntu-latest, windows-latest]
                node-version: [18, 20]

        steps:
            - uses: actions/checkout@v4

            - name: Use Node.js ${{ matrix.node-version }}
              uses: actions/setup-node@v4
              with:
                  node-version: ${{ matrix.node-version }}
                  cache: ${{ (matrix.os != 'windows-latest' && 'npm') || '' }}

            # I considered this bug might've been fixed in newer npm versions, but that wasn't the case :cry:
            # - name: Bump npm to latest
            #   if: matrix.os == 'windows-latest'
            #   run: npm install -g npm@latest

            - name: Install Dependencies
              run: npm ci ${{ (matrix.os == 'windows-latest' && '--force') || '' }}

Environment

  • npm: 10.2.4 & 10.5.0
  • Node.js: v18.19.1
  • OS Name: Microsoft Windows Server 2022 10.0.20348 Datacenter
  • System Model Name: no clue, whatever GH Actions runs on 😅
  • npm config:
; "global" config from C:\npm\prefix\etc\npmrc

cache = "C:\\npm\\cache" 

; "env" config from environment

prefix = "C:\\npm\\prefix" 

; node bin location = C:\hostedtoolcache\windows\node\18.19.1\x64\node.exe
; node version = v18.19.1
; npm local prefix = D:\a\apify-cli\apify-cli
; npm version = 10.5.0
; cwd = D:\a\apify-cli\apify-cli
; HOME = C:\Users\runneradmin
; Run `npm config ls -l` to show all defaults.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingNeeds Triageneeds review for next steps

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions