Unable to install couchbase gem on ruby on rails

Currently I used ruby 2.6.3 and rails 6.0.1 and I am unable to install couchbase gem, I keep getting this error when trying to install the gem using command
gem install couchbase

Building native extensions. This could take a while…
ERROR: Error installing couchbase:
ERROR: Failed to build gem native extension.
current directory: /Users/user/.rvm/gems/ruby-2.6.3/gems/couchbase-3.1.1/ext
/Users/user/.rvm/rubies/ruby-2.6.3/bin/ruby -I /Users/user/.rvm/rubies/ruby-2.6.3/lib/ruby/site_ruby/2.6.0 -r ./siteconf20210429-16269-1qsei29.rb extconf.rb
checking for cmake… 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
–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/user/.rvm/rubies/ruby-2.6.3/bin/$(RUBY_BASE_NAME)
extconf.rb:25:in ``’: No such file or directory - --version (Errno::ENOENT)
from extconf.rb:25:in `’

To see why this extension failed to compile, please check the mkmf.log which can be found here:
/Users/user/.rvm/gems/ruby-2.6.3/extensions/x86_64-darwin-18/2.6.0/couchbase-3.1.1/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /Users/user/.rvm/gems/ruby-2.6.3/gems/couchbase-3.1.1 for inspection.
Results logged to /Users/user/.rvm/gems/ruby-2.6.3/extensions/x86_64-darwin-18/2.6.0/couchbase-3.1.1/gem_make.out

libcouchbase is already installed
brew info libcouchbase

libcouchbase: stable 3.0.7 (bottled), HEAD
C library for Couchbase
https://docs.couchbase.com/c-sdk/3.0/hello-world/start-using-sdk.html
/usr/local/Cellar/libcouchbase/3.0.7 (110 files, 4.1MB) *
Poured from bottle on 2021-04-29 at 18:56:19
From: homebrew-core/libcouchbase.rb at b8a6748e8af26ef35bb6cea8a6c7523a38249e0a · Homebrew/homebrew-core · GitHub
License: Apache-2.0
==> Dependencies
Build: cmake
Required: libev :heavy_check_mark: , libevent :heavy_check_mark: , libuv :heavy_check_mark: , openssl@1.1 :heavy_check_mark:
==> Options
–HEAD
Install HEAD version
==> Analytics
install: 674 (30 days), 1,734 (90 days), 7,217 (365 days)
install-on-request: 662 (30 days), 1,709 (90 days), 6,943 (365 days)
build-error: 0 (30 days

What did i miss?

Hi @asharmubasir, thanks for the question. Ruby SDK does not depend on libcouchbase, but it does depend on cmake.

You can fix this issue by brew install cmake and then retrying gem install couchbase.

1 Like

ah thank you very much sir, it’s work now

Hi sir @avsej, based on your previous answer, I am able to install the couchbase gem inside my local computer which is on mac, now I am trying to install this on my aws ec2 instance, which gave the same error, and I’ve already install cmake and libcouchbase.

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

current directory: /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/couchbase-3.1.1/ext

/home/ubuntu/.rvm/rubies/ruby-2.6.3/bin/ruby -I /home/ubuntu/.rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0 -r ./siteconf20210708-22247-1n2d73c.rb extconf.rb
checking for cmake… yes
rm -rf /tmp/cb-RelWithDebInfo-2.6.3-62-x86_64-linux-3.1.1
mkdir -p /tmp/cb-RelWithDebInfo-2.6.3-62-x86_64-linux-3.1.1
– cmake version 3.5.1
– build RelWithDebInfo extension 3.1.1 for ruby 2.6.3-62-x86_64-linux
– /tmp/cb-RelWithDebInfo-2.6.3-62-x86_64-linux-3.1.1
– /usr/bin/cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DRUBY_HDR_DIR=/home/ubuntu/.rvm/rubies/ruby-2.6.3/include/ruby-2.6.0 -DRUBY_ARCH_HDR_DIR=/home/ubuntu/.rvm/rubies/ruby-2.6.3/include/ruby-2.6.0/x86_64-linux -B/tmp/cb-RelWithDebInfo-2.6.3-62-x86_64-linux-3.1.1 -S/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/couchbase-3.1.1/ext
CMake Error: The source directory “” does not exist.
Specify --help for usage, or press the help button on the CMake GUI.
– /tmp/cb-RelWithDebInfo-2.6.3-62-x86_64-linux-3.1.1
– /usr/bin/cmake --build /tmp/cb-RelWithDebInfo-2.6.3-62-x86_64-linux-3.1.1 --parallel 4 --verbose
Unknown argument --parallel
Unknown argument 4
Unknown argument --verbose
Usage: cmake --build [options] [-- [native-options]]
Options:

= Project binary directory to be built. --target = Build instead of default targets. --config = For multi-configuration tools, choose . --clean-first = Build target 'clean' first, then build. (To clean only, use --target 'clean'.) --use-stderr = Ignored. Behavior is default in CMake >= 3.0. -- = Pass remaining options to the native tool. ERROR: failed to build extension in /tmp/cb-RelWithDebInfo-2.6.3-62-x86_64-linux-3.1.1/libcouchbase.so *** 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=/home/ubuntu/.rvm/rubies/ruby-2.6.3/bin/$(RUBY_BASE_NAME)

To see why this extension failed to compile, please check the mkmf.log which can be found here:

/home/ubuntu/.rvm/gems/ruby-2.6.3/extensions/x86_64-linux/2.6.0/couchbase-3.1.1/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/couchbase-3.1.1 for inspection.
Results logged to /home/ubuntu/.rvm/gems/ruby-2.6.3/extensions/x86_64-linux/2.6.0/couchbase-3.1.1/gem_make.out

if you install library from the rubygems.org, the environment have to have compiler and cmake. But instead, you can install it from the official gem repository, where we serve gems with precompiled extension. Try to put this line in your Gemfile for production (I see you are using ruby ABI 2.6.0):

gem "couchbase", "3.1.1", :source => "https://packages.couchbase.com/clients/ruby/2.6.0/"

Thank you sir, it’s work. and thank you for your quick response.

Hi @avsej, everytime I tried to connect to the couchbase server, it;s crashed without giving any informations but this.

[NOTE]

You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: https://www.ruby-lang.org/bugreport.html

Aborted (core dumped)

Here is the script i tried to run.

require ‘couchbase’
include Couchbase
cluster = Cluster.connect("couchbase://"172.31.14.11, “admin”, “password”)

But when i tried this script on my local computer, it does not crashed, but just raise an error :
Couchbase::Error::UnambiguousTimeout ( unable open cluster at 172.31.14.11: unambiguous_timeout )