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

Prebuild-install paths are hard to use / lack documentation for multi-platform use #1898

Closed
Josverl opened this issue Jul 5, 2019 · 9 comments

Comments

@Josverl
Copy link

Josverl commented Jul 5, 2019

Summary of Problem

(Please answer all 3)

  • What are you trying to do?
    In trying to use prebuild-install to retrieve the bindings for multiple electron versions & platforms
    C:\develop\<project>\node_modules\@serialport\bindings>.\node_modules\.bin\prebuild-install.cmd --runtime electron --target 4.2.5 --arch x64 --platform win32 --verbose

  • What happens?
    prebuild-install is not able to find

prebuild-install info begin Prebuild-install version 5.3.0
prebuild-install info looking for cached prebuild @ C:\Users\josverl\AppData\Roaming\npm-cache\_prebuilds\e9e8d7-bindings-v2.0.8-electron-v69-win32-x64.tar.gz
prebuild-install http request GET https://github.com/node-serialport/node-serialport/releases/download/v2.0.8/bindings-v2.0.8-electron-v69-win32-x64.tar.gz
prebuild-install http 404 https://github.com/node-serialport/node-serialport/releases/download/v2.0.8/bindings-v2.0.8-electron-v69-win32-x64.tar.gz
prebuild-install WARN install No prebuilt binaries found (target=4.2.5 runtime=electron arch=x64 libc= platform=win32)

the same happens also when using the default platform, version & architecture

C:\develop\pymakr-vsc\node_modules\@serialport\bindings>.\node_modules\.bin\prebuild-install.cmd --verbose
prebuild-install info begin Prebuild-install version 5.3.0
prebuild-install info looking for cached prebuild @ C:\Users\josverl\AppData\Roaming\npm-cache\_prebuilds\89c4e1-bindings-v2.0.8-node-v64-win32-x64.tar.gz
prebuild-install http request GET https://github.com/node-serialport/node-serialport/releases/download/v2.0.8/bindings-v2.0.8-node-v64-win32-x64.tar.gz
prebuild-install http 404 https://github.com/node-serialport/node-serialport/releases/download/v2.0.8/bindings-v2.0.8-node-v64-win32-x64.tar.gz
prebuild-install WARN install No prebuilt binaries found (target=10.15.1 runtime=node arch=x64 libc= platform=win32)

this makes it very hard and troublesome to build and distribute multi-platform packages
also due to quite sparse documentation it is hard to find out why thinks are not working.

  • What should have happened?

The prebuilds should be found , downloaded, and subsequently installed

it would be even better to have documentation on how to install / download for multiple platforms ( i.e. prepackage for 3 platforms for electron 4.2.5.

Code to Reproduce the Issue

see above ..

possible cause

Comparing the URLs used by prebuild-install and the URLs currently used there appreatrs to be 2 mismatches :

what link
prebuild-install https://github.com/node-serialport/node-serialport/releases/download/v2.0.8/bindings-v2.0.8-electron-v69-win32-x64.tar.gz
releases https://github.com/serialport/node-serialport/releases/download/%40serialport%2Fbindings%402.0.8/bindings-v2.0.8-electron-v69-win32-x64.tar.gz

I notice that in the path there are in 2 place in the path that are incorrect

where prebuild-install git hosted
path root folder node-serialport serialport
version folder v2.0.8 @serialport/bindings@2.0.8

Versions, Operating System and Hardware

  • SerialPort@bindings@2.0.7 and 2.0.8
  • Node.js - v10.15.1
  • Windows 10.0.18362.10000
  • Hardware : n/a
@Josverl
Copy link
Author

Josverl commented Jul 5, 2019

explaining the problem made me look at options to change the version prefix

it turns out there is an option in prebuild-install to do that :-) : --tag-prefix
--tag-prefix @serialport/bindings@

C:\develop\<project>\node_modules\@serialport\bindings>node .\node_modules\prebuild-install\bin.js --runtime electron --target 4.2.5 --arch x64 --platform darwin --tag-prefix @serialport/bindings@ --verbose

This results in a successful install of the binding for electron-mac-x64 build on a windows machine

prebuild-install info begin Prebuild-install version 5.3.0
prebuild-install info looking for cached prebuild @ C:\Users\josverl\AppData\Roaming\npm-cache\_prebuilds\6a8d11-bindings-v2.0.8-electron-v69-darwin-x64.tar.gz
prebuild-install http request GET https://github.com/node-serialport/node-serialport/releases/download/@serialport/bindings@2.0.8/bindings-v2.0.8-electron-v69-darwin-x64.tar.gz
prebuild-install http 200 https://github.com/node-serialport/node-serialport/releases/download/@serialport/bindings@2.0.8/bindings-v2.0.8-electron-v69-darwin-x64.tar.gz
prebuild-install info downloading to @ C:\Users\josverl\AppData\Roaming\npm-cache\_prebuilds\6a8d11-bindings-v2.0.8-electron-v69-darwin-x64.tar.gz.22648-63b6b0d443a6b.tmp
prebuild-install info renaming to @ C:\Users\josverl\AppData\Roaming\npm-cache\_prebuilds\6a8d11-bindings-v2.0.8-electron-v69-darwin-x64.tar.gz
prebuild-install info unpacking @ C:\Users\josverl\AppData\Roaming\npm-cache\_prebuilds\6a8d11-bindings-v2.0.8-electron-v69-darwin-x64.tar.gz
prebuild-install info unpack resolved to C:\develop\<project>\node_modules\@serialport\bindings\build\Release\bindings.node
prebuild-install info install Successfully installed prebuilt binary!

Note that there is still a path mismatch , but apparently this is resolved somehow so I won't worry about that anymore.

Still , given the time I have spend to figure this out, I think this calls for some additional documentation.
this is seconded by : #1895, #1853, ,and to some extent by #1891 , #1874,

If there is another or a simpler solution to package serialport in a single multi-platform module, while still using the prebuilts, please let me know.

Note2:
node-gyp is never the answer with multi-platform . It is highly unreliable on windows , and it has a very very footprint even it does. Its OK for Dev , but not for a package.

@Josverl Josverl changed the title Prebuild-install paths are broken, possibly due to repro move Prebuild-install paths are hard to use / lack documentation for multi-platform use Jul 5, 2019
@sacha67
Copy link

sacha67 commented Jul 8, 2019

Had the same problem when I upgraded serialport in my project.
@Josverl Thank you for the solution.

@JuanM04
Copy link

JuanM04 commented Jul 16, 2019

So, how do I solve it? When I run electron-build -w on mac, prebuild tries to fetch and the build stops

@Josverl
Copy link
Author

Josverl commented Jul 16, 2019

So, how do I solve it? When I run electron-build -w on mac, prebuild tries to fetch and the build stops

@JuanM04, I do not see how this is related to the issue I raised, and your description is quite sparse. So I cannot help you.

@JuanM04
Copy link

JuanM04 commented Jul 16, 2019

Nevermind, I solved it. I just commented here because hours of trying to fix it brought me here. What happened is that electron-builder uses prebuild-install when building an Electron app. There is somewhere an issue related to this, and I'm also going to post my solution there.

I just created a .prebuild-installrc to do it automatically for me:

"scripts": {
  "postinstall": "echo \"tag-prefix=@serialport/bindings@\" > ./node_modules/@serialport/bindings/.prebuild-installrc && electron-builder install-app-deps"
}

@Josverl
Copy link
Author

Josverl commented Jul 26, 2019

I have create a script to download bindings for multiple versions & platforms and store them in a simple file structure, so they can be used to load the module dynamically.

https://github.com/Josverl/pymakr-vsc/blob/fix/SerialMultiPlatform/scripts/mp-download.ps1

its in powershell as i find that simpler to write / debug , but I think it can be transposed to just any other scripting language

@Josverl
Copy link
Author

Josverl commented Aug 28, 2019

It should be noted that it appears that a number of the published builds are actually incorrect
#1920

@phhoef
Copy link

phhoef commented Sep 15, 2019

@Josverl I am using macOS, but I've the same issue.
Thanks for your effort for describing your solution.

Unfortunately, I do not completely understand, what you've done.
You ran this command C:\develop\<project>\node_modules\@serialport\bindings>node .\node_modules\prebuild-install\bin.js --runtime electron --target 4.2.5 --arch x64 --platform darwin --tag-prefix @serialport/bindings@ --verbose and the important point is the --tag-prefix-flag, right?
Do you run this after every yarn or npm install? Is it sufficient to run it once?
Did you find a way to integrate it into a script of the package.json?
To cut a long story short: Is there a way to properly integrate your solution in order to make it work every time without any additional command execution?

Thanks

@stale
Copy link

stale bot commented Nov 14, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in a week no further activity occurs. Feel free continue the discussion or ask for a never-stale label to keep it open. If this is a support issue, consider sharing it on stack overflow to get more eyes on your problem.

@stale stale bot added the stale-issue label Nov 14, 2019
@stale stale bot closed this as completed Nov 21, 2019
@lock lock bot locked as resolved and limited conversation to collaborators May 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

4 participants