Skip to content

Error: EEXIST: file already exists, symlink in yarn v4.9.2 workspace #367

@ShaoNZ-ATL

Description

@ShaoNZ-ATL

Hi there,
I'm using a Yarn v4.9.2 workspace with some yarn specific features, such as resolutions and patches. When running yarn yarn-audit-fix, we get this output:

Resolve bins
Runtime digest

  isMonorepo true
  bins 
    yarn yarn
    npm npm
  
  versions 
    node v20.17.0
    npm 10.8.2
    yarn 4.9.2
    yaf 10.1.1
    yafLatest 10.1.1
  
  temp /var/folders/gv/dd6fn4tx3gl1wr98gsm_nfn80000gn/T/tempy-a3497b331bc9ba0723a4dc236b7b8866LiaMFZ
  cwd {cwd}
  flags 
    flow patch
    npm-path system
  

Verifying package structure...
Preparing temp assets...
Error: EEXIST: file already exists, symlink '{cwd}{/path/to/dir1}' -> '/var/folders/gv/dd6fn4tx3gl1wr98gsm_nfn80000gn/T/tempy-a3497b331bc9ba0723a4dc236b7b8866LiaMFZ/{/path/to/dir1}'
    at Object.symlinkSync (node:fs:1817:11)
    at Object.createSymlinkSync ({cwd}/node_modules/yarn-audit-fix/node_modules/fs-extra/lib/ensure/symlink.js:59:25)
    at file:///{cwd}/node_modules/yarn-audit-fix/target/esm/cli.mjs:10:3124
    at Array.forEach (<anonymous>)
    at E (file:///{cwd}/node_modules/yarn-audit-fix/target/esm/cli.mjs:10:3061)
    at Te (file:///{cwd}/node_modules/yarn-audit-fix/target/esm/cli.mjs:10:5367)
    at Function.he [as sync] (file:///{cwd}/node_modules/yarn-audit-fix/target/esm/cli.mjs:10:5466)
    at file:///{cwd}/node_modules/yarn-audit-fix/target/esm/cli.mjs:10:7685
    at ModuleJob.run (node:internal/modules/esm/module_job:234:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:473:24) {
  errno: -17,
  code: 'EEXIST',
  syscall: 'symlink',
  path: '{cwd}/{/path/to/dir1}',
  dest: '/var/folders/gv/dd6fn4tx3gl1wr98gsm_nfn80000gn/T/tempy-a3497b331bc9ba0723a4dc236b7b8866LiaMFZ/{/path/to/dir1}'
}
Failure!
Error: EEXIST: file already exists, symlink '{cwd}/{/path/to/dir1}' -> '/var/folders/gv/dd6fn4tx3gl1wr98gsm_nfn80000gn/T/tempy-a3497b331bc9ba0723a4dc236b7b8866LiaMFZ/{/path/to/dir1}'
    at Object.symlinkSync (node:fs:1817:11)
    at Object.createSymlinkSync ({cwd}/node_modules/yarn-audit-fix/node_modules/fs-extra/lib/ensure/symlink.js:59:25)
    at file:///{cwd}/node_modules/yarn-audit-fix/target/esm/cli.mjs:10:3124
    at Array.forEach (<anonymous>)
    at E (file:///{cwd}/node_modules/yarn-audit-fix/target/esm/cli.mjs:10:3061)
    at Te (file:///{cwd}/node_modules/yarn-audit-fix/target/esm/cli.mjs:10:5367)
    at Function.he [as sync] (file:///{cwd}/node_modules/yarn-audit-fix/target/esm/cli.mjs:10:5466)
    at file:///{cwd}/node_modules/yarn-audit-fix/target/esm/cli.mjs:10:7685
    at ModuleJob.run (node:internal/modules/esm/module_job:234:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:473:24) {
  errno: -17,
  code: 'EEXIST',
  syscall: 'symlink',
  path: '{cwd}/{/path/to/dir1},
  dest: '/var/folders/gv/dd6fn4tx3gl1wr98gsm_nfn80000gn/T/tempy-a3497b331bc9ba0723a4dc236b7b8866LiaMFZ/{/path/to/dir1}'
}
node:internal/modules/run_main:129
    triggerUncaughtException(
    ^

Error: EEXIST: file already exists, symlink '{cwd}/{/path/to/dir1}' -> '/var/folders/gv/dd6fn4tx3gl1wr98gsm_nfn80000gn/T/tempy-a3497b331bc9ba0723a4dc236b7b8866LiaMFZ/{/path/to/dir1}'
    at Object.symlinkSync (node:fs:1817:11)
    at Object.createSymlinkSync (/{cwd}/node_modules/yarn-audit-fix/node_modules/fs-extra/lib/ensure/symlink.js:59:25)
    at file:///{cwd}/node_modules/yarn-audit-fix/target/esm/cli.mjs:10:3124
    at Array.forEach (<anonymous>)
    at E (file:///{cwd}/node_modules/yarn-audit-fix/target/esm/cli.mjs:10:3061)
    at Te (file://{cwd}/node_modules/yarn-audit-fix/target/esm/cli.mjs:10:5367)
    at Function.he [as sync] (file:///{cwd}/node_modules/yarn-audit-fix/target/esm/cli.mjs:10:5466)
    at file:///{cwd}/node_modules/yarn-audit-fix/target/esm/cli.mjs:10:7685
    at ModuleJob.run (node:internal/modules/esm/module_job:234:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:473:24) {
  errno: -17,
  code: 'EEXIST',
  syscall: 'symlink',
  path: '{cwd}/{/path/to/dir1}',
  dest: '/var/folders/gv/dd6fn4tx3gl1wr98gsm_nfn80000gn/T/tempy-a3497b331bc9ba0723a4dc236b7b8866LiaMFZ/{/path/to/dir1}'
}

Expected behavior:
The tool should successfully create temporary symlinks and proceed with audit fixing.

Actual behavior:
Tool fails with EEXIST error when trying to create symlinks in temporary directory.

Additional context:

  • This is a monorepo with multiple workspace packages
  • The error occurs consistently on every run
  • Temporary directories appear to be properly cleaned up between runs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions