atom / node-keytar

Native Password Node Module
https://atom.github.io/node-keytar
MIT License
1.37k stars 193 forks source link

Keytar + Electron: Works on OSX, "Error: %1 is not a valid Win32 application" on Windows #39

Open tylerjames opened 8 years ago

tylerjames commented 8 years ago

I added Keytar to my Electron app and ran electron-rebuild on it. After packaging the resulting app works just fine on OSX, but when I try to run the .exe on windows I get the dreaded:

"Error: %1 is not a valid Win32 application"

I read that this might be due to the module being built for x64 which makes it not run on an ia32 environment.

So I installed node-gyp and rebuilt the module using:

HOME=~/.electron-gyp node-gyp rebuild --target=0.36.2 --arch=ia32 --dist-url=https://atom.io/download/atom-shell

It built fine but I got the same result after packaging the app for win32.

Is there any way to get this running on a 32-bit windows environment? Am I doing something wrong when in rebuilding step?

I can see that keytar is at least included inside the app folder after packaging. Is there a way to tell what architecture keytar was built for?

Thanks in advance for any help.

felixrieseberg commented 8 years ago

I'm running into the same issue, but I'm also not sure how to fix it.

craftzdog commented 8 years ago

i got same error and managed that. You may run 32bit of keytar on 64bit of electron. To check which arch the node(electron) is running on:

console.log(process.arch);

also check out electron-rebuild for building module instead of using node-gyp directly.

HanaHsu commented 8 years ago

rebuild with electron-rebuild works for me

.\node_modules\.bin\electron-rebuild.cmd -w keytar -p -f
surajreddy commented 7 years ago

I am still running into this while building a windows package on a Mac OS. Is there a specific way keytar needs to be rebuilt if doing this?

AndreBlumenthal commented 7 years ago

same error for me

gitmitch commented 7 years ago

In my experience, I had to build the Windows version of my electron app on windows in order for modules to be compiled and packaged properly. So, I built my package for Mac on Mac, and the windows app on windows.

I don't think this is necessary if you don't have any native modules. In that case you can build and package on one platform for all platforms. But for native modules, I was only able to get it to work by building and packaging on the same platform that I'm targeting.

I've heard that you might be able to use wine on mac to build and compile native modules into electron apps. I tried it, but it didn't work for me.

Microsoft provides free VM you can use for these purposes

surajreddy commented 7 years ago

Running electron-rebuild with yarn electron-rebuild seemed to do the trick for us in the end. We were trying to run electron-rebuild with a specific version, which did not seem to play well with keytar.

TL;DR:

xp6530 commented 7 years ago

same error

levinunnink commented 7 years ago

Getting the same error. electron-rebuild had no results.

surajreddy commented 7 years ago

@xp6530 @levinunnink can you try deleting your node_modules directory and trying again?

popod commented 7 years ago

As I read here, there is nothing to do to compile an electron app for Windows from macOS and compile the Windows version should be done on Windows ? Right ?

If no, could someone help me ? I've the "Error: %1 is not a valid Win32 application" error from the first post who the app works fine on mac but not in windows. Trying electron-rebuild but don't works..

jamarw commented 7 years ago

Hi all, did anyone have any luck with this? I'm hitting the same error and have tried all the suggestions above. Thanks

popod commented 7 years ago

@jamarw user keytar-prebuild ! See #67. This works for me.

jamarw commented 7 years ago

Thanks @popod ! Appreciate the help.

Xosmond commented 6 years ago

So I have to compile electron on a Windows machine to get correct Windows executables? Thats a problem because i don't have one

IGassmann commented 6 years ago

This now should be resolved thanks to https://github.com/atom/node-keytar/pull/67.

IGassmann commented 6 years ago

Still happening with the latest version of node-keytar after building an electron x64 app.

shiftkey commented 6 years ago

@IGassmann which version of Electron are you trying to target?

adeperio commented 5 years ago

Hi everyone, I am also getting this issue (the one @IGassmann is reporting). I am using electron 4.0.4 and keytar 4.4.0. I am using electron-builder to build a 64 bit windows package. But when I run the app (the package is successfully built, problem happens on app execution) I get this error. Not an issue on mac

Any ideas how I can work around this at the moment?

charlag commented 4 years ago

Same as @adeperio but weirdly it happens only in some conditions, could only reproduce it with CI now electron 8, keytar 5.2.0, electron-builder 22.3.3 https://github.com/tutao/tutanota/blob/efd3a3ff75f9be485d7f371c4e3e05eb08f3935c/package.json#L26

charlag commented 4 years ago

We still didn't find out the reason but might be that manually clearing node_modules may help (even with npm ci)

woss commented 3 years ago

i'm using the "keytar": "^7.3.0", on windows with "electron": "11.1.1", and "@electron-forge/cli": "^6.0.0-beta.54",. Still getting .webpack\main/c33748addbc1c5372b52757c2542d3fd.node is not a valid Win32 application. where c33748addbc1c5372b52757c2542d3fd.node is keytar.node any idea what is the solution and possible alternative to keytar?

Thanks

tomboolean commented 3 years ago

So, we are trying to automate our builds using electron-builder's provided docker image electronuserland/builder:wine as they show in their docs.

We're getting the same error in the console:

Uncaught Error: Cannot open C:\Program Files\peerlogic\resources\app.asar\dist\renderer\_nuxt\keytar.node: Error: C:\Users\Administrator\AppData\Local\Temp\2\24875caf-7428-4310-817f-9e24ef377df9.tmp.node is not a valid Win32 application.
C:\Users\Administrator\AppData\Local\Temp\2\24875caf-7428-4310-817f-9e24ef377df9.tmp.node

I'm wondering if there is a way for the prebuild to not try and detect what OS it's on and specify it directly? Or the prebuild can recognize Wine is installed and instead build for Windows?

For reference, here is the output from the prebuild of keytar inside the wine docker container. As you can see it's building all 10 versions from v75 to v85 as linux instead of windows: prebuilds/keytar-v7.3.0-electron-v*-linux-x64.tar.gz

tomboolean commented 3 years ago

yarn run v1.22.4
$ prebuild -t 7.0.0 -t 8.0.0 -t 9.0.0 -t 10.0.0 -t 11.0.0 -r electron --strip
prebuild info begin Prebuild version 10.0.1
prebuild info build Preparing to prebuild keytar@7.3.0 for electron 7.0.0 on linux-x64 using node-gyp
prebuild info find Python using Python version 3.6.9 found at "/usr/bin/python3"
prebuild http GET https://atom.io/download/electron/v7.0.0/node-v7.0.0-headers.tar.gz
prebuild http 200 https://atom.io/download/electron/v7.0.0/node-v7.0.0-headers.tar.gz
prebuild http GET https://atom.io/download/electron/v7.0.0/SHASUMS256.txt
prebuild http 200 https://atom.io/download/electron/v7.0.0/SHASUMS256.txt
prebuild info spawn /usr/bin/python3
prebuild info spawn args [
prebuild info spawn args   '/usr/local/share/.config/yarn/global/node_modules/node-gyp/gyp/gyp_main.py',
prebuild info spawn args   'binding.gyp',
prebuild info spawn args   '-f',
prebuild info spawn args   'make',
prebuild info spawn args   '-I',
prebuild info spawn args   '/builds/peerlogic/peerlogic-desktop-app/node_modules/keytar/build/config.gypi',
prebuild info spawn args   '-I',
prebuild info spawn args   '/usr/local/share/.config/yarn/global/node_modules/node-gyp/addon.gypi',
prebuild info spawn args   '-I',
prebuild info spawn args   '/tmp/prebuild/electron/7.0.0/include/node/common.gypi',
prebuild info spawn args   '-Dlibrary=shared_library',
prebuild info spawn args   '-Dvisibility=default',
prebuild info spawn args   '-Dnode_root_dir=/tmp/prebuild/electron/7.0.0',
prebuild info spawn args   '-Dnode_gyp_dir=/usr/local/share/.config/yarn/global/node_modules/node-gyp',
prebuild info spawn args   '-Dnode_lib_file=/tmp/prebuild/electron/7.0.0/<(target_arch)/node.lib',
prebuild info spawn args   '-Dmodule_root_dir=/builds/peerlogic/peerlogic-desktop-app/node_modules/keytar',
prebuild info spawn args   '-Dnode_engine=v8',
prebuild info spawn args   '--depth=.',
prebuild info spawn args   '--no-parallel',
prebuild info spawn args   '--generator-output',
prebuild info spawn args   'build',
prebuild info spawn args   '-Goutput_dir=.'
prebuild info spawn args ]
prebuild info spawn make
prebuild info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory '/builds/peerlogic/peerlogic-desktop-app/node_modules/keytar/build'
  CXX(target) Release/obj.target/keytar/src/async.o
  CXX(target) Release/obj.target/keytar/src/main.o
  CXX(target) Release/obj.target/keytar/src/keytar_posix.o
  SOLINK_MODULE(target) Release/obj.target/keytar.node
  COPY Release/keytar.node
make: Leaving directory '/builds/peerlogic/peerlogic-desktop-app/node_modules/keytar/build'
prebuild info build Stripping debug information from build/Release/keytar.node
prebuild info build Packing build/Release/keytar.node into prebuilds/keytar-v7.3.0-electron-v75-linux-x64.tar.gz
prebuild info build Prebuild written to prebuilds/keytar-v7.3.0-electron-v75-linux-x64.tar.gz
prebuild info build Preparing to prebuild keytar@7.3.0 for electron 8.0.0 on linux-x64 using node-gyp
prebuild info find Python using Python version 3.6.9 found at "/usr/bin/python3"
prebuild http GET https://atom.io/download/electron/v8.0.0/node-v8.0.0-headers.tar.gz
prebuild http 200 https://atom.io/download/electron/v8.0.0/node-v8.0.0-headers.tar.gz
prebuild http GET https://atom.io/download/electron/v8.0.0/SHASUMS256.txt
prebuild http 200 https://atom.io/download/electron/v8.0.0/SHASUMS256.txt
prebuild info spawn /usr/bin/python3
prebuild info spawn args [
prebuild info spawn args   '/usr/local/share/.config/yarn/global/node_modules/node-gyp/gyp/gyp_main.py',
prebuild info spawn args   'binding.gyp',
prebuild info spawn args   '-f',
prebuild info spawn args   'make',
prebuild info spawn args   '-I',
prebuild info spawn args   '/builds/peerlogic/peerlogic-desktop-app/node_modules/keytar/build/config.gypi',
prebuild info spawn args   '-I',
prebuild info spawn args   '/usr/local/share/.config/yarn/global/node_modules/node-gyp/addon.gypi',
prebuild info spawn args   '-I',
prebuild info spawn args   '/tmp/prebuild/electron/8.0.0/include/node/common.gypi',
prebuild info spawn args   '-Dlibrary=shared_library',
prebuild info spawn args   '-Dvisibility=default',
prebuild info spawn args   '-Dnode_root_dir=/tmp/prebuild/electron/8.0.0',
prebuild info spawn args   '-Dnode_gyp_dir=/usr/local/share/.config/yarn/global/node_modules/node-gyp',
prebuild info spawn args   '-Dnode_lib_file=/tmp/prebuild/electron/8.0.0/<(target_arch)/node.lib',
prebuild info spawn args   '-Dmodule_root_dir=/builds/peerlogic/peerlogic-desktop-app/node_modules/keytar',
prebuild info spawn args   '-Dnode_engine=v8',
prebuild info spawn args   '--depth=.',
prebuild info spawn args   '--no-parallel',
prebuild info spawn args   '--generator-output',
prebuild info spawn args   'build',
prebuild info spawn args   '-Goutput_dir=.'
prebuild info spawn args ]
prebuild info spawn make
prebuild info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory '/builds/peerlogic/peerlogic-desktop-app/node_modules/keytar/build'
  CXX(target) Release/obj.target/keytar/src/async.o
  CXX(target) Release/obj.target/keytar/src/main.o
  CXX(target) Release/obj.target/keytar/src/keytar_posix.o
  SOLINK_MODULE(target) Release/obj.target/keytar.node
  COPY Release/keytar.node
make: Leaving directory '/builds/peerlogic/peerlogic-desktop-app/node_modules/keytar/build'
prebuild info build Stripping debug information from build/Release/keytar.node
prebuild info build Packing build/Release/keytar.node into prebuilds/keytar-v7.3.0-electron-v76-linux-x64.tar.gz
prebuild info build Prebuild written to prebuilds/keytar-v7.3.0-electron-v76-linux-x64.tar.gz
prebuild info build Preparing to prebuild keytar@7.3.0 for electron 9.0.0 on linux-x64 using node-gyp
prebuild info find Python using Python version 3.6.9 found at "/usr/bin/python3"
prebuild http GET https://atom.io/download/electron/v9.0.0/node-v9.0.0-headers.tar.gz
prebuild http 200 https://atom.io/download/electron/v9.0.0/node-v9.0.0-headers.tar.gz
prebuild http GET https://atom.io/download/electron/v9.0.0/SHASUMS256.txt
prebuild http 200 https://atom.io/download/electron/v9.0.0/SHASUMS256.txt
prebuild info spawn /usr/bin/python3
prebuild info spawn args [
prebuild info spawn args   '/usr/local/share/.config/yarn/global/node_modules/node-gyp/gyp/gyp_main.py',
prebuild info spawn args   'binding.gyp',
prebuild info spawn args   '-f',
prebuild info spawn args   'make',
prebuild info spawn args   '-I',
prebuild info spawn args   '/builds/peerlogic/peerlogic-desktop-app/node_modules/keytar/build/config.gypi',
prebuild info spawn args   '-I',
prebuild info spawn args   '/usr/local/share/.config/yarn/global/node_modules/node-gyp/addon.gypi',
prebuild info spawn args   '-I',
prebuild info spawn args   '/tmp/prebuild/electron/9.0.0/include/node/common.gypi',
prebuild info spawn args   '-Dlibrary=shared_library',
prebuild info spawn args   '-Dvisibility=default',
prebuild info spawn args   '-Dnode_root_dir=/tmp/prebuild/electron/9.0.0',
prebuild info spawn args   '-Dnode_gyp_dir=/usr/local/share/.config/yarn/global/node_modules/node-gyp',
prebuild info spawn args   '-Dnode_lib_file=/tmp/prebuild/electron/9.0.0/<(target_arch)/node.lib',
prebuild info spawn args   '-Dmodule_root_dir=/builds/peerlogic/peerlogic-desktop-app/node_modules/keytar',
prebuild info spawn args   '-Dnode_engine=v8',
prebuild info spawn args   '--depth=.',
prebuild info spawn args   '--no-parallel',
prebuild info spawn args   '--generator-output',
prebuild info spawn args   'build',
prebuild info spawn args   '-Goutput_dir=.'
prebuild info spawn args ]
prebuild info spawn make
prebuild info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory '/builds/peerlogic/peerlogic-desktop-app/node_modules/keytar/build'
  CXX(target) Release/obj.target/keytar/src/async.o
  CXX(target) Release/obj.target/keytar/src/main.o
  CXX(target) Release/obj.target/keytar/src/keytar_posix.o
  SOLINK_MODULE(target) Release/obj.target/keytar.node
  COPY Release/keytar.node
make: Leaving directory '/builds/peerlogic/peerlogic-desktop-app/node_modules/keytar/build'
prebuild info build Stripping debug information from build/Release/keytar.node
prebuild info build Packing build/Release/keytar.node into prebuilds/keytar-v7.3.0-electron-v80-linux-x64.tar.gz
prebuild info build Prebuild written to prebuilds/keytar-v7.3.0-electron-v80-linux-x64.tar.gz
prebuild info build Preparing to prebuild keytar@7.3.0 for electron 10.0.0 on linux-x64 using node-gyp
prebuild info find Python using Python version 3.6.9 found at "/usr/bin/python3"
prebuild http GET https://atom.io/download/electron/v10.0.0/node-v10.0.0-headers.tar.gz
prebuild http 200 https://atom.io/download/electron/v10.0.0/node-v10.0.0-headers.tar.gz
prebuild http GET https://atom.io/download/electron/v10.0.0/SHASUMS256.txt
prebuild http 200 https://atom.io/download/electron/v10.0.0/SHASUMS256.txt
prebuild info spawn /usr/bin/python3
prebuild info spawn args [
prebuild info spawn args   '/usr/local/share/.config/yarn/global/node_modules/node-gyp/gyp/gyp_main.py',
prebuild info spawn args   'binding.gyp',
prebuild info spawn args   '-f',
prebuild info spawn args   'make',
prebuild info spawn args   '-I',
prebuild info spawn args   '/builds/peerlogic/peerlogic-desktop-app/node_modules/keytar/build/config.gypi',
prebuild info spawn args   '-I',
prebuild info spawn args   '/usr/local/share/.config/yarn/global/node_modules/node-gyp/addon.gypi',
prebuild info spawn args   '-I',
prebuild info spawn args   '/tmp/prebuild/electron/10.0.0/include/node/common.gypi',
prebuild info spawn args   '-Dlibrary=shared_library',
prebuild info spawn args   '-Dvisibility=default',
prebuild info spawn args   '-Dnode_root_dir=/tmp/prebuild/electron/10.0.0',
prebuild info spawn args   '-Dnode_gyp_dir=/usr/local/share/.config/yarn/global/node_modules/node-gyp',
prebuild info spawn args   '-Dnode_lib_file=/tmp/prebuild/electron/10.0.0/<(target_arch)/node.lib',
prebuild info spawn args   '-Dmodule_root_dir=/builds/peerlogic/peerlogic-desktop-app/node_modules/keytar',
prebuild info spawn args   '-Dnode_engine=v8',
prebuild info spawn args   '--depth=.',
prebuild info spawn args   '--no-parallel',
prebuild info spawn args   '--generator-output',
prebuild info spawn args   'build',
prebuild info spawn args   '-Goutput_dir=.'
prebuild info spawn args ]
prebuild info spawn make
prebuild info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory '/builds/peerlogic/peerlogic-desktop-app/node_modules/keytar/build'
  CXX(target) Release/obj.target/keytar/src/async.o
  CXX(target) Release/obj.target/keytar/src/main.o
  CXX(target) Release/obj.target/keytar/src/keytar_posix.o
  SOLINK_MODULE(target) Release/obj.target/keytar.node
  COPY Release/keytar.node
make: Leaving directory '/builds/peerlogic/peerlogic-desktop-app/node_modules/keytar/build'
prebuild info build Stripping debug information from build/Release/keytar.node
prebuild info build Packing build/Release/keytar.node into prebuilds/keytar-v7.3.0-electron-v82-linux-x64.tar.gz
prebuild info build Prebuild written to prebuilds/keytar-v7.3.0-electron-v82-linux-x64.tar.gz
prebuild info build Preparing to prebuild keytar@7.3.0 for electron 11.0.0 on linux-x64 using node-gyp
prebuild info find Python using Python version 3.6.9 found at "/usr/bin/python3"
prebuild http GET https://atom.io/download/electron/v11.0.0/node-v11.0.0-headers.tar.gz
prebuild http 200 https://atom.io/download/electron/v11.0.0/node-v11.0.0-headers.tar.gz
prebuild http GET https://atom.io/download/electron/v11.0.0/SHASUMS256.txt
prebuild http 200 https://atom.io/download/electron/v11.0.0/SHASUMS256.txt
prebuild info spawn /usr/bin/python3
prebuild info spawn args [
prebuild info spawn args   '/usr/local/share/.config/yarn/global/node_modules/node-gyp/gyp/gyp_main.py',
prebuild info spawn args   'binding.gyp',
prebuild info spawn args   '-f',
prebuild info spawn args   'make',
prebuild info spawn args   '-I',
prebuild info spawn args   '/builds/peerlogic/peerlogic-desktop-app/node_modules/keytar/build/config.gypi',
prebuild info spawn args   '-I',
prebuild info spawn args   '/usr/local/share/.config/yarn/global/node_modules/node-gyp/addon.gypi',
prebuild info spawn args   '-I',
prebuild info spawn args   '/tmp/prebuild/electron/11.0.0/include/node/common.gypi',
prebuild info spawn args   '-Dlibrary=shared_library',
prebuild info spawn args   '-Dvisibility=default',
prebuild info spawn args   '-Dnode_root_dir=/tmp/prebuild/electron/11.0.0',
prebuild info spawn args   '-Dnode_gyp_dir=/usr/local/share/.config/yarn/global/node_modules/node-gyp',
prebuild info spawn args   '-Dnode_lib_file=/tmp/prebuild/electron/11.0.0/<(target_arch)/node.lib',
prebuild info spawn args   '-Dmodule_root_dir=/builds/peerlogic/peerlogic-desktop-app/node_modules/keytar',
prebuild info spawn args   '-Dnode_engine=v8',
prebuild info spawn args   '--depth=.',
prebuild info spawn args   '--no-parallel',
prebuild info spawn args   '--generator-output',
prebuild info spawn args   'build',
prebuild info spawn args   '-Goutput_dir=.'
prebuild info spawn args ]
prebuild info spawn make
prebuild info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory '/builds/peerlogic/peerlogic-desktop-app/node_modules/keytar/build'
  CXX(target) Release/obj.target/keytar/src/async.o
  CXX(target) Release/obj.target/keytar/src/main.o
  CXX(target) Release/obj.target/keytar/src/keytar_posix.o
  SOLINK_MODULE(target) Release/obj.target/keytar.node
  COPY Release/keytar.node
make: Leaving directory '/builds/peerlogic/peerlogic-desktop-app/node_modules/keytar/build'
prebuild info build Stripping debug information from build/Release/keytar.node
prebuild info build Packing build/Release/keytar.node into prebuilds/keytar-v7.3.0-electron-v85-linux-x64.tar.gz
prebuild info build Prebuild written to prebuilds/keytar-v7.3.0-electron-v85-linux-x64.tar.gz```