node-oracledb icon indicating copy to clipboard operation
node-oracledb copied to clipboard

Enhancement Request - Simpler oracledb installation - package oci in new node module

Open sagiegurari opened this issue 9 years ago • 10 comments

I have a proposal to make the installation and runtime of node-oracledb simpler. Basically most of the issues have to do with OCI installation and all those env vars that are needed to compile and in runtime (different env vars).

My suggestion is as follows:

  • create a new npm module (for example oracle-oci) which basically just packages the oci client instead of having users install the instance client on their on
  • node-oracledb will add a dependency to this new oci module so it will be installed when oracledb is installed.
  • as part of the oracledb installation, when running the c++ compilation, setup the needed env vars automatically to point to the installed oracle oci module (define the needed env vars ONLY if not defined already by the user in this env).
  • for runtime, before loading the C++ bindings, resolve the location of the oci module and setup the process env vars as needed. like in installation do not overwrite if the env vars are already set (for example if lang is set or maybe oci path is already pointing to some local installation).

Basically this will remove the need to install instant client and setup env vars. The tooling needed to compile C++ is still needed (python, modern c++ compiler and such...) but that is standard for any node module with C++ code.

The reason the oci should be in different package and not inside node-oracledb is to allow the user to select which oci version he wants by simple adding the oracle-oci dependency in his package.json as well with specific version. This would force of using the user requested version instead of latest.

sagiegurari avatar Dec 15 '16 17:12 sagiegurari

@sagiegurari we have thought about that and it's a good direction. Currently Instant Client requires a click through. (Yes, I will continue to champion the removal). Got a good solution?

cjbj avatar Dec 16 '16 05:12 cjbj

The oracle-oci could just download the instant client on install and not package it. The download url using same version as the oracle oci npm package version. Before downloading you could ask for user approval of license and remember his answer for next time. If i remeber during bower install they ask user permission of statistics collection. To support automatic download in build machines without human manual intervation maybe validate some silent flag via env var.

sagiegurari avatar Dec 16 '16 05:12 sagiegurari

@sagiegurari some of this is easier said than done. Anyway, we are working on a number of fronts. Any technical input into the mechanics of download and clickthroughs are welcome.

cjbj avatar Dec 19 '16 02:12 cjbj

This may be a silly question, but why can't you build the interface without using OCIl? Can't the protocols to communicate with the database be implemented in JavaScript natively, the way Java Type4 JDBC drivers are created? The dependency on Python (at least for me, on MacOS), and the need to setup environment variables prior to the build, doesn't seem consistent with the way modules are delivered via npm. Admittedly, I'm very new to Node, and haven't worked with a lot of libraries yet.

When you look at concepts like 12-Factor apps, where the expectation is that a developer can build the application directly from source control, this library really breaks that concept by requiring the developer to know a lot more information than seems necessary to get the code to build and run.

jlgreene2 avatar Mar 10 '17 15:03 jlgreene2

@jlgreene2 I'll take a shot at answering this one before @cjbj can provide a proper answer :)

I don't believe OCI is the problem. Oracle is a very powerful database with lots of advanced features not found in other databases. Those features have to be exposed by some kind of client-side (middle tier) library. A low-level library, written in C, makes a lot of sense as then only light-weight interfaces need to be written for specific scripting languages. This reduces risk and duplication while allowing more features to be exposed faster. Actually, Node.js itself does the same thing - a lot of the codebase is written in C and has C based dependencies.

The real problem is that the current installation process is more difficult than it should be. That's what this thread (and related threads on pre-compiled binaries) are trying to address. @cjbj has been working hard behind the scenes to move these efforts forward. Hopefully, this will eventually be as easy as npm install oracledb.

dmcghan avatar Mar 10 '17 16:03 dmcghan

@jlgreene2 there are various projects happening in parallel. In the short term some work on dynamic loading that @anthony-tuininga is researching for https://github.com/oracle/odpi should help the install compilation process of node-oracledb v2. Hopefully making his code portable won't slow down the merge. You will still need to have Oracle client libraries installed for runtime use. They add a lot of value that is indispensable.

cjbj avatar Mar 12 '17 11:03 cjbj

Thank you for your replies @dmcghan and @cjbj. As I said, I'm kind of new to the Node space, and trying to evaluate whether our development teams should be pursuing it. My experience with Oracle has been mainly confined to Java. This experience with installing Node was just something that I had not experienced before with other Node modules loaded via npm. So I figured I would ask.

jlgreene2 avatar Mar 13 '17 14:03 jlgreene2

Hopefully, this will eventually be as easy as npm install oracledb.

For Oracle Linux or RHEL users who have the Instant Client basic & devel RPMs installed, the node-oracledb install already is as simple as 'npm install oracledb'. See https://github.com/oracle/node-oracledb/blob/master/INSTALL.md#linuxadv

cjbj avatar Mar 13 '17 21:03 cjbj

@cjbj

For Oracle Linux or RHEL users who have the Instant Client basic & devel RPMs installed

That's a big "if". Sure, if you have the instance client installed and have the right compiler in place, it's as simple as that...

I hope it's eventually as easy as npm install oracledb, without all the preconditions.

dmcghan avatar Mar 13 '17 21:03 dmcghan

Regular followers know that strides were made in v2 to improve installation.

And another step forward was made today: Instant Client RPMs are available without a click-through from yum.oracle.com. Read all about it at https://blogs.oracle.com/linux/oracle-instant-client-rpms-now-available-on-oracle-linux-yum-server-yumoraclecom

Don't ask me about ZIPs or other platforms. I'll let you know the news if/when I have any.

cjbj avatar Oct 23 '18 04:10 cjbj

The direction has been towards creating 'Thin' drivers - we did this last year for Python. For Node.js, the just-released node-oracledb 6.0 is a pure JavaScript module by default, so there is no need to bundle Instant Client at all. I'll close this issue. We got there in the end!

cjbj avatar May 25 '23 00:05 cjbj