Search code examples
rubyrubygemslinux-mintcups

Error Installing cups Gem on Linux Mint


I'm having trouble installing the cups 0.1.10 gem. When running bundle install on my project folder the process is interrupted because of the following error:

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory: /tmp/bundler20170801-5492-c0toxgcups-0.1.10/gems/cups-0.1.10/ext
/usr/bin/ruby2.3 -r ./siteconf20170801-5492-1frgnir.rb extconf.rb
checking for main() in -lcups... 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=/usr/bin/$(RUBY_BASE_NAME)2.3
    --with-cupslib
    --without-cupslib
Couldn't find CUPS libraries on your system. Check they're installed and in your path.

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

  /tmp/bundler20170801-5492-c0toxgcups-0.1.10/extensions/x86_64-linux/2.3.0/cups-0.1.10/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /tmp/bundler20170801-5492-c0toxgcups-0.1.10/gems/cups-0.1.10 for inspection.
Results logged to /tmp/bundler20170801-5492-c0toxgcups-0.1.10/extensions/x86_64-linux/2.3.0/cups-0.1.10/gem_make.out

An error occurred while installing cups (0.1.10), and Bundler cannot continue.
Make sure that `gem install cups -v '0.1.10'` succeeds before bundling.

I've cloned the repository on OS X Sierra 10.12.6, and I get no problem at all. I've tried using rvm to install and use the same version of ruby installed on OS X, but still no luck.

The system version of Ruby on Linux Mint is ruby2.3.1pp112, and I've also installed ruby-dev using sudo apt-get install ruby2.3-dev, as I've read in many places that's a suitable solution to the problem, but it presists.


Solution

  • The error message is:

    Couldn't find CUPS libraries on your system. Check they're installed and in your path.
    

    Install the CUPS libraries and retry bundle install:

    sudo apt-get install libcups2-dev
    sudo apt-get install libcupsimage2-dev
    

    This is a common pattern in Ruby when installing gems; if it has to compile a native extension that relies on a third-party library then you need to have the third-party library installed first. Other gems like mysql2, pg, and nokogiri will all have the same behavior and require the appropriate library to be installed.