serialport / node-serialport

Access serial ports with JavaScript. Linux, OSX and Windows. Welcome your robotic JavaScript overlords. Better yet, program them!
https://serialport.io
MIT License
5.79k stars 1.01k forks source link

prebuild-install via electron-builder gets 404 when downloading windows bindings (but not Mac) #1994

Closed iamcam closed 4 years ago

iamcam commented 4 years ago

When attempting to build electron with electron-build for windows via the docker image, there's an issue with getting a 404 when attempting to load the windows bindings from GitHub. The Mac version builds just fine, as does linux from the Docker image.

In Docker, If I manually download the bindings from the releases the copy the file name it missed (eg the has-prefixed filename) into _prebuilds folder, it builds fine. It appears to use the prebuilt binary on the Mac side as well.

    prebuild-install WARN install prebuilt binaries enforced with --force!
    prebuild-install WARN install prebuilt binaries may be out of date!
    prebuild-install info looking for cached prebuild @ /Users/XXXXXX/.npm/_prebuilds/ac1814-bindings-v8.0.4-electron-v75-win32-x64.tar.gz
    prebuild-install http request GET https://github.com/serialport/node-serialport/releases/download/v8.0.4/bindings-v8.0.4-electron-v75-win32-x64.tar.gz
    prebuild-install http 404 https://github.com/serialport/node-serialport/releases/download/v8.0.4/bindings-v8.0.4-electron-v75-win32-x64.tar.gz
    prebuild-install WARN install No prebuilt binaries found (target=7.1.1 runtime=electron arch=x64 libc= platform=win32)

Is there something missing in the prerebuild configuration where its looking for the wrong URL or something?

Any help would be greatly appreciated.

therealtbs commented 4 years ago

Looking at the URLs that are requested, prebuild-install seems to be looking for a release called v8.0.4, however the release in this repo with the artifacts is called @serialport/bindings@8.0.4.

I'm not sure if this is something that can be easily fixed on the side of the serialport team, however I used the following manual workaround:

  1. Look at the logged output. The following information is important:
    1. the line 'looking for cached prebuild @' note the path following the @-sign
    2. the line 'request GET' note the filename at the end of the URL.
  2. Download the file from the correct URL to the location from step 1. I used curl
    curl -L "https://github.com/serialport/node-serialport/releases/download/%40serialport%2Fbindings%408.0.4/$FILENAME" -o "$PATH_TO_CACHED"
JeffJassky commented 4 years ago

This is still happening. Anybody know what the issue is?

reconbot commented 4 years ago

However electron-builder

{
  "scripts": {
    "install": "prebuild-install --tag-prefix @serialport/bindings@ || node-gyp rebuild",
  }
}

I just landed #2003 (thanks @s00d!) which gives electron-builder a way to pickup the tag prefix by default, unknown why it's not being passed through on windows, I'd open an issue with them.

reconbot commented 4 years ago

I published @serialport/bindings@8.0.6 the binaries are building now, please try it out!

JesseWeb commented 4 years ago

it still get 404 when I building Windows app on Mac using electron-builder.

s00d commented 4 years ago

it still get 404 when I building Windows app on Mac using electron-builder.

Best way it use a docker container electronuserland/builder:wine for build windows and Linux multi-platform-build

JesseWeb commented 4 years ago

it still get 404 when I building Windows app on Mac using electron-builder.

Best way it use a docker container electronuserland/builder:wine for build windows and Linux multi-platform-build

I am testing electronuserland/builder:wine for building win64 application ,still get this error.

 electron-builder  version=22.2.0 os=4.9.184-linuxkit
  • loaded configuration  file=package.json ("build" field)
  • electron-rebuild not required if you use electron-builder, please consider to remove excess dependency from devDependencies

To ensure your native dependencies are always matched electron version, simply add script `"postinstall": "electron-builder install-app-deps" to your `package.json`
  • writing effective config  file=build/builder-effective-config.yaml
  • executing node-gyp rebuild  arch=x64
  • rebuilding native dependencies  dependencies=@serialport/bindings@8.0.6 platform=win32 arch=x64
  • install prebuilt binary  name=@serialport/bindings version=8.0.6 platform=win32 arch=x64
  ⨯ cannot build native dependency  reason=prebuild-install failed with error and build from sources not possible because platform or arch not compatible
                                    cause=exit status 1
                                    errorOut=prebuild-install info begin Prebuild-install version 5.3.3
    prebuild-install info looking for cached prebuild @ /root/.npm/_prebuilds/64b73e-bindings-v8.0.6-electron-v75-win32-x64.tar.gz
    prebuild-install http request GET https://github.com/serialport/node-serialport/releases/download/v8.0.6/bindings-v8.0.6-electron-v75-win32-x64.tar.gz
    prebuild-install http 404 https://github.com/serialport/node-serialport/releases/download/v8.0.6/bindings-v8.0.6-electron-v75-win32-x64.tar.gz
    prebuild-install WARN install No prebuilt binaries found (target=7.1.7 runtime=electron arch=x64 libc= platform=win32)

                                    command=/usr/local/bin/node /project/node_modules/prebuild-install/bin.js --platform=win32 --arch=x64 --target=7.1.7 --runtime=electron --verbose --force
                                    workingDir=/project/node_modules/@serialport/bindings
  ⨯ /project/node_modules/app-builder-lib/node_modules/app-builder-bin/linux/x64/app-builder exited with code ERR_ELECTRON_BUILDER_CANNOT_EXECUTE  stackTrace=
                                                                                                                                                     Error: /project/node_modules/app-builder-lib/node_modules/app-builder-bin/linux/x64/app-builder exited with code ERR_ELECTRON_BUILDER_CANNOT_EXECUTE
                                                                                                                                                         at ChildProcess.childProcess.once.code (/project/node_modules/app-builder-lib/node_modules/builder-util/src/util.ts:239:14)
                                                                                                                                                         at Object.onceWrapper (events.js:285:13)
                                                                                                                                                         at ChildProcess.emit (events.js:197:13)
                                                                                                                                                         at maybeClose (internal/child_process.js:984:16)
                                                                                                                                                         at Process.ChildProcess._handle.onexit (internal/child_process.js:265:5)
error Command failed with exit code 1.
s00d commented 4 years ago

I am testing electronuserland/builder:wine for building win64 application ,still get this error.

Sorry its my mistake, I used the format of the old version. I make new Pull request 2008

You can try to do so before installing and building:

echo \\{ \\\"tag-prefix\\\": \\\"@serialport/bindings@\\\" }\\ > ./node_modules/@serialport/bindings/.prebuild-installrc
reconbot commented 4 years ago

Where can I find the docs on that?

s00d commented 4 years ago

here and here, but ${appname} it's prebuild-install

I found information here

typester commented 4 years ago

I confirmed that the fix in #2008 resolved this issue, but there is no released version that is included this fix. I hope it will be released soon.

jsgv commented 4 years ago

Any reason why there has not been release for this?

reconbot commented 4 years ago

No reason but my day job keeping me busy.

Successfully published:

let me know how it works

mettz commented 4 years ago

Hi, I run into the same issue because version 8 of Electron uses NODE_MODULE_VERSION 76 and most recent serialport release is for version 75. Here's the output from electron-builder

prebuild-install http request GET https://github.com/serialport/node-serialport/releases/download/@serialport/bindings@8.0.7/bindings-v8.0.7-electron-v76-linux-x64.tar.gz
prebuild-install http 404 https://github.com/serialport/node-serialport/releases/download/@serialport/bindings@8.0.7/bindings-v8.0.7-electron-v76-linux-x64.tar.gz
prebuild-install WARN install No prebuilt binaries found (target=8.0.0 runtime=electron arch=x64 libc= platform=linux)

To make it work I downgraded my app to version 7.1.12 of electron but I made this post to informs core developers of the problem.

mkurczewski commented 4 years ago

Hi, I run into the same issue because version 8 of Electron uses NODE_MODULE_VERSION 76 and most recent serialport release is for version 75. Here's the output from electron-builder

prebuild-install http request GET https://github.com/serialport/node-serialport/releases/download/@serialport/bindings@8.0.7/bindings-v8.0.7-electron-v76-linux-x64.tar.gz
prebuild-install http 404 https://github.com/serialport/node-serialport/releases/download/@serialport/bindings@8.0.7/bindings-v8.0.7-electron-v76-linux-x64.tar.gz
prebuild-install WARN install No prebuilt binaries found (target=8.0.0 runtime=electron arch=x64 libc= platform=linux)

To make it work I downgraded my app to version 7.1.12 of electron but I made this post to informs core developers of the problem.

This is the issue I reported few days ago https://github.com/serialport/node-serialport/issues/2031

mkurczewski commented 4 years ago

Hi @reconbot, what's the approximate date when we can see the update for Electron 8?

reconbot commented 4 years ago

What needs to be done to support it?

mkurczewski commented 4 years ago

@reconbot As per https://github.com/serialport/node-serialport/issues/2031 we just need bindings for electron-v76

ghost602 commented 4 years ago

I set it back from version 8 to 7. I am using it now.

reconbot commented 4 years ago

Per https://github.com/serialport/node-serialport/issues/2031#issuecomment-626324067 serialport@9 now ships with ABI v76 for electron

And just to note @mkurczewski getting it building probably took about 8 hours of work, the ecosystem is super brittle, I'm thankful for you raising the issues, but I want you to know what goes into it.

For anyone who finds this thread and wants to know how to build the binaries themselves. See https://github.com/serialport/node-serialport/issues/2031#issuecomment-616551473

Electron remains a pain to support but it's obviously a wonderful use case. If anyone wants to help make it easier to use with serialport, please consider updating the documents and contributing to https://github.com/serialport/website/blob/master/docs/guide-installation.md#electron

stale[bot] commented 4 years ago

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.