0

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.

Ali Hamidi
  • 11
  • 3
  • Since libcouchbase 2.0 you don't need external libvbucket, it has been bundled into libcouchbase and links statically – avsej May 21 '13 at 21:38
  • Your script is using some custom tarballs, why not use specific version from official site (can be found at http://couchbase.com/develop/c)? – avsej May 21 '13 at 21:42
  • I was under the impression that the "preferred" approach was to build the binaries using the target environments (in this case actually building on a Heroku Dyno). – Ali Hamidi May 22 '13 at 07:26
  • @avsej Ah ok, cool thanks. I'll remove libvbucket. – Ali Hamidi May 22 '13 at 07:35

3 Answers3

1

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"
Ali Hamidi
  • 11
  • 3
0

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

avsej
  • 3,822
  • 4
  • 26
  • 31
  • I tried setting the Env Variables as you mentioned, but I still get the same error. I'm not sure if it helps but the path in which I am unpacking the tarball is /app/vendor/couchbase Additionally, the couchbase header files are not actually listing in the /app/vendor/couchbase/include directory. That directory has a sub-folder named "libcouchbase" which houses the actual files. – Ali Hamidi May 22 '13 at 08:09
0

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

avsej
  • 3,822
  • 4
  • 26
  • 31