prebuild / prebuild

A command line tool for easily doing prebuilds for multiple version of node on a specific platform

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Building for Electron 5.0.0 instead builds for Node 5.0.0

todbot opened this issue · comments

If this command is run:

prebuild -r electron -t 5.0.0

It actually builds for Node v5.0.0. However, this command builds for Electron correctly:

prebuild -r electron -t 5.0.6

And since the former command seems to be what is run when doing prebuild --all, this means that prebuild fails for Electron v5.

Those commands are exactly the same?

There have been similar reports (I can't find them just now) where it turned out to be a node-gyp cache issue.

Apologies, copy and paste error, the second line should read:

prebuild -r electron -t 5.0.6

I updated the initial comment to match.

And yes, it does appear to be a cache issue, so if you do prebuild --all and node-abi has this for its supported targets:

var supportedTargets = [
  {runtime: 'node', target: '5.0.0', abi: '47', lts: false}
...
  {runtime: 'electron', target: '5.0.0', abi: '70', lts: false}

when the header files are downloaded they are both put into the directory ~/.node_gyp/5.0.0.

Thus, prebuild --all will first build for Node v5 then when building for Electron v5, it just uses the same ~/.node_gyp/5.0.0 even though it appears to be downloading headers for Electron.

Is this a node-gyp bug? I poked around but don't see how one specifies runtime to node-gyp

Is this a node-gyp bug?

I think so. If -r is electron we pass this to node-gyp:

prebuild/gypbuild.js

Lines 19 to 22 in bb952c7

if (opts.runtime === 'electron') {
args.push('--runtime=electron')
args.push('--dist-url=https://atom.io/download/electron')
} else if (opts.runtime === 'node-webkit') {

Yes, I was seeing that as well. When one does the following:

rm -rf ~/.node-gyp  prebuilds
prebuild -r node -t 5.0.0 
prebuild -r electron -t 5.0.0 

then both are built with NODE_VERSION 47. If you look in ~/.node-gyp you'll see there's only one directory, named "5.0.0".

Why doesn't node-gyp attach the runtime to the directory name? (assuming this is still node-gyp's issue, that is. I suppose prebuild could hack around it by modifying "devDir()" in gyp.js, but I'm sure that'll break other things)

I admit to not knowing much about node-gyp. Is there a quick way I can pull out the exact commands being issued to node-gyp from prebuild to help formulate a bug report to them?

Oh no wait, node-gyp doesn't take a --runtime flag.
So I guess it's up to prebuild to scope the downloads. e.g. if it executes node-gyp something like:

node-gyp  rebuild --target=5.0.0 --target_arch=x64 --runtime=electron --dist-url=https://atom.io/download/electron --devdir ~/.node-gyp/electron

Then Node v5 lives in ~/.node-gyp/5.0.0 and
Electron v5 lives in ~/.node-gyp/electron/5.0.0

Would this work?

Is there a quick way I can pull out the exact commands being issued to node-gyp from prebuild to help formulate a bug report to them?

prebuild --verbose might trigger node-gyp to print its arguments.

Maybe we can float the idea with node-gyp to change the cache location based on --runtime. Surely other tools that wrap node-gyp have the same problem.

Except that I don't think node-gyp has any use for a runtime switch. I will open an issue and see what they say. Thanks for thinking through this with me.

@ralphtheninja do you recall if node-gyp used --runtime in the past, and if not, why we are passing that parameter to node-gyp?

I don't recall why we pass them.

Fixed in 9.1.1