Pergunta

I'm trying to put together a custom buildpack with NodeJS and the CouchBase module/libraries

I've gotten as far as using Vulcan to build libcouchbase and libvbucket and getting the buildpack to retrieve and unpack the tgz files for both.

Everything looks ok there, but I receive errors when npm tries to install the couchbase module:

I get a bunch of errors, but this line:

"../src/couchbase_impl.h:52:36: warning: libcouchbase/couchbase.h: No such file or directory"

leads me to think that it can't find the libcouchbase libraries (which is possible since they aren't in the usual place).

I've tried to add the correct path using CPPFLAGS="-I/app/vendor/couchbase/include/libcouchbase" in both the Config Vars and just exporting that as part of the compile phase, but still no luck.

Here is the gist with the Heroku deploy output and the compile/release buildpack files: https://gist.github.com/ahamidi/5620503

Any help would be greatly appreciated.

Thanks,

Ali

[Update 1]

I've made some progress and I can now get the slug to compile when deploying to Heroku.

The key was figuring out the ENV Variables that CouchNode looks for when adding custom directories to include.

In this case, the Env Variables were EXTRA_CPPFLAGS and EXTRA_LDFLAGS.

So I updated the compile file to include the following:

export EXTRA_CPPFLAGS="-I$BUILD_DIR/vendor/couchbase/include" 
export EXTRA_LDFLAGS="-L$BUILD_DIR/vendor/couchbase/lib -Wl,-rpath,$BUILD_DIR/vendor/couchbase/lib"

The slug compiles and the app is deployed, but I now get a different error in the logs:

Error: libcouchbase.so.2: cannot open shared object file: No such file or directory

So it looks like Node can't see the libcouchbase libraries directory.

Foi útil?

Solução

For anyone who is curious or experiencing a similar issue, here's what worked for me.

In order to get the couchbase npm module to install I had to tell it where to find the libcouchbase libraries (in compile file):

export EXTRA_CPPFLAGS="-I$BUILD_DIR/vendor/couchbase/include" 
export EXTRA_LDFLAGS="-L$BUILD_DIR/vendor/couchbase/lib -Wl,-rpath,$BUILD_DIR/vendor/couchbase/lib"

Then in order to require couchbase in my app I had to set the following Env Variable:

LD_LIBRARY_PATH="/app/vendor/couchbase/lib:$LD_LIBRARY_PATH"

With the command:

heroku config:add LD_LIBRARY_PATH="/app/vendor/couchbase/lib:$LD_LIBRARY_PATH"

Outras dicas

You should set CPPFLAGS="-I/app/vendor/couchbase/include" LDFLAGS="-L/app/vendor/couchbase/include -lcouchbase"

from your script it seems like you just unpacking libcouchbase without any further work. you should also build it and install. typical magic spell for node.js client will be ./configure --disable-plugins --disable-examples && make && sudo make install. I'm not sure if sudo part needed on heroku, probably just make install

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top