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

atom-shell #357

Closed
Tracked by #240
daiyam opened this issue Oct 25, 2014 · 22 comments
Closed
Tracked by #240

atom-shell #357

daiyam opened this issue Oct 25, 2014 · 22 comments

Comments

@daiyam
Copy link

daiyam commented Oct 25, 2014

Hi,

How can I compile node-sqlite3 for atom-shell? I want to use it in the web-page side to avoid any unnecessary ipc call.

Thx

@bengotow
Copy link
Contributor

bengotow commented Nov 6, 2014

Hi @daiyam were you able to get this working? I'm interested in doing this too. I'll let you know if I make any headway.

@daiyam
Copy link
Author

daiyam commented Nov 6, 2014

I'm using a wrapper around sqlite3 like dblite without its bugs.
But the performance isn't that great: half the speed of node-sqlite3 due to the extra parsing and the error handling.

@kkaefer
Copy link
Contributor

kkaefer commented Nov 7, 2014

@daiyam
Copy link
Author

daiyam commented Nov 8, 2014

I tried...

$ export ATOM_NODE_VERSION=0.18.2
$ apm install .

will give out

> sqlite3@3.0.2 install /Users/.../node-sqlite3-master
> node-pre-gyp install --fallback-to-build

Unsupported target version: 0.18.2

node-pre-gyp ERR! install error 
node-pre-gyp ERR! stack Error: Unsupported target version: 0.18.2

or

$ node-gyp rebuild --target=0.18.2 --arch=x64 --dist-url=https://gh-contractor-zcbenz.s3.amazonaws.com/atom-shell/dist
gyp: Undefined variable module_name in binding.gyp while trying to load binding.gyp
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1

or

$ ./node_modules/.bin/node-pre-gyp build --target=0.18.2 --arch=x64 --dist-url=https://gh-contractor-zcbenz.s3.amazonaws.com/atom-shell/dist
node-pre-gyp info it worked if it ends with ok
node-pre-gyp info using node-pre-gyp@0.5.31
node-pre-gyp info using node@0.11.14 | darwin | x64
node-pre-gyp ERR! UNCAUGHT EXCEPTION 
node-pre-gyp ERR! stack Error: Unsupported target version: 0.18.2

@Mithgol
Copy link
Contributor

Mithgol commented Nov 9, 2014

That's because the issue mapbox/node-pre-gyp#110 is not yet closed (in other words, because node-pre-gyp does not support Atom Shell as a target yet).

@bengotow
Copy link
Contributor

bengotow commented Nov 9, 2014

I was curious about how Mapbox was using SQLite inside their Mapbox Studio app (an atom-shell application). It looks like they're still using atom-shell 0.16.x, which happened to define the node_ami version number as "16", which matches up with an available binary in node-pre-gyp. I don't fully understand the different versioning approaches used in node-pre-gyp. I'm not sure if 0.16.x is actually compatible or just happens to not fail. At any rate, it works and SQLite 3 is usable with atom-shell 0.16.x.

For technical reasons we can't move our project back to atom-shell 0.16.x, and we're stuck with 0.19.x, which has node_ami = 18. @Mithgol, if there's anything I can do to help close that issue, let me know!

@springmeyer
Copy link
Contributor

Mapbox studio is not using atom shell and node-sqlite3 in the same process. The lack of binary compatibility with node was a major deterant. Because we have multiple node c++ addons and support multiple platforms having to provide 2x the binaries for atom-shell is not viable for us at this point. So Mapbox Studio is only using atom shell for the browser and not taking advantage of the ability to call into node modules.

@Mithgol
Copy link
Contributor

Mithgol commented Nov 10, 2014

@bengotow You can help by adding a commit or two towards the final goal of mapbox/node-pre-gyp#112.

@bwin
Copy link
Contributor

bwin commented Dec 2, 2014

You could also wait for PR #369 and then manually build with node-gyp

npm install sqlite3 # or another way of obtaining source
cd node_modules/sqlite3
node-gyp rebuild --target=0.19.5 --arch=ia32 --dist-url=https://gh-contractor-zcbenz.s3.amazonaws.com/atom-shell/dist --module_name=node_sqlite3 --module_path=..\lib\binding

edit: corrected typo in snippet

@bengotow
Copy link
Contributor

bengotow commented Dec 2, 2014

Thanks @bwin, @Mithgol - I looked into the changes that needed to be made and figured it'd be best to wait for folks with a deeper understanding of the V8 headers and versioning involved to update things. In the meantime, we've started using the (deprecated) WebSQL API in Chromium. It's surprisingly performant (simple indexed SELECT queries in 1-2msec), and good enough for us to build on top of until the dust settles a bit with all this stuff. Thanks for the help - we'll be rolling onto node-sqlite3 as soon as we can!

@max-mapper
Copy link

I just wanted to chime in and say it would be super awesome if this worked with atom-shell out of the box!

@springmeyer
Copy link
Contributor

Thanks @maxogden! - mapbox/node-pre-gyp#112 is on my radar.

@jasonhinkle
Copy link

I was able to get sqlite3 working with Electron after install with the following. Note that the version numbers are hard-coded into the arguments which are Electron 0.27.1 and v43 (by the way anybody know where 43 come from? It seems to refer to modules versioning that is related to the version of Electron, but I can't find any translation of these numbers - the only way to find it is to just let your app throw an error and see what the foldername is that it's looking for.)

cd node_modules/sqlite3
npm run prepublish
node-gyp configure --module_name=node_sqlite3 --module_path=../lib/binding/node-v43-darwin-x64
node-gyp rebuild --target=0.27.1 --arch=x64 --target_platform=darwin --dist-url=https://atom.io/download/atom-shell --module_name=node_sqlite3 --module_path=../lib/binding/node-v43-darwin-x64

@max-mapper
Copy link

43 is the NODE_MODULE_VERSION which is similar to the ABI version, node, iojs and electron all have their non-overlapping own version ranges that they increment whenever the native API changes. I don't think this is written down anywhere (i've been trying to get core people to document it)

@ekryski
Copy link

ekryski commented Jun 8, 2015

Gonna also throw in my hat. Would love to see this work out of the box. I can confirm that @jasonhinkle's solution does work.

I still haven't tried with ASPM as documented here. I tried with electron-build but it didn't seem to work as my require statement still bombed but I didn't dig any deeper there.

@olimsaidov
Copy link

For anyone having same issue: http://verysimple.com/2015/05/30/using-node_sqlite3-with-electron/

@ekryski
Copy link

ekryski commented Jul 4, 2015

@olimsaidov Nice! I should have written something up myself. I have the exact same process going on Delicious. Works perfectly. Pretty much the same process for compiling any native lib, other dbs included.

@thefinn93
Copy link

Lots of these have the word "darwin" in them (and aren't working for me), are they mac-specific?

@ekryski
Copy link

ekryski commented Jul 13, 2015

@thefinn93 Yes. You need to specify which platform you are targeting. I haven't built for other platforms just yet, so I'm not entirely sure what options you need to change.

@jasonhinkle
Copy link

The target_platform and target_arch need to be changed for your environment - the options can be found at https://www.npmjs.com/package/node-pre-gyp

@zcbenz
Copy link

zcbenz commented Sep 24, 2015

Refs mapbox/node-pre-gyp#175.

@springmeyer
Copy link
Contributor

@zcbenz - thank you for mapbox/node-pre-gyp#175 - it is now merged and part of node-pre-gyp v0.6.12. Would it be possible for you to create a pull that starts building binaries for electron on travis?

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