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
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.