electron / electron/forge

package command fails when using yarn workspaces with native dependency

Open
#3,734 4 comments 0 reactions 0 assignees View on GitHub
bug plugin/vite status/confirmed workspaces
Dominant language
TypeScript
Stars
7.1k
Forks
641
Avg merge
3d 1h
Merged PRs (30d)
30

Description

### Pre-flight checklist

- [x] I have read the [contribution documentation](https://github.com/electron/forge/blob/main/CONTRIBUTING.md) for this project.
- [x] I agree to follow the [code of conduct](https://github.com/electron/electron/blob/main/CODE_OF_CONDUCT.md) that this project uses.
- [x] I have searched the issue tracker for a bug that matches the one I want to file, without success.

### Electron Forge version

7.5.0

### Electron version

v32.1.2

### Operating system

MacOS 14.7

### Last known working Electron Forge version

_No response_

### Expected behavior

Electron-forge should dereference symlinks (or provide an option to) when copying the package.

### Actual behavior

It does not dereference the symlinked dependencies leading to error:

```
✔ Copying files

An unhandled rejection has occurred inside Forge:
Error: ENOENT: no such file or directory, stat '/private/var/folders/bb/j1658g0d50gfcvgq3cm6cj1c0000gn/T/electron-packager/tmp-usVZSn/Electron.app/Contents/Resources/app/node_modules/asr'
```

### Steps to reproduce

I'm using yarn (`4.5.0`) workspaces and I have packages
```
- packages
- application (electron app)
- asr (a native dependency)
```

`asr` is a dependency of `application`.

When I run `yarn package` it fails with the following error:

```
✔ Copying files

An unhandled rejection has occurred inside Forge:
Error: ENOENT: no such file or directory, stat '/private/var/folders/bb/j1658g0d50gfcvgq3cm6cj1c0000gn/T/electron-packager/tmp-usVZSn/Electron.app/Contents/Resources/app/node_modules/asr'
```

I see the dir it is stat'ing is a symlink:
```
ls -al /private/var/folders/bb/j1658g0d50gfcvgq3cm6cj1c0000gn/T/electron-packager/tmp-usVZSn/Electron.app/Contents/Resources/app/node_modules/asr
lrwxr-xr-x@ 1 matt staff 9 9 Oct 00:19 /private/var/folders/bb/j1658g0d50gfcvgq3cm6cj1c0000gn/T/electron-packager/tmp-usVZSn/Electron.app/Contents/Resources/app/node_modules/asr -> ../../asr
```

A workaround is running:
```
rm -rf ./node_modules/asr && cp -L -r ../asr ./node_modules/asr
```

If I run this and then rerun `yarn package`. The application will build correctly.

Is there any way to make electron-force understand it should dereference this symlink when copying the package?

---

I see a similar issue at https://github.com/electron/forge/issues/3624 with a suggested fix to the vite plugin. Would you be happy to take a PR for this?

### Additional information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.