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

SQLCipher disappears when built on Windows #876

Closed
chirpycora opened this issue Sep 13, 2017 · 2 comments
Closed

SQLCipher disappears when built on Windows #876

chirpycora opened this issue Sep 13, 2017 · 2 comments

Comments

@chirpycora
Copy link

I'm attempting to build SQLite3 with SQLCipher in a Windows environment. So far I have had no success doing so. I'm running Node 8.5.0 with NPM 5.4.0.

This is about as basic a scenario as I can think up. In a new folder, I added test.js, and then called npm install sqlite3 --build-from-source --sqlite_libname=sqlcipher --save. This should have created a copy of sqlite3 that supports encryption. Then on the command line, I ran node test.js.

However, when I run the first code block in test.js, it creates an unencrypted database. Running the second block confirms unencrypted access. SQLCipher is not getting bundled in.

I re-ran the install command with --loglevel verbose and saved the output to this file. Nothing struck me as going wrong with it, though I did notice that the text "sqlcipher" never appeared - whether that means anything or not, I am not sure.

Any help would be appreciated!

@springmeyer
Copy link
Contributor

It looks like --sqlite_libname=sqlcipher is being ignored or not see.

Can you try cloning the node-sqlite3 repo and running npm install ...... from within it? (rather than npm install sqlite3 --save which will download the code from the npm registry.

Then from you local checkout do:

npm install --ignore-scripts

Which will install all deps without installing node-sqlite3 itself.

Then build node-sqlite3 like:

./node_modules/.bin/node-pre-gyp configure build --sqlite_libname=sqlcipher

Context: What I think is happening is you are hitting a bug whereby npm > 2.x does not forward arguments to the underlying build tool (node-pre-gyp). More on this at mapbox/node-pre-gyp#300. By calling node-pre-gyp directly I think you can workaround this bug. npm install sqlite3 --build-from-source is basically equivalent to node-pre-gyp configure build (the former calls the latter) and node-pre-gyp configure build calls node-gyp configure build (more details on this at https://github.com/mapbox/node-cpp-skel/blob/master/docs/extended-tour.md#builds)

@chirpycora
Copy link
Author

That appears to be exactly right. The resulting build from the cloned repo is able to encrypt and decrypt databases. I've tested it with the aforementioned test script to confirm, and I've also added the --runtime=electron --target=1.7.6 --dist-url=https://atom.io/download/electron flags to the build command to confirm that it works with Electron apps on Windows as well.

It looks like #300 in the node-pre-gyp repository is pretty active, so I'm guessing my issue here could be short-lived. Otherwise, I can submit a Readme edit to document the issue for Windows users, if you feel that would be helpful.

Thank you again for your help!

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

No branches or pull requests

2 participants