-
-
Notifications
You must be signed in to change notification settings - Fork 230
Open
Description
When running corepack enable the links are not properly updated.
I updated the node version with brew and now all symlinks previously enabled with corepack are broken.
MacBookPro:bin mk42$ corepack disable
MacBookPro:bin mk42$ corepack enable
Internal Error: EEXIST: file already exists, symlink '../Cellar/node@22/22.20.0_2/lib/node_modules/corepack/dist/yarn.js' -> '/opt/homebrew/bin/yarn'
at async Object.symlink (node:internal/fs/promises:1008:10)
at async EnableCommand.generatePosixLink (/opt/homebrew/Cellar/node@22/22.20.0_2/lib/node_modules/corepack/dist/lib/corepack.cjs:23168:5)
at async Promise.all (index 2)
at async EnableCommand.execute (/opt/homebrew/Cellar/node@22/22.20.0_2/lib/node_modules/corepack/dist/lib/corepack.cjs:23151:5)
at async EnableCommand.validateAndExecute (/opt/homebrew/Cellar/node@22/22.20.0_2/lib/node_modules/corepack/dist/lib/corepack.cjs:20258:22)
at async _Cli.run (/opt/homebrew/Cellar/node@22/22.20.0_2/lib/node_modules/corepack/dist/lib/corepack.cjs:21195:18)
at async Object.runMain (/opt/homebrew/Cellar/node@22/22.20.0_2/lib/node_modules/corepack/dist/lib/corepack.cjs:23654:19)
The issue seems to be here:
corepack/sources/commands/Enable.ts
Lines 81 to 100 in 0b492c9
| async generatePosixLink(installDirectory: string, distFolder: string, binName: string) { | |
| const file = path.join(installDirectory, binName); | |
| const symlink = path.relative(installDirectory, path.join(distFolder, `${binName}.js`)); | |
| if (fs.existsSync(file)) { | |
| const currentSymlink = await fs.promises.readlink(file); | |
| if (binName.includes(`yarn`) && corepackUtils.isYarnSwitchPath(await fs.promises.realpath(file))) { | |
| console.warn(`${binName} is already installed in ${file} and points to a Yarn Switch install - skipping`); | |
| return; | |
| } | |
| if (currentSymlink !== symlink) { | |
| await fs.promises.unlink(file); | |
| } else { | |
| return; | |
| } | |
| } | |
| await fs.promises.symlink(symlink, file); |
fs.existsSync(file) returns false as the file this symlink is pointing to does not exist. This check should be true to remove the broken symlink
Metadata
Metadata
Assignees
Labels
No labels