-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Conversation
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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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();
This doesn't look right:console.log('***\* Found Oracle Instant Client in PATH in the following direcory:' + dir);
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_pathThis 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
I recommend not to use console.log for valid things, instead to use https://www.npmjs.com/package/debuglog |
@sagiegurari isn't it kinda of a moot point since we are throwing an error? But while we're on the topic shouldn't we be handling the errors asynchronously by passing the error up the callback chain instead of try/catching it? |
error you say? you have printouts to console.log for valid scenarios. if(existsSync(path.join(dir, 'oci.dll'))) {
console.log();
console.log('**** Found Oracle Instant Client in PATH in the following direcory:' + dir); |
It's not a valid scenario. This only prints out when it's the wrong instant client version. |
ok, now i get you. than forget it, you are right. |
in windows, i saw an issue for people who used node 64 bit with oci 32 bit. |
Not all errors are asynchronous: This try/catch is only executed once to bring in the C lib when the module is first "required" in. There is no callback chain in this context anyway, so throwing is the correct behavior. |
@dmcghan okay that makes sense then. @sagiegurari yea i thought about including the node.js version but didn't know how to extrapolate the same information from the dll, so for now I decided to hold off. As far as having multiple instant clients in path, the first one to appear is the one that is used which is why only the first one's directory is displayed. Perhaps the error message should indicate this. |
maybe this can help: These are not js implementations but i'm sure you can convert it to js to validate. |
I was just doing some tests on Windows. I didn't have any environment variables set. I opened a command prompt and typed |
In response to everyone's feedback, I just pushed the following changes:
I haven't added the scanning of ORACLE_HOME yet. I am waiting to get some feedback from @cjbj on this. Need to better understand when ORACLE_HOME is used and whether it is preferred over PATH. As explained, on Windows having it defined does not appear to influence anything. Maybe it's only for Linux? |
As for instant client, ORACLE_HOME is referred only when TNS_ADMIN isn't set and it is used to locate configuration files such as tnsnames.ora or sqlnet.ora. As for full client, ORACLE_HOME must be set. Otherwise Oracle client doesn't work. On Unix ORACLE_HOME must be set as an environment variable. On Windows it is set in the Windows registry. |
It doesn't work on Unix because the environment variable PATH is not used to locate dependent shared libraries on Unix. On Linux, the location of libclntsh.so is embedded in the compiled node-oracledb binary by the linker option On other Unix platforms, similar but different ways are used to locate libclntsh.so. |
Thanks @kubo
In my testing on Windows, I did not have TNS_ADMIN set and I can confirm that although I had ORACLE_HOME set it was not used. So I'm still not sure why that is. In regards to your second reply, based on that I think I may need to make the first section, the one that searches for the library, only for Windows and for everything else just have a standard message explaining that the library was not found. Or perhaps I can search the LD_LIBRARY_PATH? Before I change anything again, I will wait a bit to give everyone the opportunity to chime in. |
ORACLE_HOME is unrelated to the location of OCI.DLL. It is used only to locate network configuration files when TNS_ADMIN is not set in instant client. If you don't use network configuration files such as tnsnames.ora, ORACLE_HOME has no effect.
+1 to the former. |
@bchr02 to surface my earlier comments I think it will easier to make the change (for this PR, at least) specific to Windows. The general message terminology needs to use 'Oracle client' instead of 'Oracle Instant Client' since PATH may be using an Oracle Home-style install and not Instant Client. |
@cjbj Okay, I just pushed those changes. Thanks. |
@bchr02 in 1.11 we emit a new NJS error message when the node-oracledb binary can't be loaded but we haven't added any of the investigatory heuristics of this PR. |
@bchr02 where do you want to go with this? I adopted the ideas into https://github.com/oracle/node-oracledb/blob/dev-2.0/lib/oracledb.js (thank you!) without the port specific Windows check for oci.dll. Do you want to rework the PR and add it under a platform check for Windows? It should probably mention needing the VS Redistributable. There could be some smarts like looking for a BASIC_README or BASIC_LITE_README to get a version number and then printing out which VS Redistributable is needed? |
@cjbj I would love to. I’ll start working on something. So, what did you have in mind by looking at the readme’s. Is there a version number within them, some metadata on the files themselves or does the mere fact that they exist mean that VS 2010 is needed over 2005? |
@bchr02 If your code finds an oci.dll and there is a BASIC_README or BASIC_LITE_README then you know the user has Instant Client - and the user must separately install a redistributable. You can parse the version out of the readme from the Some of the logic could also be added into https://github.com/oracle/node-oracledb/blob/v2.0.14-dev/package/oracledbinstall.js#L336 These are just brainstorm ideas from a non-windows user. |
@cjbj Is the getInfo() function in oracledb.js called when OCL.DLL or VS redistributable is missing? getInfo() is called only when |
@kubo. Something like https://gist.github.com/cjbj/78a587855a81edec3fb4dedc8aece522 ? |
I updated the gist. |
@cjbj I checked the gist on Linux. It looks good. |
@cjbj In light of oracle/odpi#48 which route are we going with this? will this be done in ODPI-C or oracledb.js? |
@bchr02 I think Anthony will make some changes. Give it a day or two to see what he commits. |
The v2.0.15 messages might contain too much information; for example if there is no oracledb.node binary, the messages mention this and then talk about Instant Client. I expect some readers will focus on the wrong parts of the message. |
@bchr02 is it time to close this? |
Yes, thank you. |
If there is a pending error and Instant Client is not found in PATH then an error message is displayed prior to
throw err;
.Otherwise, if it is found in PATH then the directory it is first found in is outputed with a message asking the user to check that the correct version is installed.
Signed-off-by: Bill Christo [email protected]