cli icon indicating copy to clipboard operation
cli copied to clipboard

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

Open vladfrangu opened this issue 11 months ago • 10 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

This issue exists in the latest npm version

  • [X] 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.

vladfrangu avatar Mar 21 '24 16:03 vladfrangu

We are facing this on npm ci in a fresh node:18.20.2 Docker container running in Google Cloud Build (no caching configured).

$ npm ci
...
npm ERR! code EEXIST
npm ERR! syscall open
npm ERR! path /builder/home/.npm/_cacache/tmp/da69041f
npm ERR! errno -17
npm ERR! EEXIST: file already exists, open '/builder/home/.npm/_cacache/tmp/da69041f'
npm ERR! File exists: /builder/home/.npm/_cacache/tmp/da69041f
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.
# cloudbuild.yaml
steps:
  - name: "node:18.20.2"
    script: |
      #!/usr/bin/env bash
      npm ci

das7pad avatar Apr 25 '24 10:04 das7pad

I'm also going to upload the logs here in case the GitHub actions logs expire:

logs_21970753725.zip

vladfrangu avatar Apr 25 '24 10:04 vladfrangu

We have the same issue today

shaykr avatar Apr 29 '24 18:04 shaykr

Try to use node v22

perfilev-faraway avatar Apr 30 '24 13:04 perfilev-faraway

also getting this today. Any workarounds?

anthonywhite avatar May 15 '24 12:05 anthonywhite

I found that using npm v9 would be a workaround.

    - if: runner.os == 'Windows'
      run: npm install -g [email protected]
      shell: bash

mtsmfm avatar May 22 '24 04:05 mtsmfm

same issue with ubuntu, node version: "20.12.1"

jhwu68 avatar May 28 '24 04:05 jhwu68

facing same issue when deploying in heroku docker node app

Vinitpal avatar Jun 14 '24 07:06 Vinitpal

Similar issue with building inside of docker in a CI/CD system using gitlab

heath-freenome avatar Jun 18 '24 02:06 heath-freenome