Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Not working with Electron 4.0.1 on Windows #149

Closed
emusgrave opened this issue Jan 17, 2019 · 17 comments
Closed

Not working with Electron 4.0.1 on Windows #149

emusgrave opened this issue Jan 17, 2019 · 17 comments

Comments

@emusgrave
Copy link

Using Electron 4.0.1, Keytar 4.3.0, Windows 10.

Starting from electron-quick-start, adding keytar, and calling

keytar.getPassword('_mytokens_', '_myusername_')
    .then(password => console.log('Password is ', password));

Results in errno 3228369023

I've tried pulling keytar from master and rebuilding, since there are some recent commits that attempt to address Electron 4 compatibility, but I still get the same error.

If I downgrade to Electron 3.1.1 then it works as expected.

@dcpesses
Copy link

Same, here, except I'm experiencing the issue on Windows and on macOS.

I've tried using several different versions of Node (8.12, 8.15, 10.15) on both Windows 10 as well as on macOS 10.13.6, with little success.

On Windows, keytar 4.3.0 throws the following error (even though keytar.node exists at the given path):

[16:52:41.336] Error: The specified module could not be found.
\\?\C:\Users\dcpesses\Projects\electron-quick-start-keytar\node_modules\keytar\build\Release\keytar.node
    at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:160:31)
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:722:18)
    at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:160:31)
    at Module.load (internal/modules/cjs/loader.js:602:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:541:12)
    at Function.Module._load (internal/modules/cjs/loader.js:533:3)
    at Module.require (internal/modules/cjs/loader.js:640:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (C:\Users\dcpesses\Projects\electron-quick-start-keytar\node_modules\keytar\lib\keytar.js:1:107)
    at Object.<anonymous> (C:\Users\dcpesses\Projects\electron-quick-start-keytar\node_modules\keytar\lib\keytar.js:61:3)

macOS throws a different error:

dyld: lazy symbol binding failed: Symbol not found: __ZN2v816FunctionTemplate3NewEPNS_7IsolateEPFvRKNS_20FunctionCallbackInfoINS_5ValueEEEENS_5LocalIS4_EENSA_INS_9SignatureEEEiNS_19ConstructorBehaviorE
  Referenced from: /Users/dpesses/Projects/electron-quick-start-keytar/node_modules/keytar/build/Release/keytar.node
  Expected in: flat namespace

dyld: Symbol not found: __ZN2v816FunctionTemplate3NewEPNS_7IsolateEPFvRKNS_20FunctionCallbackInfoINS_5ValueEEEENS_5LocalIS4_EENSA_INS_9SignatureEEEiNS_19ConstructorBehaviorE
  Referenced from: /Users/dpesses/Projects/electron-quick-start-keytar/node_modules/keytar/build/Release/keytar.node
  Expected in: flat namespace

I've had limited success using keytar 4.2.1 with a local project using Electron 4.0.1, configured with electron-builder, but I've been unsuccessful in packaging Electron with a working keytar module.

It appears other devs have run into this issue as well, as it's referenced in electron-builder#3590, but even after following the suggestions given in that thread, I'm still receiving errors.

@emusgrave
Copy link
Author

@dcpesses To get past the keytar.node not found error, try adding electron-rebuild to your project as a dev dependency, and then running an npm script with electron-rebuild -f -w keytar. That will rebuild the keytar.node file with whatever version of electron that you are using.

If you can get past that error, I'll be interested to hear if you have the issue that I'm having with Electron 4.0.1.

@dcpesses
Copy link

@emusgrave Actually I tried that same command with electron-rebuild but never could get it to actually rebuild. After executing electron-rebuild -f -w keytar, it would pause for 3 seconds, then display Rebuild Complete. The only thing that really worked for me was running an npm script with electron-builder install-app-deps. It only works locally though, so as soon as I attempt to build a package for production, I get the same errors.

What might work, is forking the repo and removing prebuild-install from the npm script install, as I have a sneaking suspicion the install defaults to using any available prebuilds, which are likely to fail due to issues with the same ABI used for both v3 and v4 of Electron. (See #node-abi/54 for details.)

@mark-spurgeon
Copy link

This seems to be a widespread bug. I got the same issue running on a mac with keytar version 4.3.0 and electron 4.0.1, but downgrading to electron 3.1.1 worked for me...

@conteit
Copy link

conteit commented Jan 21, 2019

Not working with electron >=4.0.0 both on macOs Mojave and Windows 10 1803

@shiftkey
Copy link
Contributor

I think we need to wait on electron/node-abi#55 because of changes to ABI compatibility and how Electron 4 is built.

@shiftkey
Copy link
Contributor

Closing this out in favour of the earlier report #133. I'll update that issue to make it clearer it's a broad problem.

@emusgrave
Copy link
Author

@shiftkey Thanks for pointing me towards that issue, but I still don't think the title of that issue captures the depth of the problem. Electron 4 is the mainline release now, and as it stands today, I can't figure out any way to get keytar to work with it, manually or otherwise.

Until this is solved, you may even want a banner on the readme that explains that this library cannot be used with Electron 4. The goal is simply to save people time. I burned a few hours trying to figure this out before just downgrading to Electron 3.

@shiftkey
Copy link
Contributor

@emusgrave

Electron 4 is the mainline release now, and as it stands today, I can't figure out any way to get keytar to work with it, manually or otherwise.

I've got a test build running on Electron 4.0.1 but after poking at the keytar interactions it looks like it's silently failing on my side. I still need to upgrade from Electron 2.0.x first to 3.x before I can really think about digging into this (Node ABI issues aside).

Until this is solved, you may even want a banner on the readme that explains that this library cannot be used with Electron 4.

Want to open a PR and start this off? I'm happy to review and get something up asap.

@vladimiry
Copy link

Until this is solved, you may even want a banner on the readme that explains that this library cannot be used with Electron 4.

This is not true. I successfully use keytar with electron@v4 here https://github.com/vladimiry/email-securely-app. Just don't rely on prebuilds (I simply remove the prebuilds and trigger building from sources).

@adeperio
Copy link

getting this same issue @vladimiry , any idea how I can build from source? Will this work building windows packages on a mac?

@vladimiry
Copy link

@adeperio make sure you use the latest keytar release as the issue with prebuilds has already been resolved.

@adeperio
Copy link

adeperio commented Feb 14, 2019

@vladimiry oh ok. I think I'm already pointing to the latest keytar (4.4.0?) and I'm still getting this problem (using Electron 4.0.4). I'm building with electron-builder (trying to build a win 64 exe on a mac) with the following build config:

"npmRebuild": true,
"buildDependenciesFromSource": true

Is there anything else you think I could be doing?

@vladimiry
Copy link

Try this way:

  • Remove ./node_modules/keytar/prebuilds and ./node_modules/keytar/build if any.
  • Remove/comment-out "npmRebuild": true, and "buildDependenciesFromSource": true from your config.
  • Execute npx electron-builder install-app-deps --arch=x64 (I'm assuming you build for x64 arch running x64 system).

Will this work building windows packages on a mac?

It's unlikely that you will be able to compile native modules for windows on mac. Native modules need to be compiled on respective platforms (win/mac/linux), for example using Appveyor and Travi CI.

@adeperio
Copy link

@vladimiry I think that's where I have been heading down the wrong direction. I was on Electron 1.8.6 and have been using prebuilds successfully to build Windows on a mac machine. But in the upgrade to Electron 4.0.4, I lost this ability with node-hid, another native dep. node-hid only supported up to Electron < 2.0 I think and still don't have prebuilds for the latest electron.

This may not be a keytar issue and may actually be a problem with node-hid. In the mix up, I think I was rebuilding ALL native dependencies. But maybe I can use your instructions on the node-hid library first, and revert back to using the prebuilds with keytar? Thanks for sending those through. I'll report back and see what I come up with.

@shiftkey
Copy link
Contributor

node-hid only supported up to Electron < 2.0 I think and still don't have prebuilds for the latest electron.

@adeperio check out the latest release for node-hid as it looks like they've encountered the same problem as keytar and are now shipping prebuilds for Electron 4.0.4.

@adeperio
Copy link

adeperio commented Feb 16, 2019

Thanks @shiftkey yep latest release of node-hid is working. Still waiting on keytar I think

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants