0

I have a OpenShift gear with the NodeJS and MongoDB cartridge installed. I have added KeystoneJS to and when I try to push the updated code, the build fails due to missing gyp module. Full error stack below.

Has anyone else faced missing gyp module of a node/mongo cartridge?

Thanks! Nirav

remote: Traceback (most recent call last):
remote: File "/opt/rh/v8314/root/usr/bin/gyp", line 15, in 
remote: import gyp
remote: ImportError: No module named gyp
remote: gyp ERR! configure error
remote: gyp ERR! stack Error: gyp failed with exit code: 1
remote: gyp ERR! stack at ChildProcess.onCpExit (/opt/rh/nodejs010/root/usr/lib/node_modules/node-gyp/lib/configure.js:343:16)
remote: gyp ERR! stack at ChildProcess.emit (events.js:98:17)
remote: gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:820:12)
remote: gyp ERR! System Linux 2.6.32-504.16.2.el6.x86_64
remote: gyp ERR! command "node" "/opt/rh/nodejs010/root/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
remote: gyp ERR! cwd /var/lib/openshift/559fa9944382ec4cf1000106/app-root/runtime/repo/node_modules/keystone/node_modules/keystone-utils/node_modules/limax/node_modules/cld
remote: gyp ERR! node -v v0.10.35
remote: gyp ERR! node-gyp -v v1.0.2
remote: gyp ERR! not ok
remote:
remote: npm info cld@2.4.3 Failed to exec install script
remote: npm ERR! EEXIST, open '/var/lib/openshift/559fa9944382ec4cf1000106/.npm/0fe9cfe4-6-npm-mime-db-1-14-0-package-tgz.lock'
remote: File exists: /var/lib/openshift/559fa9944382ec4cf1000106/.npm/0fe9cfe4-6-npm-mime-db-1-14-0-package-tgz.lock
remote: Move it away, and try again.
remote: npm ERR! System Linux 2.6.32-504.16.2.el6.x86_64
remote: npm ERR! command "node" "/opt/rh/nodejs010/root/usr/bin/npm" "install" "-d"
remote: npm ERR! cwd /var/lib/openshift/559fa9944382ec4cf1000106/app-root/runtime/repo
remote: npm ERR! node -v v0.10.35
remote: npm ERR! npm -v 1.4.28
remote: npm ERR! path /var/lib/openshift/559fa9944382ec4cf1000106/.npm/0fe9cfe4-6-npm-mime-db-1-14-0-package-tgz.lock
remote: npm ERR! code EEXIST
remote: npm ERR! errno 47
zabumba
  • 12,172
  • 16
  • 72
  • 129
Nirav
  • 45
  • 8

1 Answers1

1

This error started to happen for me suddenly, too, even though it had worked before. For some reason the Python gyp module is either not available in the cartridge or cannot be found. Though I cannot tell what has changed I have found a workaround by upgrading the npm installation used for deployment.

For this I added two action hooks:

  1. .openshift/action_hooks/pre_build

    #!/bin/sh
    
    #  We need to move the package.json file out of the way in pre_build, so
    #  that the OpenShift git post-receive hook doesn't try and use the old
    #  npm version to install the dependencies.
    mv ${OPENSHIFT_REPO_DIR}/package.json \
       ${OPENSHIFT_TMP_DIR}/${OPENSHIFT_APP_UUID}_package.json
    
  2. .openshift/action_hooks/build

    #!/bin/sh
    
    #  we moved the package.json file out of the way in pre_build,
    #  so that the OpenShift git post-receive hook doesn't try and use the
    #  old npm version to install the dependencies. Move it back in.
    mv ${OPENSHIFT_TMP_DIR}/${OPENSHIFT_APP_UUID}_package.json \
       ${OPENSHIFT_REPO_DIR}/package.json
    
    cd ${OPENSHIFT_REPO_DIR}
    
    # We need an updated npm available for node-gyp to work reliable
    npm install npm
    
    # Now install the packages with the new npm version
    ./node_modules/.bin/npm install
    

The idea of using an alternative npm installation that way is taken from https://github.com/ryanj/nodejs-custom-version-openshift/tree/master/.openshift/action_hooks

I also tried using environment variables and setting $PYTHONPATH but had no success with that approach during build (although I got it to work on a manual install).

phw
  • 430
  • 3
  • 11