Unable to 'gem install couchbase' on OS X 10.10 (Yosemite)

I got the following error when ‘gem install couchbase’:

Building native extensions. This could take a while…
ERROR: Error installing couchbase:
ERROR: Failed to build gem native extension.

/Users/root/.rvm/rubies/ruby-2.1.2/bin/ruby extconf.rb

checking for lcb_iops_wire_bsd_impl2(NULL, 0) in -lcouchbase… no



*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.

Provided configuration options:
–with-opt-dir
–without-opt-dir
–with-opt-include
–without-opt-include=${opt-dir}/include
–with-opt-lib
–without-opt-lib=${opt-dir}/lib
–with-make-prog
–without-make-prog
–srcdir=.
–curdir
–ruby=/Users/root/.rvm/rubies/ruby-2.1.2/bin/ruby
–with-libcouchbase-dir
–without-libcouchbase-dir
–with-libcouchbase-include
–without-libcouchbase-include=${libcouchbase-dir}/include
–with-libcouchbase-lib
–without-libcouchbase-lib=${libcouchbase-dir}/lib
–with-couchbaselib
–without-couchbaselib

extconf failed, exit code 1

But I already have installed libcouchbase on my machine using ‘brew.’

$brew install libcouchbase
Warning: libcouchbase-2.4.3 already installed

So I try manually building libcouchbase.

$ git clone git://github.com/couchbase/libcouchbase.git
$ cd libcouchbase && mkdir build && cd build
$ …/cmake/configure
$ make
$ ctest

Actually, I needed this cause I need to use libcouchbase >= 2.4.4 because of Loading.... But it seems like brew only install 2.4.3.

ctest passed, but I still can’t ‘gem install couchbase’.
It seems like I need to use one of the configuration options.

Could anyone help me with example script?


P.S. It would be great if…

  1. Brew is updated.
  2. If guide links on github are updated. (The links are mis-directing to wrong pages.) Such as ‘installation page’ link from GitHub - couchbase/libcouchbase: The couchbase client for C..
  3. A little more detail about how to install couchbase client library. :smile:

Homebrew has the most recent libcouchbase already

https://github.com/Homebrew/homebrew/blob/master/Library/Formula/libcouchbase.rb#L5

Have you done brew update && brew upgrade libcouchbase

1 Like

installation page leads to https://docs.couchbase.com/developer/c-2.4/download-install.html what wrong with it?

1 Like

Did you run make install?

1 Like

Oops, I was very ignorant. Sorry.
I tried…

brew uninstall libcouchbase
brew install libcouchbase

and thought everything would work fine.

And “installation page” looks fine, as well. I don’t know what I was looking at it.
And I didn’t know about “make install”, thank you.

Thank you for detailed explanation and everything else.

Hmmm…
Since everything works fine now, so this is not that critical but wondering why…

You must install libcouchbase >= 2.4.0

this error pops up while I have…

libcouchbase 2.4.3

I’m experiencing the same issue on Yosemite. I have tried everything listed here with no luck.

Building native extensions.  This could take a while...
ERROR:  Error installing couchbase:
ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
checking for lcb_iops_wire_bsd_impl2(NULL, 0) in -lcouchbase... no

**********************************************************************
* You must install libcouchbase >= 2.4.0
* See http://www.couchbase.com/communities/c/ for more details
**********************************************************************

*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may 
need configuration options.

Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
--with-libcouchbase-dir
--without-libcouchbase-dir
--with-libcouchbase-include
--without-libcouchbase-include=${libcouchbase-dir}/include
--with-libcouchbase-lib
--without-libcouchbase-lib=${libcouchbase-dir}/
--with-couchbaselib
--without-couchbaselib

Have you also tried the following?

brew update
brew upgrade libcouchbase

I got this to work with it.

@gp99, could you post output of brew info libcouchbase?

⇒ brew info libcouchbase
libcouchbase: stable 2.4.6 (bottled), HEAD
http://docs.couchbase.com/developer/c-2.4/c-intro.html
/usr/local/Cellar/libcouchbase/2.1.3 (131 files, 1.5M) *
  Built from source
/usr/local/Cellar/libcouchbase/2.4.6 (56 files, 1.5M)
  Poured from bottle
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/libcouchbase.rb
==> Dependencies
Build: cmake ✔
Required: openssl ✔
Recommended: libevent ✔
Optional: libev ✘, libuv ✘
==> Options
--universal
	Build a universal binary
--with-libev
	Build libev plugin
--with-libuv
	Build with libuv support
--without-libevent
	Do not build libevent plugin
--HEAD
	Install HEAD version

Tried upgrade too

⇒ brew upgrade libcouchbase
Error: libcouchbase 2.4.6 already installed

I’ve tried yesterday, everything works on 10.10

I finally figured out that it was an issue with 64bit. Couchbaselib was x64, but I think the gem was trying to install as i386. I found something online about this happening with other gems, and updating ruby was the fix. I use rbenv, and switched back the the system ruby version and the gem installed fine.

The gem is trying to workaround 64/32 bit issue on macs: https://github.com/couchbase/couchbase-ruby-client/blob/master/ext/couchbase_ext/extconf.rb#L23-L31

@gp99 could you post here output of

  1. ruby --version
  2. lipo -info $(brew --prefix libcouchbase)/lib/libcouchbase.dylib
  3. lipo -info $(rbenv which ruby)
  4. ruby -rrbconfig -e 'puts(defined?(RbConfig::ARCHFLAGS) ? RbConfig::ARCHFLAGS : "RbConfig::ARCHFLAGS is not defined")'
  5. ruby -rrbconfig -e '[RbConfig::CONFIG, RbConfig::MAKEFILE_CONFIG].each { |cfg| %w(CFLAGS LDFLAGS LDSHARED LIBRUBY_LDSHARED configure_args).each { |k| puts "#{k} => #{cfg[k]}" } }'