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

make fails: Expected buildPath to be an absolute path #1501

Open
basz opened this issue Jun 9, 2023 · 9 comments
Open

make fails: Expected buildPath to be an absolute path #1501

basz opened this issue Jun 9, 2023 · 9 comments

Comments

@basz
Copy link
Contributor

basz commented Jun 9, 2023

make fails with "Expected buildPath to be an absolute path".

Built project successfully. Stored in "electron-app/ember-dist".
Making Electron project.
Expected buildPath to be an absolute path

diggin it seem the buildPath is set as 'electron-app' in the make task while forge

a quick fix inside node_modules/ember-electron/lib/tasks/make.js to prove we can get past this.

dir: path.join(process.cwd() , electronProjectPath),
@bendemboski
Copy link
Member

@basz I'm not following here. Does this reproduce with a specific version of electron-forge? A specific version of ember-electron? A specific project setup?

@basz
Copy link
Contributor Author

basz commented Jun 10, 2023

Hi, yes i bit of an unclear report.

It's basically a new test application ember new + ember install ember-electron

npx ember --version
ember-cli: 4.12.1
node: 18.16.0
os: darwin arm64

new project with ember-electron ^4.2.1",
that has @electron/[email protected] and @electron-forge/[email protected]

the electron-app package.json contains

"@electron-forge/cli": "^6.1.1",
"@electron-forge/maker-deb": "^6.1.1",
"@electron-forge/maker-rpm": "^6.1.1",
"@electron-forge/maker-squirrel": "^6.1.1",
"@electron-forge/maker-zip": "^6.1.1",
"@electron-forge/plugin-webpack": "^6.1.1",

electron/rebuild has this requirement quite some time. https://github.com/electron/rebuild/blame/main/src/rebuild.ts#L136

I think @electron-forge/core at some point changed it requirements about the given buildPath argument

@basz
Copy link
Contributor Author

basz commented Jun 13, 2023

does that make sense? Would you accept a PR using cwd + 'electron-app'. If so should I change the utility that produces electronProjectPath or the make.js only.

@bendemboski
Copy link
Member

@basz I'm having trouble understanding/reproducing this. When I follow your steps it seems to work just fine, and when I edit @electron/rebuild in electron-app/node_modules to make it log out this.buildPath it's absolute.

Can you put together a sample repository that reproduces this problem?

@basz
Copy link
Contributor Author

basz commented Jun 14, 2023

yes. try this gem... https://hithub.com/basz/ember-electron-app.git

git clone [email protected]:basz/ember-electron-app.git
cd ember-electron-app
yarn install && yarn install --cwd electron-app
npx ember electron:make

That will result in

Checking dependencies in electron-app...
Environment: production
⠴ building... [Babel: @ember-data/adapter > applyPatches]"warn" is imported from external module "@ember/debug" but never used in "-private/utils/serialize-into-hash.js" and "-private/utils/determine-body-promise.js".
⠼ building... [Babel: @ember-data/store > applyPatches]"registerWaiter" and "unregisterWaiter" are imported from external module "@ember/test" but never used in "-private/store-service.js".
cleaning up...
Built project successfully. Stored in "electron-app/ember-dist".
Making Electron project.
Expected buildPath to be an absolute path

@bendemboski
Copy link
Member

I see, it's related to the webpack plugin -- if you aren't using the webpack plugin it works fine. I think that's probably a bug in the webpack plugin because neither electron-forge nor electron-packager say the path must be absolute, but the webpack plugin passes it straight to @electron/rebuild, which blows up on it. So it might be worth filing an issue and/or PRing a fix in @electron-forge for the webpack plugin.

But given the bug exists, I'd be fine with a PR making it absolute. It looks like we already do that in the electron task so I think we'd just want to add the same path.resolve() to the other tasks (package, make, and publish).

@basz
Copy link
Contributor Author

basz commented Jun 14, 2023

That i do not understand. webpack changes paths how? shouldn't webpack be only packing stuff? are you saying that by using webpack electron-forge is bypassed or something?

I'll make a PR tomorrow to make.js and while i'm at it also package.js and publish.js

Thanks for having a look

@bendemboski
Copy link
Member

The webpack plugin invokes @electron/rebuild itself, presumably because it needs native dependencies to be built for the current platform when running webpack? And this.projectDir is just the dir argument to @electron-forge, with no absolute-ifying or anything.

The core @electron-forge package method invokes @electron/rebuild as well by supplying a hook to electron-packager that does the rebuilding. electron-packager ends up doing everything off in a temp directory, and the buildPath argument that gets passed to @electron/rebuild is always an absolute path pointing into that temp directory.

So when running without the webpack plugin, the rebuild is only invoked from the package method and it is supplied an absolute path. But when running with the webpack plugin, it's invoked from both places (I think), and when invoked from the webpack plugin, blows up if dir is relative.

@basz
Copy link
Contributor Author

basz commented Jun 15, 2023

Thank you for taking the time to explain that. Very useful insightful.

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

2 participants