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

Importing fails in Windows environments without C runtime library #1015

Open
traeok opened this issue Jan 28, 2025 · 3 comments
Open

Importing fails in Windows environments without C runtime library #1015

traeok opened this issue Jan 28, 2025 · 3 comments

Comments

@traeok
Copy link

traeok commented Jan 28, 2025

  • Operating System Name where ibm_db is installed: Windows 10
  • Target Db2 Server Version or output of db2level command from Db2 database system: N/A
> node -v
20.18.2

> npm ls ibm_db
[email protected] C:\Users\WDAGUtilityAccount\test-proj                                                                   
-- [email protected]

C:\Users\WDAGUtilityAccount\test-proj>echo %IBM_DB_HOME%
%IBM_DB_HOME%

C:\Users\WDAGUtilityAccount\test-proj>echo %PATH%
C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Users\WDAGUtilityAccount\scoop\apps\nodejs\current\bin;C:\Users\WDAGUtilityAccount\scoop\apps\nodejs\current;C:\Users\WDAGUtilityAccount\scoop\shims;C:\Users\WDAGUtilityAccount\AppData\Local\Microsoft\WindowsApps

C:\Users\WDAGUtilityAccount\test-proj>echo %LIB%
%LIB%

Steps to Reproduce:

In Windows Sandbox or an environment w/o the CRT available:

  1. mkdir test-proj
  2. cd test-proj
  3. npm init -y
  4. npm install ibm_db
  5. node -i
  6. In the REPL, type const ibmDb = await import("ibm_db")
  7. See the error message during import:

Image

These steps work with [email protected] but not with [email protected].

Possible solution:

Bundling the CRT as a static library may resolve this issue - we faced a similar situation in a Zowe node package where a Node-native module could not be found in environments without CRT. Compiling our Node-native binaries with a static C runtime resolved this for our scenario, so I figured it was worth mentioning here.

@traeok traeok changed the title Importing ibm_db fails in environments without C runtime library Importing fails in Windows environments without C runtime library Jan 28, 2025
@bimalkjha
Copy link
Member

@traeok I do not see any install output for ibm_db. We need complete output of npm install ibm_db to understand the issue. Do you see ibm_db\build\Release\odbc_bindings.node file post install? Thanks.

@traeok
Copy link
Author

traeok commented Jan 29, 2025

Sorry about that, here's the output from npm install:

PS C:\Users\WDAGUtilityAccount\test-proj> npm install ibm_db
npm warn deprecated [email protected]: You or someone you depend on is using Q, the JavaScript Promise library that gave JavaScript developers strong feelings about promises. They can almost certainly migrate to the native JavaScript promise now. Thank you literally everyone for joining me in this bet against the odds. Be excellent 
to each other.
npm warn deprecated
npm warn deprecated (For a CapTP with native promises, see @endo/eventual-send and @endo/captp)

added 48 packages, and audited 49 packages in 15s

3 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

The odbc_bindings.node file is present at that path:

PS C:\Users\WDAGUtilityAccount\test-proj\node_modules\ibm_db\build\Release> ls


    Directory: C:\Users\WDAGUtilityAccount\test-proj\node_modules\ibm_db\build\Release


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----         1/29/2025   8:40 AM         282112 odbc_bindings.node

@bimalkjha
Copy link
Member

@traeok [email protected] started using new version of clidriver v12.1.0 by default which depends on vcruntime140.dll where older version of clidriver uses vcruntime120.dll.
We can find amd64.VC14.CRT and amd64.VC12.CRT both under ibm_db\installer\clidriver\bin directory. Add full path of ibm_db\installer\clidriver\bin\amd64.VC14.CRT in system level environment variable LIB and then try import("ibm_db") and verify. Thanks.

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

2 participants