Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: EEXIST: file already exists, symlink 'Versions/Current/Electron Framework' with yarn classic #188

Open
eXhumer opened this issue Sep 17, 2024 · 1 comment

Comments

@eXhumer
Copy link

eXhumer commented Sep 17, 2024

I use yarn classic (v1.22.22) as my package manager and I keep receiving Error: EEXIST: file already exists, symlink 'Versions/Current/Electron Framework' -> '/Users/exhumer/Projects/exviewer/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Electron Framework' when I try yarn upgrade or yarn sometimes. If I re-run the same command twice, the problem doesn't appear and finishes the process without any error. It seems like if an existing symlink exist on macOS with the yarn package manager specifically, it fails the install script. The issue doesn't seem to appear if I use the npm package manager instead.

[4/4] 🔨  Rebuilding all packages...
error /Users/exhumer/Projects/exviewer/node_modules/electron: Command failed.
Exit code: 1
Command: node install.js
Arguments: 
Directory: /Users/exhumer/Projects/exviewer/node_modules/electron
Output:
Error: EEXIST: file already exists, symlink 'Versions/Current/Electron Framework' -> '/Users/exhumer/Projects/exviewer/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Electron Framework'
    at async Object.symlink (node:internal/fs/promises:1001:10)
    at async Extractor.extractEntry (/Users/exhumer/Projects/exviewer/node_modules/extract-zip/index.js:130:7)
    at async ZipFile.<anonymous> (/Users/exhumer/Projects/exviewer/node_modules/extract-zip/index.js:65:11)
info Visit https://yarnpkg.com/en/docs/cli/upgrade for documentation about this command.

Is there any consideration to maybe delete all contents in the distPath before trying to extract files into it? This would prevent this issue from appearing.

function extractFile (zipPath) {
const distPath = process.env.ELECTRON_OVERRIDE_DIST_PATH || path.join(__dirname, 'dist');
return extract(zipPath, { dir: path.join(__dirname, 'dist') }).then(() => {
// If the zip contains an "electron.d.ts" file,
// move that up
const srcTypeDefPath = path.join(distPath, 'electron.d.ts');
const targetTypeDefPath = path.join(__dirname, 'electron.d.ts');
const hasTypeDefinitions = fs.existsSync(srcTypeDefPath);
if (hasTypeDefinitions) {
fs.renameSync(srcTypeDefPath, targetTypeDefPath);
}
// Write a "path.txt" file.
return fs.promises.writeFile(path.join(__dirname, 'path.txt'), platformPath);
});
}

@eXhumer
Copy link
Author

eXhumer commented Sep 17, 2024

Adding fs.rmSync(distPath, { recursive: true, force: true }); before the calling extract method seems to fix the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant