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

Yarn local workspaces no longer working - fails on Preparing native dependencies #3597

Open
3 tasks done
joezappie opened this issue May 13, 2024 · 3 comments
Open
3 tasks done

Comments

@joezappie
Copy link

joezappie commented May 13, 2024

Pre-flight checklist

  • I have read the contribution documentation for this project.
  • I agree to follow the code of conduct that this project uses.
  • I have searched the issue tracker for a bug that matches the one I want to file, without success.

Electron Forge version

7.4.0

Electron version

30.0.3

Operating system

Windows 10

Last known working Electron Forge version

7.2.0

Expected behavior

I had an issue #3388 about using yarn workspaces for a monorepo where the my electron app depends on other local workspace packages. At the time 7.2.0 was out and @easternmotors was able to show me how to configure yarn to get it to build using the workspaces: protocol.

Upgrading that test repo to 7.4.0, it now crashes on the "Preparing native dependencies" step.
image

I'm new to yarn but it doesn't appear to output any error on the crash. Running make with npm instead crashes on the same step and provides an unhelp generic error:

npm ERR! Lifecycle script `make` failed with error:
npm ERR! Error: command failed
npm ERR!   in workspace: [email protected]
npm ERR!   at location: C:\Users\joeja\projects\yarn-electron-workspaces\packages\electron-app

This test repo is just an electron app created with the command yarn create electron-app electron-app --template vite and a local workspace test package added to its dependencies, so very easy to repeat.

Actual behavior

It should build when a local workspace is used as a dependency

Steps to reproduce

I have two repo to simulate it was working on 7.2 and failing on 7.4:

7.4.0 Fail Test Repo

  1. Clone test repo using electron-forge 7.4.0:
    https://github.com/joezappie/yarn-electron-workspaces/tree/bug/electron-forge-make
  2. Run `yarn workspace electron-app make'
  3. See that it crashes on the Preparing native dependencies step

7.2.0 Success Test Repo

  1. Clone test repo using electron-forge 7.2.0:
    https://github.com/joezappie/yarn-electron-workspaces
  2. Run `yarn workspace electron-app make'
  3. See that it successfully builds

Additional information

I tried 7.3.0/7.3.1 but I run into an an error saying electron-forge/plugin-vite needed to be in my dev dependencies, despite being in it so I gave up on those versions. Not sure if its 7.3 or 7.4 that broke the module resolution of local workspaces dependencies.

Is there now a different way of needing to do this?

@easternmotors
Copy link

@joezappie hey I saw your issue but I have been travelling and haven't been able to test this out. I can say I do have it working with 7.4.0 without any major changes. I'll let you know if I can repro/fix using your minimal repo when I get a chance.

Let me know if you've solved the issue already though!

@easternmotors
Copy link

@joezappie I actually misspoke in my last post, I forgot we refactored our app in a way that we don't actually cross-reference Yarn workspaces anymore in our app which is why I haven't seen the issue. Regardless I was curious and wanted to dive into the issue a little deeper.

It seemed to be failing on the package command (which is a subset of the make command). To get some better output, I ran the following command:

# Basic debugging output
DEBUG=1 yarn workspace electron-app run package

# electron-packager debugging output (this gave me more info once I narrowed it down to electron-packager)
DEBUG=electron-packager yarn workspace electron-app run package

Running either of those gave me a better error message:

An unhandled rejection has occurred inside Forge:
Error: EPERM: operation not permitted, symlink 'C:\...\yarn-electron-workspaces\packages\test' -> 'C:\Users\...\AppData\Local\Temp\electron-packager\tmp-I0C8Ti\node_modules\test-package'

I have run into weird permission errors on Windows before so I hopped over to my MacBook Pro and I confirmed that the command is working as expected on Mac. So, I hopped back to my PC and was trying a bunch of different things to no avail. I finally ended up trying to run Git Bash as administrator and got it to work.

I'm not sure exactly what change in electron-forge and/or electron-packager necessitated this change but hopefully it give you a workaround for the situation.

Just for your SA, the other things I tried on Windows that didn't end up working were messing with Yarn's winLinkType config option and setting electron-packager's tmpdir option to false in the forge.config.js. The latter might be a viable option once this issue is resolved.

I hope this helps and let me know if launching your terminal with administrator privileges works and if that's a viable solution for you.

@noseworthy
Copy link

I'm having a very similar issue, but I'm on an ARM Mac. We're using yarn workspaces as well and I'm trying to build a macos .dmg using electron-forge but the packager is failing at the same step when it tries to stat my workspace dependency:

An unhandled rejection has occurred inside Forge:
Error: ENOENT: no such file or directory, stat '/private/var/folders/pr/SOME_RANDOM_VALUE/T/electron-packager/tmp-ANOTHER_RANDOM_VALUE/Electron.app/Contents/Resources/app/node_modules/MY_WORKSPACE_MODULE'

The file specified by the above path is a symlink, and it resolves to a relative path from the root of the electron app's workspace. Since the dependency was copied into this temporary directory for packaging, the relative path is no longer valid and the symlink doesn't resolve.

Is there something I'm missing here? I've been banging my head against this for ages. I would've expected the packager to copy the actual resolved directory to the temp directory, not the symlink.

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

3 participants