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

Better error msg when Instant Client is missing #404

Closed
wants to merge 8 commits into from
20 changes: 20 additions & 0 deletions lib/oracledb.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,33 @@ var oracledbInst;
var Lob = require('./lob.js').Lob;
var pool = require('./pool.js');
var connection = require('./connection.js');
var path;
var existsSync;

try {
oracledbCLib = require('../build/Release/oracledb');
} catch (err) {
if (err.code === 'MODULE_NOT_FOUND') {
oracledbCLib = require('../build/Debug/oracledb');
} else {

path = require('path');
existsSync = require('fs').existsSync || require('path').existsSync;

process.env.PATH.split(path.delimiter).forEach(function(dir) {
if(existsSync(path.join(dir, 'oci.dll'))) {
console.log();
console.log('**** Found Oracle Instant Client in PATH in the following direcory:' + dir);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea to improve this. Can the messages cater for users with ORACLE_HOME installs too? Something like "Found the Oracle client library ..." Testing PATH will only work on Windows; I'd be OK making the improved validation work on Windows-only for the moment.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I will modify to cater to ORACLE_HOME too. Good idea. Also, for Linux we could search for libclntsh.so.12.1 or libclntsh.so.11.1, right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For non-Windows I think you'd be OK checking for 'libclntsh.*' Harder to portably check the link has been created.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look right:

    path = require('path');
    existsSync = require('fs').existsSync || require('path').existsSync;

I can't find existsSync in path. Also, existsSync is deprecated:
https://nodejs.org/api/fs.html#fs_fs_existssync_path

The main answer here offers an alternative:
http://stackoverflow.com/questions/4482686/check-synchronously-if-file-directory-exists-in-node-js

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you're right. I will update it.

  • sent from iPhone.

On Apr 9, 2016, at 11:20 AM, Dan McGhan [email protected] wrote:

In lib/oracledb.js:

try {
oracledbCLib = require('../build/Release/oracledb');
} catch (err) {
if (err.code === 'MODULE_NOT_FOUND') {
oracledbCLib = require('../build/Debug/oracledb');
} else {

  • path = require('path');
  • existsSync = require('fs').existsSync || require('path').existsSync;
  • process.env.PATH.split(path.delimiter).forEach(function(dir) {
  •  if(existsSync(path.join(dir, 'oci.dll'))) {
    
  •     console.log();
    
  •     console.log('***\* Found Oracle Instant Client in PATH in the following direcory:' + dir);
    
    This doesn't look right:
path = require('path');
existsSync = require('fs').existsSync || require('path').existsSync;

I can't find existsSync in path. Also, existsSync is deprecated:
https://nodejs.org/api/fs.html#fs_fs_existssync_path

This the main answer here offers an alternative:
http://stackoverflow.com/questions/4482686/check-synchronously-if-file-directory-exists-in-node-js


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub

console.log('**** Make sure the version you have installed is the correct one.');
console.log('**** Needs to match your the bitness (32bit/64bit) of your Node.js and be for the Operating System that you are using.');
console.log();
throw err;
}
});
console.log();
console.log('**** Oracle Instant Client directory not found.');
console.log('**** Add the Instant Client directory to your PATH environment variable, then try again.');
console.log();
throw err;
}
}
Expand Down