electron / forge

:electron: A complete tool for building and publishing Electron applications
https://electronforge.io
MIT License
6.35k stars 497 forks source link

ENAMETOOLONG due to recursive copy #3249

Open xiazhvera opened 1 year ago

xiazhvera commented 1 year ago

Pre-flight checklist

Electron Forge version

6.1.1

Electron version

v19.1.9

Operating system

macOS 13.4

Last known working Electron Forge version

No response

Expected behavior

Running electron-forge and package the sample with no error.

Actual behavior

Console Output:

> electron-forge make

✔ Checking your system
✔ Loading configuration
✔ Resolving make targets
  › Making for the following targets: zip
❯ Running package command
  ✔ Preparing to package application
  ✔ Running packaging hooks
    ✔ Running generateAssets hook
    ✔ Running prePackage hook
  ❯ Packaging application
    › Determining targets...
    ❯ Packaging for arm64 on darwin
      ✔ Copying files
      ⠋ Preparing native dependencies
      ◼ Finalizing package
  ◼ Running postPackage hook
◼ Running preMake hook
◼ Making distributables
◼ Running postMake hook

An unhandled rejection has occurred inside Forge:
Error: ENAMETOOLONG: name too long, scandir '/var/folders/5t/c51w9v_d5jn5_z5vvt0x2j_80000gr/T/
electron-packager/darwin-arm64/electron_sample-darwin-arm64-jlmkEx/Electron.app
/Contents/Resources/app/node_modules/<my-local-library>
/Contents/Resources/app/node_modules/<my-local-library>
/Contents/Resources/app/node_modules/<my-local-library>
/Contents/Resources/app/node_modules/<my-local-library>
/Contents/Resources/app/node_modules/<my-local-library>
/Contents/Resources/app/node_modules/<my-local-library>
/Contents/Resources/app/node_modules/<my-local-library>
/Contents/Resources/app/node_modules/<my-local-library>
/Contents/Resources/app/node_modules/<my-local-library>
/Contents/Resources/app/node_modules/<my-local-library>
/Contents/Resources/app/node_modules/<my-local-library>
/Contents/Resources/app/node_modules/<my-local-library>
/Contents/Resources/app/node_modules/<my-local-library>
/Contents/Resources/app/electron_sample-darwin-arm64/electron_sample.app
/Contents/Frameworks/electron_sample Helper (Plugin).app/Contents'

Steps to reproduce

The issue happens when I have a dependency to a local library using a relative path. Sample package.json


  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "build": "./node_modules/.bin/tsc",
    "start": "electron-forge start",
    "package": "electron-forge package",
    "make": "electron-forge make"
  },

// other options.....

  "dependencies": {
    "<my-local-library>": "file:../../../" (relative path to the library),
    },

Simply run npm run make could reproduce the issue.

Additional information

I did not see the issue if I use a version number instead of the relative path for the dependency. However, I would like to to build the application with my local distribution instead of the public version.

Besides, it seems that the issue does not occur when running electron-packager directly:

> npx electron-packager . --overwrite

I was able to package the sample without errors running the commands above.

Electron-packager had a similar issue and it has been fixed in 8.5.2. It could be related or similar: https://github.com/electron/electron-packager/issues/396

clemdesign commented 1 year ago

@xiazhvera Did you find a solution for this issue please ?

xiazhvera commented 1 year ago

@xiazhvera Did you find a solution for this issue please ?

Not yet. While it seems that the issue does not occurs to electron-packager. You could try using it for package.

sparecycles commented 6 months ago

Have you tried adding derefSymlinks: true ?

const config: ForgeConfig = {
  packagerConfig: {
    derefSymlinks: true
  },