From 71b61432bc3651961885384cf29b9bc4f549313f Mon Sep 17 00:00:00 2001 From: Bill Christo Date: Fri, 8 Apr 2016 18:20:38 -0400 Subject: [PATCH 1/8] Better error msg when Instant Client is missing --- lib/oracledb.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/oracledb.js b/lib/oracledb.js index d2f3a429b..f95d95aed 100644 --- a/lib/oracledb.js +++ b/lib/oracledb.js @@ -22,6 +22,8 @@ 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'); @@ -29,6 +31,24 @@ try { if (err.code === 'MODULE_NOT_FOUND') { oracledbCLib = require('../build/Debug/oracledb'); } else { + + existsSync = require('fs').existsSync || require('path').existsSync; + ic_found = false; + + 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); + 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; } } From 73d61531ad2b0d1302be4ff6e44ee9c5d8e5a734 Mon Sep 17 00:00:00 2001 From: Bill Christo Date: Fri, 8 Apr 2016 18:23:11 -0400 Subject: [PATCH 2/8] Better error msg when Instant Client is missing --- lib/oracledb.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/oracledb.js b/lib/oracledb.js index f95d95aed..3183dc493 100644 --- a/lib/oracledb.js +++ b/lib/oracledb.js @@ -31,10 +31,9 @@ try { if (err.code === 'MODULE_NOT_FOUND') { oracledbCLib = require('../build/Debug/oracledb'); } else { - - existsSync = require('fs').existsSync || require('path').existsSync; - ic_found = false; - + + 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(); From 6c29e2e8dbbe2b1363aa809d640631a657426033 Mon Sep 17 00:00:00 2001 From: Bill Christo Date: Fri, 8 Apr 2016 18:30:18 -0400 Subject: [PATCH 3/8] Better error msg when Instant Client is missing --- lib/oracledb.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/oracledb.js b/lib/oracledb.js index 3183dc493..b18b31226 100644 --- a/lib/oracledb.js +++ b/lib/oracledb.js @@ -32,6 +32,7 @@ try { 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) { From 3b6bbc783d3d9281e7bc9ff5b737fe49291ecddd Mon Sep 17 00:00:00 2001 From: Bill Christo Date: Sun, 10 Apr 2016 02:20:57 -0400 Subject: [PATCH 4/8] Better error msg when Instant Client is missing --- lib/oracledb.js | 51 +++++++++++++++++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 12 deletions(-) diff --git a/lib/oracledb.js b/lib/oracledb.js index b18b31226..c5f236608 100644 --- a/lib/oracledb.js +++ b/lib/oracledb.js @@ -23,7 +23,9 @@ var Lob = require('./lob.js').Lob; var pool = require('./pool.js'); var connection = require('./connection.js'); var path; -var existsSync; +var fs; +var fileExists; +var fileMatch; try { oracledbCLib = require('../build/Release/oracledb'); @@ -31,22 +33,47 @@ try { if (err.code === 'MODULE_NOT_FOUND') { oracledbCLib = require('../build/Debug/oracledb'); } else { - path = require('path'); - existsSync = require('fs').existsSync || require('path').existsSync; + fs = require('fs'); + + fileExists = function(fullPathToFile) { + try { + return fs.statSync(fullPathToFile).isFile(); + } + catch (err) { + return false; + } + }; + + fileMatch = function(dir, match){ + try { + return fs.readdirSync(dir).some(function(file){ + if(file.indexOf(match)>=0) {console.log(dir +'/' +file);return true;} + }); + } + catch (err) { + return false; + } + }; 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); - 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; - } + var msg = function(){ + console.log(); + console.log('**** Found Oracle Instant Client in PATH in the following directory: ' + dir); + console.log('**** But the version is either corrupt or not for the same OS and/or Node.js processor architecture in which you\'re running on.'); + console.log('**** Your Node.js processor architecture is ' + process.arch + '.'); + console.log('**** If you have multiple Instant Client folders defined in PATH, only the first one is loaded.'); + console.log('**** Therefore, the first to appear needs to be correct one.'); + console.log(); + throw err; + }; + + if(fileExists(path.join(dir, 'oci.dll')) || fileMatch(dir, 'libclntsh.')) {msg();} + }); + console.log(); - console.log('**** Oracle Instant Client directory not found.'); + console.log('**** Oracle Instant Client directory was not found.'); console.log('**** Add the Instant Client directory to your PATH environment variable, then try again.'); console.log(); throw err; From 68d5f8d92bd519494bff7aa86fabdd369661c447 Mon Sep 17 00:00:00 2001 From: Bill Christo Date: Sun, 10 Apr 2016 02:35:51 -0400 Subject: [PATCH 5/8] Better error msg when Instant Client is missing --- lib/oracledb.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/oracledb.js b/lib/oracledb.js index c5f236608..5a7bc59e5 100644 --- a/lib/oracledb.js +++ b/lib/oracledb.js @@ -48,7 +48,7 @@ try { fileMatch = function(dir, match){ try { return fs.readdirSync(dir).some(function(file){ - if(file.indexOf(match)>=0) {console.log(dir +'/' +file);return true;} + if(file.substr(0, searchString.length) === searchString) {return true;} }); } catch (err) { From 10da5cc9aa953f52a9b72a6623c8ed7a55b4fe57 Mon Sep 17 00:00:00 2001 From: Bill Christo Date: Sun, 10 Apr 2016 02:36:54 -0400 Subject: [PATCH 6/8] Better error msg when Instant Client is missing --- lib/oracledb.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/oracledb.js b/lib/oracledb.js index 5a7bc59e5..db3f31437 100644 --- a/lib/oracledb.js +++ b/lib/oracledb.js @@ -45,7 +45,7 @@ try { } }; - fileMatch = function(dir, match){ + fileMatch = function(dir, searchString){ try { return fs.readdirSync(dir).some(function(file){ if(file.substr(0, searchString.length) === searchString) {return true;} From 270b4d18f2aff2a952cb67d14a004d2f7f75d336 Mon Sep 17 00:00:00 2001 From: Bill Christo Date: Mon, 11 Apr 2016 08:56:09 -0400 Subject: [PATCH 7/8] Better error msg when Instant Client is missing --- lib/oracledb.js | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/lib/oracledb.js b/lib/oracledb.js index db3f31437..a77e7bc3c 100644 --- a/lib/oracledb.js +++ b/lib/oracledb.js @@ -25,7 +25,6 @@ var connection = require('./connection.js'); var path; var fs; var fileExists; -var fileMatch; try { oracledbCLib = require('../build/Release/oracledb'); @@ -45,21 +44,10 @@ try { } }; - fileMatch = function(dir, searchString){ - try { - return fs.readdirSync(dir).some(function(file){ - if(file.substr(0, searchString.length) === searchString) {return true;} - }); - } - catch (err) { - return false; - } - }; - process.env.PATH.split(path.delimiter).forEach(function(dir) { var msg = function(){ console.log(); - console.log('**** Found Oracle Instant Client in PATH in the following directory: ' + dir); + console.log('**** Found an Oracle client library in PATH in the following directory: ' + dir); console.log('**** But the version is either corrupt or not for the same OS and/or Node.js processor architecture in which you\'re running on.'); console.log('**** Your Node.js processor architecture is ' + process.arch + '.'); console.log('**** If you have multiple Instant Client folders defined in PATH, only the first one is loaded.'); @@ -68,13 +56,14 @@ try { throw err; }; - if(fileExists(path.join(dir, 'oci.dll')) || fileMatch(dir, 'libclntsh.')) {msg();} + if(fileExists(path.join(dir, 'oci.dll'))) {msg();} }); console.log(); - console.log('**** Oracle Instant Client directory was not found.'); - console.log('**** Add the Instant Client directory to your PATH environment variable, then try again.'); + console.log('****'); + console.log('**** AN ORACLE CLIENT LIBRARY WAS NOT FOUND.'); + console.log('****'); console.log(); throw err; } From 8d436cea8e3db84bf2c5dbde2d59810ddae94e91 Mon Sep 17 00:00:00 2001 From: Bill Christo Date: Mon, 11 Apr 2016 09:03:52 -0400 Subject: [PATCH 8/8] Better error msg when Instant Client is missing --- lib/oracledb.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/oracledb.js b/lib/oracledb.js index a77e7bc3c..3dc277eba 100644 --- a/lib/oracledb.js +++ b/lib/oracledb.js @@ -50,7 +50,7 @@ try { console.log('**** Found an Oracle client library in PATH in the following directory: ' + dir); console.log('**** But the version is either corrupt or not for the same OS and/or Node.js processor architecture in which you\'re running on.'); console.log('**** Your Node.js processor architecture is ' + process.arch + '.'); - console.log('**** If you have multiple Instant Client folders defined in PATH, only the first one is loaded.'); + console.log('**** If you have multiple Oracle client directories defined in PATH, only the first one is loaded.'); console.log('**** Therefore, the first to appear needs to be correct one.'); console.log(); throw err;