Question

How to fix hiredis compilation issue after a deployment on nodejitsu?

After I deployed to nodejitsu I received the following error from jistu logs command.

ld.so.1: node: fatal: relocation error: file /opt/haibu/apps/<user>/<app>/package/node_modules/redis/node_modules/hiredis/build/Release/hiredis.node: symbol redisReaderCreate: referenced symbol not found
Était-ce utile?

La solution

The reason why it doesn't work out of the box is because the redis package comes bundled with hiredis, which is a C library used by redis for parsing redis code.

Nodejitsu does not guarantee that C libraries will work out of the box because the code must be compiled on their servers, and there are no guarantees that it'll execute the makefile in the same way as your dev environment.

In Pavel's solution, he overrides the CPPFLAGS and LD_OPTIONS environmental variables, which in turn force the hiredis library to compile. Unfortunately, this will adversely affect any OTHER C libraries that your package uses.

I would recommend bundling redis with your project in the following manner:

npm install hiredis
npm install redis
npm uninstall hiredis

Redis will detect that you have hiredis installed, so it won't install it as a dependency. Then, simply remove hiredis after you install redis. Redis will automatically fall back on the Javascript parser, which is a bit slower (but the team is working on improving it).

Then, add "redis" to your bundled dependencies:

"bundledDependencies": ["redis"]

Simply jitsu deploy and you're good to go.

Autres conseils

I had to add the following to package.json

"bundledDependencies": ["redis"]

https://npmjs.org/doc/json.html#bundledDependencies

optionally try to add the following to package.json

"env": {
    "CXX": "/opt/local/bin/g++ -m64",
    "CPPFLAGS": "-I/opt/local/include",
    "LD_OPTIONS": "-L/opt/local/lib -lsocket -lnsl",
    "PYTHON": "/opt/local/bin/python2.7"
}

received help from 'blakmatrix_' and '@AvianFlu' on webchat.jit.su thx!

  • bundleddeps tells npm to pack the deps along with the rest of your project, normally nothing in node_modules gets packed
  • though if you tell it to, by putting the dep name in the bundled dep array it will include that dependencie in with your app when packaged
  • by doing that once you do a npm i -d for example it will use the bundle dep rather than install it fresh
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top