nodejs-buildpack: Unable to re-build with node-oracledb dependency

I am running into an issue when using the buildpack version 1.5.15 and trying to use the node-oracledb module. in order to compile the native module it needs some oracle dependencies. I am getting the error below. I am struggling to figure out where I could customize the buildpack to install these dependencies. could someone guide me as to how I would customize the buildpack for this?

node-oracledb ERR! Error: Cannot find Oracle library libclntsh.so
       node-oracledb ERR! Error: See https://github.com/oracle/node-oracledb/blob/master/INSTALL.md
       gyp: Call to 'INSTURL="https://github.com/oracle/node-oracledb/blob/master/INSTALL.md"; ERR="node-oracledb ERR! Error:"; if [ -z $OCI_LIB_DIR ]; then OCI_LIB_DIR=`ls -d /usr/lib/oracle/*/client*/lib/libclntsh.* 2> /dev/null | tail -1 | sed -e 's#/libclntsh[^/]*##'`; if [ -z $OCI_LIB_DIR ]; then if [ -z "$ORACLE_HOME" ]; then if [ -f /opt/oracle/instantclient/libclntsh.so ]; then echo "/opt/oracle/instantclient/"; else echo "$ERR Cannot find Oracle library libclntsh.so" >&2; echo "$ERR See $INSTURL" >&2; echo "" >&2; fi; else if [ -f "$ORACLE_HOME/lib/libclntsh.so" ]; then echo $ORACLE_HOME/lib; else echo "$ERR Cannot find $ORACLE_HOME/lib/libclntsh.so" >&2; echo "$ERR See $INSTURL" >&2; echo "" >&2; fi; fi; else if [ -f "$OCI_LIB_DIR/libclntsh.so" ]; then echo $OCI_LIB_DIR; else echo "$ERR Cannot find $OCI_LIB_DIR/libclntsh.so" >&2; echo "$ERR See $INSTURL" >&2; echo "" >&2; fi; fi; else if [ -f "$OCI_LIB_DIR/libclntsh.so" ]; then echo $OCI_LIB_DIR; else echo "$ERR Cannot find $OCI_LIB_DIR/libclntsh.so" >&2; echo "$ERR See $INSTURL" >&2; echo "" >&2; fi; fi;' returned exit status 0 while in binding.gyp. while trying to load binding.gyp
       gyp ERR! configure error
       gyp ERR! stack Error: `gyp` failed with exit code: 1
       gyp ERR! stack     at ChildProcess.onCpExit (/tmp/staged/app/.heroku/node/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:305:16)
       gyp ERR! stack     at emitTwo (events.js:87:13)
       gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
       gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
       gyp ERR! System Linux 3.19.0-51-generic
       gyp ERR! command "/tmp/staged/app/.heroku/node/bin/node" "/tmp/staged/app/.heroku/node/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
       gyp ERR! cwd /tmp/staged/app/node_modules/oracledb
       gyp ERR! node -v v4.4.5
       gyp ERR! node-gyp -v v3.3.1
       gyp ERR! not ok
       npm ERR! Linux 3.19.0-51-generic
       npm ERR! argv "/tmp/staged/app/.heroku/node/bin/node" "/tmp/staged/app/.heroku/node/bin/npm" "rebuild" "--nodedir=/tmp/staged/app/.heroku/node"
       npm ERR! node v4.4.5
       npm ERR! npm  v2.15.5
       npm ERR! code ELIFECYCLE
       npm ERR! oracledb@1.9.3 install: `node-gyp rebuild`
       npm ERR! Exit status 1
       npm ERR!
       npm ERR! Failed at the oracledb@1.9.3 install script 'node-gyp rebuild'.
       npm ERR! This is most likely a problem with the oracledb package,
       npm ERR! not with npm itself.
       npm ERR! Tell the author that this fails on your system:
       npm ERR!     node-gyp rebuild
       npm ERR! You can get information on how to open an issue for this project with:
       npm ERR!     npm bugs oracledb
       npm ERR! Or if that isn't available, you can get their info via:
       npm ERR!
       npm ERR!     npm owner ls oracledb
       npm ERR! There is likely additional logging output above.
       npm ERR! Please include the following file with any support request:
       npm ERR!     /tmp/staged/app/npm-debug.log

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 17 (3 by maintainers)

Commits related to this issue

Most upvoted comments

@codeguruRahul

here are the changes I made to get this to work. I have listed the files and additions I made below.

lib/environment.sh

this is a function that will set up your environment variables for all of the oracle libraries

add_oracle_env(){
    local build_dir="$1"
        export LD_LIBRARY_PATH=$build_dir/oracle/instantclient:${LD_LIBRARY_PATH:-}
    export OCI_LIB_DIR=$build_dir/oracle/instantclient
    export OCI_INC_DIR=$build_dir/oracle/instantclient/sdk/include
  }

bin/compile.sh

add this line to the create_env() function. this executes the function above with the paramteter for the build directory

add_oracle_env "$BUILD_DIR/.heroku"

add this line to the top of the build_dependencies() function. this executes the function that will install the actual oracle libraries.

install_oracle_libraries "$BUILD_DIR/.heroku"

profile/nodejs.sh

add these into this file, i added them right after the NODE_ENV is exported.

export LD_LIBRARY_PATH=$HOME/.heroku/oracle/instantclient:${LD_LIBRARY_PATH:-}
export OCI_LIB_DIR=$HOME/.heroku/oracle/instantclient
export OCI_INC_DIR=$HOME/.heroku/oracle/instantclient/sdk/include

lib/dependecies.sh

create this function, I did this at the top of the file, it should not matter where you put it. this is executed in the compile script, that we added above. you will need to replace the download urls with proper locations that you can access. I downloaded the instantclient-basic and sdk and put them, into artifactory.

install_oracle_libraries(){
  echo $HOME
  local build_dir=${1:-}
  echo "Installing oracle libraries"
  mkdir -p $build_dir/oracle
  cd $build_dir/oracle
  local basic_download_url="https://myartifatcory.com/artifactory/thirdParty/oracle/instantclient-basic-linux.x64-12.1.0.2.0.zip"
  local sdk_download_url="https://myartifatcory.com/artifactory/thirdParty/oracle/instantclient-sdk-linux.x64-12.1.0.2.0.zip"
  curl -k "$basic_download_url" --silent --fail --retry 5 --retry-max-time 15 -o instantclient-basic.zip
  echo "Downloaded [$basic_download_url]"
  curl -k "$sdk_download_url" --silent --fail --retry 5 --retry-max-time 15 -o instantclient-sdk.zip
  echo "Downloaded [$sdk_download_url]"
  echo "unzipping libraries"
  unzip instantclient-basic.zip
  unzip instantclient-sdk.zip
  mv instantclient_12_1 instantclient
  cd instantclient
  ln -s libclntsh.so.12.1 libclntsh.so
}

you should be able to build the buildpack after this and it will bundle in the oracle libraries and npm will know about them.

let me know if there is anything that is not clear.