Can't install couchbase gem on CentOS 7

Here is an exception that I get when I try to install it on a CentOS 7 server:

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

    current directory: /home/deploy/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/couchbase-3.0.0/ext
/home/deploy/.rbenv/versions/2.7.1/bin/ruby -I /home/deploy/.rbenv/versions/2.7.1/lib/ruby/2.7.0 -r ./siteconf20200928-16463-3ufbwi.rb extconf.rb
checking for cmake... yes
rm -rf /tmp/cb-RelWithDebInfo-2.7.1-83-x86_64-linux-3.0.0
mkdir -p /tmp/cb-RelWithDebInfo-2.7.1-83-x86_64-linux-3.0.0
-- build RelWithDebInfo extension 3.0.0 for ruby 2.7.1-83-x86_64-linux
-- /tmp/cb-RelWithDebInfo-2.7.1-83-x86_64-linux-3.0.0
-- cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DRUBY_HDR_DIR=/home/deploy/.rbenv/versions/2.7.1/include/ruby-2.7.0 -DRUBY_ARCH_HDR_DIR=/home/deploy/.rbenv/versions/2.7.1/include/ruby-2.7.0/x86_64-linux -DTAOCPP_JSON_BUILD_TESTS=OFF -DTAOCPP_JSON_BUILD_EXAMPLES=OFF -DSNAPPY_BUILD_TESTS=OFF -DSNAPPY_INSTALL=OFF /home/deploy/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/couchbase-3.0.0/ext
CMake Error at CMakeLists.txt:1 (cmake_minimum_required):
  CMake 3.15 or higher is required.  You are running version 2.8.12.2


-- Configuring incomplete, errors occurred!
-- /tmp/cb-RelWithDebInfo-2.7.1-83-x86_64-linux-3.0.0
-- make -j4 VERBOSE=1
make: *** No targets specified and no makefile found.  Stop.
ERROR: failed to build extension in /tmp/cb-RelWithDebInfo-2.7.1-83-x86_64-linux-3.0.0/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/deploy/.rbenv/versions/2.7.1/bin/$(RUBY_BASE_NAME)

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

  /home/deploy/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/extensions/x86_64-linux/2.7.0/couchbase-3.0.0/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /home/deploy/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/couchbase-3.0.0 for inspection.
Results logged to /home/deploy/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/extensions/x86_64-linux/2.7.0/couchbase-3.0.0/gem_make.out

Centos 7 actually has cmake 3 and when I provide it I receive different error:

$ mkdir ~/bin; export PATH=~/bin:$PATH; ln -s /usr/bin/cmake3 ~/bin/cmake
$ gem install couchbase
Building native extensions. This could take a while...
ERROR:  Error installing couchbase:
	ERROR: Failed to build gem native extension.

    current directory: /home/deploy/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/couchbase-3.0.0/ext
/home/deploy/.rbenv/versions/2.7.1/bin/ruby -I /home/deploy/.rbenv/versions/2.7.1/lib/ruby/2.7.0 -r ./siteconf20200928-17582-r8nxjh.rb extconf.rb
checking for cmake... yes
rm -rf /tmp/cb-RelWithDebInfo-2.7.1-83-x86_64-linux-3.0.0
mkdir -p /tmp/cb-RelWithDebInfo-2.7.1-83-x86_64-linux-3.0.0
-- build RelWithDebInfo extension 3.0.0 for ruby 2.7.1-83-x86_64-linux
-- /tmp/cb-RelWithDebInfo-2.7.1-83-x86_64-linux-3.0.0
-- cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DRUBY_HDR_DIR=/home/deploy/.rbenv/versions/2.7.1/include/ruby-2.7.0 -DRUBY_ARCH_HDR_DIR=/home/deploy/.rbenv/versions/2.7.1/include/ruby-2.7.0/x86_64-linux -DTAOCPP_JSON_BUILD_TESTS=OFF -DTAOCPP_JSON_BUILD_EXAMPLES=OFF -DSNAPPY_BUILD_TESTS=OFF -DSNAPPY_INSTALL=OFF /home/deploy/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/couchbase-3.0.0/ext
-- The CXX compiler identification is GNU 4.8.5
-- The C compiler identification is GNU 4.8.5
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ - works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc - works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Looking for backtrace
-- Looking for backtrace - found
-- Looking for dladdr
-- Looking for dladdr - found
-- Found Git: /usr/bin/git (found version "1.8.3.1") 
-- Build spdlog: 1.6.0
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Build type: RelWithDebInfo
-- Check if the system is big endian
-- Searching 16 bit integer
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of unsigned short
-- Check size of unsigned short - done
-- Searching 16 bit integer - Using unsigned short
-- Check if the system is big endian - little endian
-- Looking for sys/mman.h
-- Looking for sys/mman.h - found
-- Looking for sys/resource.h
-- Looking for sys/resource.h - found
-- Looking for sys/time.h
-- Looking for sys/time.h - found
-- Looking for sys/uio.h
-- Looking for sys/uio.h - found
-- Looking for unistd.h
-- Looking for unistd.h - found
-- Looking for windows.h
-- Looking for windows.h - not found
-- Looking for zlibVersion in z
-- Looking for zlibVersion in z - found
-- Looking for lzo1x_1_15_compress in lzo2
-- Looking for lzo1x_1_15_compress in lzo2 - not found
-- Performing Test HAVE_VISUAL_STUDIO_ARCH_AVX
-- Performing Test HAVE_VISUAL_STUDIO_ARCH_AVX - Failed
-- Performing Test HAVE_VISUAL_STUDIO_ARCH_AVX2
-- Performing Test HAVE_VISUAL_STUDIO_ARCH_AVX2 - Failed
-- Performing Test HAVE_CLANG_MAVX
-- Performing Test HAVE_CLANG_MAVX - Success
-- Performing Test HAVE_CLANG_MBMI2
-- Performing Test HAVE_CLANG_MBMI2 - Success
-- Performing Test HAVE_BUILTIN_EXPECT
-- Performing Test HAVE_BUILTIN_EXPECT - Success
-- Performing Test HAVE_BUILTIN_CTZ
-- Performing Test HAVE_BUILTIN_CTZ - Success
-- Performing Test HAVE_ATTRIBUTE_ALWAYS_INLINE
-- Performing Test HAVE_ATTRIBUTE_ALWAYS_INLINE - Failed
-- Performing Test SNAPPY_HAVE_SSSE3
-- Performing Test SNAPPY_HAVE_SSSE3 - Failed
-- Performing Test SNAPPY_HAVE_BMI2
-- Performing Test SNAPPY_HAVE_BMI2 - Failed
-- Looking for mmap
-- Looking for mmap - found
-- Looking for sysconf
-- Looking for sysconf - found
-- Found OpenSSL: /usr/lib64/libcrypto.so (found version "1.0.2k")  
-- OPENSSL_VERSION: 1.0.2k
-- OPENSSL_INCLUDEDIRS: /usr/include
-- OPENSSL_LIBRARIES: /usr/lib64/libssl.so;/usr/lib64/libcrypto.so
-- RUBY_INCLUDE_DIR: /home/deploy/.rbenv/versions/2.7.1/include/ruby-2.7.0;/home/deploy/.rbenv/versions/2.7.1/include/ruby-2.7.0/x86_64-linux
-- RUBY_LIBRARY: 
fatal: Not a git repository (or any of the parent directories): .git
-- Configuring done
CMake Error in CMakeLists.txt:
  The compiler feature "cxx_std_17" is not known to CXX compiler

  "GNU"

  version 4.8.5.


CMake Generate step failed.  Build files cannot be regenerated correctly.
-- /tmp/cb-RelWithDebInfo-2.7.1-83-x86_64-linux-3.0.0
-- make -j4 VERBOSE=1
make: *** No targets specified and no makefile found.  Stop.
ERROR: failed to build extension in /tmp/cb-RelWithDebInfo-2.7.1-83-x86_64-linux-3.0.0/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/deploy/.rbenv/versions/2.7.1/bin/$(RUBY_BASE_NAME)

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

  /home/deploy/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/extensions/x86_64-linux/2.7.0/couchbase-3.0.0/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /home/deploy/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/couchbase-3.0.0 for inspection.
Results logged to /home/deploy/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/extensions/x86_64-linux/2.7.0/couchbase-3.0.0/gem_make.out

It looks like gem need newer glibc which is hard to update on CentOS 7. Can you confirm if this gem should work on CentOS 7 or only newer versions are supported? There are no OS mentions on https://docs.couchbase.com/ruby-sdk/3.0/project-docs/compatibility.html page.

I also tried to use gem version with included libcouchbase(from https://github.com/couchbase/couchbase-ruby-client/releases/tag/3.0.0) but it fails too:

$ ruby -r couchbase -e ‘p Couchbase::VERSION’
Traceback (most recent call last):
	1: from /home/deploy/.rbenv/versions/2.7.1/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'
/home/deploy/.rbenv/versions/2.7.1/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require': cannot load such file -- couchbase (LoadError)
	5: from /home/deploy/.rbenv/versions/2.7.1/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:156:in `require'
	4: from /home/deploy/.rbenv/versions/2.7.1/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:168:in `rescue in require'
	3: from /home/deploy/.rbenv/versions/2.7.1/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:168:in `require'
	2: from /home/deploy/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/couchbase-3.0.0-x86_64-linux/lib/couchbase.rb:16:in `<top (required)>'
	1: from /home/deploy/.rbenv/versions/2.7.1/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'
/home/deploy/.rbenv/versions/2.7.1/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require': /lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by /home/deploy/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/couchbase-3.0.0-x86_64-linux/lib/couchbase/libcouchbase.so) - /home/deploy/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/couchbase-3.0.0-x86_64-linux/lib/couchbase/libcouchbase.so (LoadError)

If you want to build couchbase ruby gem from sources, you have to make sure you have recent cmake and c++ compiler (with support of at least C++17 standard). In case of gcc, it is at least GCC7.

I will fix it in 3.0.1 release.

1 Like

I did not try to build gem itself, only to install it via gem install. I though that it would work on CentOS 7 because C SDK supports it and Python SDK lists CentOS 7 as supported too(https://docs.couchbase.com/python-sdk/current/project-docs/compatibility.html#platform-compatibility).

I will fix it in 3.0.1 release.

Thank you! Can you also update https://docs.couchbase.com/ruby-sdk/3.0/project-docs/compatibility.html with a list of supported OS?

By the way, is it possible to use couchbase ruby gem with c lib installed via https://docs.couchbase.com/c-sdk/3.0/hello-world/start-using-sdk.html#installing-binary-packages-without-a-repository? I.e. using it instead of building native extension during gem install.

Now you can install current snapshot build from official repository. We have prebuilt binaries there. You can put this line into your Gemfile

gem "couchbase", "~> 3.0.1.snapshot", :source => "https://sdk-snapshots.couchbase.com/ruby/2.7.0/"

Or directly with gem

gem install --source https://sdk-snapshots.couchbase.com/ruby/2.7.0/ couchbase --pre

Looks like 3.0.1.snapshot version works fine:

$ ruby -r couchbase -e 'p Couchbase::VERSION'
{:sdk=>"3.0.1.snapshot.679", :backend=>"1.0.1", :build_timestamp=>"2020-10-01 11:53:30", :revision=>"4c0d2423a781d3df637c65fbca3bcf91638d0d16", :platform=>"Linux-4.15.0-66-generic", :cpu=>"x86_64", :cc=>"GNU 9.3.1", :cxx=>"GNU 9.3.1", :ruby=>"2.7.0", :spdlog=>"1.6.0", :asio=>"1.18.0", :snappy=>"1.1.8", :http_parser=>"2.9.4", :openssl_headers=>"OpenSSL 1.1.1c FIPS  28 May 2019", :openssl_runtime=>"OpenSSL 1.1.1c FIPS  28 May 2019", :static_stdlib=>true, :static_openssl=>true}

Thank you!