ibmdb / node-ibm_db

IBM DB2 and IBM Informix bindings for node
MIT License
188 stars 151 forks source link

Fix error in driverInstaller on z/OS #884

Closed laijonathan closed 1 year ago

laijonathan commented 1 year ago

This fixes a build issue on z/OS.

The installer should not check if IBM_DB_HOME folder exists on z/OS as that path represents a HLQ dataset, not a DB2 installation.

bimalkjha commented 1 year ago
        if (fs.existsSync(process.env.IBM_DB_HOME) || platform == "os390") {
          IBM_DB_HOME = process.env.IBM_DB_HOME;

@laijonathan Could you please provide more clarity about above code change that if directory process.env.IBM_DB_HOME does not exists in the z/OS system, then why we should set IBM_DB_HOME to process.env.IBM_DB_HOME? And if we do not set it, then which part of code flow is causing issue? Thanks.

laijonathan commented 1 year ago

We need IBM_DB_HOME to extract the headers from SDSNC.H (z/OS HLQ dataset, not a directory) https://github.com/ibmdb/node-ibm_db/blob/92be6a0580ad9baae1d0da793f32b1eb80133dad/installer/driverInstall.js#L195

Our existing code checks if a file or directory exists in our current working directory with the path from our IBM_DB_HOME env variable

    if (process.env.IBM_DB_HOME) {
      if (fs.existsSync(process.env.IBM_DB_HOME)) {
        IBM_DB_HOME = process.env.IBM_DB_HOME;
        IS_ENVIRONMENT_VAR = true;
      } else {
      printMsg(process.env.IBM_DB_HOME + " directory does not exist. Please " +
            "check if you have set the IBM_DB_HOME environment" +
            " variable\'s value correctly.\n");
      clidriverFound = false;
      }
    }

The problem is that users on z/OS will always get an error even if IBM_DB_HOME is set properly as it is not a directory or a file but a z/OS dataset. As a result, IBM_DB_HOME will be empty and cli_driver will be false causing it to terminate at line 301.

laijonathan commented 1 year ago

@bimalkjha

bimalkjha commented 1 year ago

@laijonathan Ok. please do the DCO sign-off. Thanks.