• Home »
  • Errors »
  • ERROR: Error installing webrat: Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers.

ERROR: Error installing webrat: Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers.

One of my tasks today at work was to install numerous Ruby gems on a couple of our development servers. One of those gems was called webrat which is used for “Ruby acceptance testing and for web applications”. When I attempted to install webrat using “gem install webrat” from a Linux shell I received some errors which I describe below along with how to resolve the error in my scenario. It is likely for you to get similar errors however not the same exact errors so the key is analyzing the output of the “gem install” command to see if it will lead you to resolution.

Ruby Gem: Webrat Install Error:

[root@dev ~]# gem install webrat rspec-rails rspec database_cleaner
Building native extensions.  This could take a while...
ERROR:  Error installing webrat:
        ERROR: Failed to build gem native extension.

/usr/local/bin/ruby extconf.rb
checking for iconv.h in /opt/local/include/,/opt/local/include/libxml2,/opt/local/include,/opt/local/include,/opt/local/include/libxml2,/usr/local/include,/usr/local/include/libxml2,/usr/local/include,/usr/local/include/libxml2,/usr/include,/usr/include/libxml2... yes
checking for libxml/parser.h in /opt/local/include/,/opt/local/include/libxml2,/opt/local/include,/opt/local/include,/opt/local/include/libxml2,/usr/local/include,/usr/local/include/libxml2,/usr/local/include,/usr/local/include/libxml2,/usr/include,/usr/include/libxml2... yes
checking for libxslt/xslt.h in /opt/local/include/,/opt/local/include/libxml2,/opt/local/include,/opt/local/include,/opt/local/include/libxml2,/usr/local/include,/usr/local/include/libxml2,/usr/local/include,/usr/local/include/libxml2,/usr/include,/usr/include/libxml2... no
libxslt is missing.  try 'port install libxslt' or 'yum install libxslt-devel'
*** 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/local/bin/ruby
        --with-iconv-dir
        --without-iconv-dir
        --with-iconv-include
        --without-iconv-include=${iconv-dir}/include
        --with-iconv-lib
        --without-iconv-lib=${iconv-dir}/lib
        --with-xml2-dir
        --without-xml2-dir
        --with-xml2-include
        --without-xml2-include=${xml2-dir}/include
        --with-xml2-lib
        --without-xml2-lib=${xml2-dir}/lib
        --with-xslt-dir
        --without-xslt-dir
        --with-xslt-include
        --without-xslt-include=${xslt-dir}/include
        --with-xslt-lib
        --without-xslt-lib=${xslt-dir}/lib
Gem files will remain installed in /usr/local/lib/ruby/gems/1.8/gems/nokogiri-1.4.1 for inspection.
Results logged to /usr/local/lib/ruby/gems/1.8/gems/nokogiri-1.4.1/ext/nokogiri/gem_make.out

Analyzing The Webrat Gem Install Error:

Typically you will be able to locate the specific error right in the output of a failed gem install. You may have looked over it in the above output but the third library file that the nokogiri gem depends on is where the failure is located. Now you may be thinking I was installing webrat so who cares about the nokogiri gem but the reality is that webrat requires the nokogiri gem so if this fails then the installation of webrat will also fail. If you are unable to locate the error in the output to the shell you should next check the mkmf.log file located in build directory of the failed gem such as the directory below for nokogiri.

Ruby Nokogiri Gem Build Directory:

/usr/local/lib/ruby/gems/1.8/gems/nokogiri-1.4.1/ext/nokogiri/mkmf.log

Even though we already have the error that caused the failure a quick look at the last part of the mkmf.log file displays the same type of details.

Nokogiri Gem mkmf.log Displaying Install Error Details:

nokogiri_find_header: checking for libxslt/xslt.h in /opt/local/include/,/opt/local/include/libxml2,/opt/local/include,/opt/local/in
clude,/opt/local/include/libxml2,/usr/local/include,/usr/local/include/libxml2,/usr/local/include,/usr/local/include/libxml2,/usr/in
clude,/usr/include/libxml2... -------------------- no

"gcc -E -I/usr/include/libxml2 -I/usr/include -I. -I/usr/local/lib/ruby/1.8/i686-linux -I. -I/opt/local/include/ -I/opt/local/includ
e/libxml2 -I/opt/local/include  -g -O2  -g -DXP_UNIX -O3 -Wall -Wcast-qual -Wwrite-strings -Wconversion -Wmissing-noreturn -Winline
 conftest.c -o conftest.i"
conftest.c:1:26: error: libxslt/xslt.h: No such file or directory
checked program was:
/* begin */
1: #include <libxslt/xslt.h>
/* end */

So the error is related to libxslt which can probably be resolved using the recommended resolution in the shell error output. The recommendation is to install the libxslt-devel package via yum which can be done using the below syntax on CentOS. Other package managers should be very similar and you would just need to locate the correct package name in case its a bit different.

Install libxslt-devel Using Yum On CentOS:

[root@dev gems]# yum install libxslt-devel
Setting up Install Process
Parsing package install arguments
Resolving Dependencies
--> Running transaction check
---> Package libxslt-devel.i386 0:1.1.17-2.el5_2.2 set to be updated
--> Processing Dependency: libgcrypt-devel for package: libxslt-devel
--> Processing Dependency: libexslt.so.0 for package: libxslt-devel
--> Processing Dependency: libxslt.so.1 for package: libxslt-devel
---> Package libxslt-devel.x86_64 0:1.1.17-2.el5_2.2 set to be updated
--> Running transaction check
---> Package libgcrypt-devel.i386 0:1.4.4-5.el5 set to be updated
--> Processing Dependency: libgcrypt = 1.4.4-5.el5 for package: libgcrypt-devel
--> Processing Dependency: libgpg-error-devel for package: libgcrypt-devel
---> Package libxslt.i386 0:1.1.17-2.el5_2.2 set to be updated
--> Running transaction check
---> Package libgcrypt.x86_64 0:1.4.4-5.el5 set to be updated
---> Package libgcrypt.i386 0:1.4.4-5.el5 set to be updated
---> Package libgpg-error-devel.i386 0:1.4-2 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
=============================================================================
 Package                 Arch       Version          Repository        Size
=============================================================================
Installing:
 libxslt-devel           x86_64     1.1.17-2.el5_2.2  base              308 k
 libxslt-devel           i386       1.1.17-2.el5_2.2  base              295 k
Updating:
 libgcrypt               x86_64     1.4.4-5.el5      base              233 k
 libgcrypt               i386       1.4.4-5.el5      base              250 k
Installing for dependencies:
 libgcrypt-devel         i386       1.4.4-5.el5      base              396 k
 libgpg-error-devel      i386       1.4-2            base               17 k
 libxslt                 i386       1.1.17-2.el5_2.2  base              485 k

Transaction Summary
=============================================================================
Install      5 Package(s)
Update       2 Package(s)
Remove       0 Package(s)

Total download size: 1.9 M
Is this ok [y/N]: y
Downloading Packages:
(1/7): libgpg-error-devel 100% |=========================|  17 kB    00:00
(2/7): libgcrypt-1.4.4-5. 100% |=========================| 250 kB    00:00
(3/7): libgcrypt-1.4.4-5. 100% |=========================| 233 kB    00:00
(4/7): libxslt-devel-1.1. 100% |=========================| 295 kB    00:00
(5/7): libgcrypt-devel-1. 100% |=========================| 396 kB    00:00
(6/7): libxslt-devel-1.1. 100% |=========================| 308 kB    00:00
(7/7): libxslt-1.1.17-2.e 100% |=========================| 485 kB    00:00
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Updating  : libgcrypt                    ######################### [1/9]
  Updating  : libgcrypt                    ######################### [2/9]
  Installing: libxslt                      ######################### [3/9]
  Installing: libgpg-error-devel           ######################### [4/9]
  Installing: libgcrypt-devel              ######################### [5/9]
  Installing: libxslt-devel                ######################### [6/9]
  Installing: libxslt-devel                ######################### [7/9]
  Cleanup   : libgcrypt                    ######################### [8/9]
  Cleanup   : libgcrypt                    ######################### [9/9]

Installed: libxslt-devel.x86_64 0:1.1.17-2.el5_2.2 libxslt-devel.i386 0:1.1.17-2.el5_2.2
Dependency Installed: libgcrypt-devel.i386 0:1.4.4-5.el5 libgpg-error-devel.i386 0:1.4-2 libxslt.i386 0:1.1.17-2.el5_2.2
Updated: libgcrypt.x86_64 0:1.4.4-5.el5 libgcrypt.i386 0:1.4.4-5.el5
Complete!

As you can see above there were a bunch of dependencies installed along with the libxslt-devel package but this should now clear the way to install webrat and nokogiri without issue. Below is the second attempt after resolving the only issues located during the first install attempt.

Install The Webrat Gem:

[root@dev gems]# gem install webrat
Building native extensions.  This could take a while...
Successfully installed nokogiri-1.4.1
Successfully installed rack-test-0.5.3
Successfully installed webrat-0.7.0
3 gems installed
Installing ri documentation for nokogiri-1.4.1...
No definition for parse_memory
No definition for parse_file
No definition for parse_with
No definition for get_options
No definition for set_options
Installing ri documentation for rack-test-0.5.3...
Installing ri documentation for webrat-0.7.0...
Installing RDoc documentation for nokogiri-1.4.1...
No definition for parse_memory
No definition for parse_file
No definition for parse_with
No definition for get_options
No definition for set_options
Installing RDoc documentation for rack-test-0.5.3...
Installing RDoc documentation for webrat-0.7.0...
[root@dev gems]#

This time webrat was installed properly along with two gem dependencies which included the rack-test gem and the nokogiri gem.


List Price: $39.99 USD
New From: $20.90 USD In Stock
Used from: $7.94 USD In Stock

Advanced Rails (Paperback)

By (author): Brad Ediger


List Price: $34.99 USD
New From: $4.80 USD In Stock
Used from: $0.01 USD In Stock

Share