• 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:

bash

  1. [root@dev ~]# gem install webrat rspec-rails rspec database_cleaner
  2. Building native extensions.  This could take a while...
  3. ERROR:  Error installing webrat:
  4.         ERROR: Failed to build gem native extension.
  5.  
  6. /usr/local/bin/ruby extconf.rb
  7. 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
  8. 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
  9. 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
  10. libxslt is missing.  try 'port install libxslt' or 'yum install libxslt-devel'
  11. *** extconf.rb failed ***
  12. Could not create Makefile due to some reason, probably lack of
  13. necessary libraries and/or headers.  Check the mkmf.log file for more
  14. details.  You may need configuration options.
  15.  
  16. Provided configuration options:
  17.         --with-opt-dir
  18.         --without-opt-dir
  19.         --with-opt-include
  20.         --without-opt-include=${opt-dir}/include
  21.         --with-opt-lib
  22.         --without-opt-lib=${opt-dir}/lib
  23.         --with-make-prog
  24.         --without-make-prog
  25.         --srcdir=.
  26.         --curdir
  27.         --ruby=/usr/local/bin/ruby
  28.         --with-iconv-dir
  29.         --without-iconv-dir
  30.         --with-iconv-include
  31.         --without-iconv-include=${iconv-dir}/include
  32.         --with-iconv-lib
  33.         --without-iconv-lib=${iconv-dir}/lib
  34.         --with-xml2-dir
  35.         --without-xml2-dir
  36.         --with-xml2-include
  37.         --without-xml2-include=${xml2-dir}/include
  38.         --with-xml2-lib
  39.         --without-xml2-lib=${xml2-dir}/lib
  40.         --with-xslt-dir
  41.         --without-xslt-dir
  42.         --with-xslt-include
  43.         --without-xslt-include=${xslt-dir}/include
  44.         --with-xslt-lib
  45.         --without-xslt-lib=${xslt-dir}/lib
  46. Gem files will remain installed in /usr/local/lib/ruby/gems/1.8/gems/nokogiri-1.4.1 for inspection.
  47. 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:

code

  1. /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:

bash

  1. nokogiri_find_header: checking for libxslt/xslt.h in /opt/local/include/,/opt/local/include/libxml2,/opt/local/include,/opt/local/in
  2. clude,/opt/local/include/libxml2,/usr/local/include,/usr/local/include/libxml2,/usr/local/include,/usr/local/include/libxml2,/usr/in
  3. clude,/usr/include/libxml2... -------------------- no
  4.  
  5. "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
  6. e/libxml2 -I/opt/local/include  -g -O2  -g -DXP_UNIX -O3 -Wall -Wcast-qual -Wwrite-strings -Wconversion -Wmissing-noreturn -Winline
  7.  conftest.c -o conftest.i"
  8. conftest.c:1:26: error: libxslt/xslt.h: No such file or directory
  9. checked program was:
  10. /* begin */
  11. 1: #include <libxslt/xslt.h>
  12. /* 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:

bash

  1. [root@dev gems]# yum install libxslt-devel
  2. Setting up Install Process
  3. Parsing package install arguments
  4. Resolving Dependencies
  5. --> Running transaction check
  6. ---> Package libxslt-devel.i386 0:1.1.17-2.el5_2.2 set to be updated
  7. --> Processing Dependency: libgcrypt-devel for package: libxslt-devel
  8. --> Processing Dependency: libexslt.so.0 for package: libxslt-devel
  9. --> Processing Dependency: libxslt.so.1 for package: libxslt-devel
  10. ---> Package libxslt-devel.x86_64 0:1.1.17-2.el5_2.2 set to be updated
  11. --> Running transaction check
  12. ---> Package libgcrypt-devel.i386 0:1.4.4-5.el5 set to be updated
  13. --> Processing Dependency: libgcrypt = 1.4.4-5.el5 for package: libgcrypt-devel
  14. --> Processing Dependency: libgpg-error-devel for package: libgcrypt-devel
  15. ---> Package libxslt.i386 0:1.1.17-2.el5_2.2 set to be updated
  16. --> Running transaction check
  17. ---> Package libgcrypt.x86_64 0:1.4.4-5.el5 set to be updated
  18. ---> Package libgcrypt.i386 0:1.4.4-5.el5 set to be updated
  19. ---> Package libgpg-error-devel.i386 0:1.4-2 set to be updated
  20. --> Finished Dependency Resolution
  21. Dependencies Resolved
  22. =============================================================================
  23.  Package                 Arch       Version          Repository        Size
  24. =============================================================================
  25. Installing:
  26.  libxslt-devel           x86_64     1.1.17-2.el5_2.2  base              308 k
  27.  libxslt-devel           i386       1.1.17-2.el5_2.2  base              295 k
  28. Updating:
  29.  libgcrypt               x86_64     1.4.4-5.el5      base              233 k
  30.  libgcrypt               i386       1.4.4-5.el5      base              250 k
  31. Installing for dependencies:
  32.  libgcrypt-devel         i386       1.4.4-5.el5      base              396 k
  33.  libgpg-error-devel      i386       1.4-2            base               17 k
  34.  libxslt                 i386       1.1.17-2.el5_2.2  base              485 k
  35.  
  36. Transaction Summary
  37. =============================================================================
  38. Install      5 Package(s)
  39. Update       2 Package(s)
  40. Remove       0 Package(s)
  41.  
  42. Total download size: 1.9 M
  43. Is this ok [y/N]: y
  44. Downloading Packages:
  45. (1/7): libgpg-error-devel 100% |=========================|  17 kB    00:00
  46. (2/7): libgcrypt-1.4.4-5. 100% |=========================| 250 kB    00:00
  47. (3/7): libgcrypt-1.4.4-5. 100% |=========================| 233 kB    00:00
  48. (4/7): libxslt-devel-1.1. 100% |=========================| 295 kB    00:00
  49. (5/7): libgcrypt-devel-1. 100% |=========================| 396 kB    00:00
  50. (6/7): libxslt-devel-1.1. 100% |=========================| 308 kB    00:00
  51. (7/7): libxslt-1.1.17-2.e 100% |=========================| 485 kB    00:00
  52. Running rpm_check_debug
  53. Running Transaction Test
  54. Finished Transaction Test
  55. Transaction Test Succeeded
  56. Running Transaction
  57.   Updating  : libgcrypt                    ######################### [1/9]
  58.   Updating  : libgcrypt                    ######################### [2/9]
  59.   Installing: libxslt                      ######################### [3/9]
  60.   Installing: libgpg-error-devel           ######################### [4/9]
  61.   Installing: libgcrypt-devel              ######################### [5/9]
  62.   Installing: libxslt-devel                ######################### [6/9]
  63.   Installing: libxslt-devel                ######################### [7/9]
  64.   Cleanup   : libgcrypt                    ######################### [8/9]
  65.   Cleanup   : libgcrypt                    ######################### [9/9]
  66.  
  67. Installed: libxslt-devel.x86_64 0:1.1.17-2.el5_2.2 libxslt-devel.i386 0:1.1.17-2.el5_2.2
  68. 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
  69. Updated: libgcrypt.x86_64 0:1.4.4-5.el5 libgcrypt.i386 0:1.4.4-5.el5
  70. 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:

bash

  1. [root@dev gems]# gem install webrat
  2. Building native extensions.  This could take a while...
  3. Successfully installed nokogiri-1.4.1
  4. Successfully installed rack-test-0.5.3
  5. Successfully installed webrat-0.7.0
  6. 3 gems installed
  7. Installing ri documentation for nokogiri-1.4.1...
  8. No definition for parse_memory
  9. No definition for parse_file
  10. No definition for parse_with
  11. No definition for get_options
  12. No definition for set_options
  13. Installing ri documentation for rack-test-0.5.3...
  14. Installing ri documentation for webrat-0.7.0...
  15. Installing RDoc documentation for nokogiri-1.4.1...
  16. No definition for parse_memory
  17. No definition for parse_file
  18. No definition for parse_with
  19. No definition for get_options
  20. No definition for set_options
  21. Installing RDoc documentation for rack-test-0.5.3...
  22. Installing RDoc documentation for webrat-0.7.0...
  23. [root@dev gems]#

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

Distributed Programming with Ruby (Paperback)


List Price: $44.99 USD
New From: $26.58 USD In Stock
Used from: $4.93 USD In Stock

Advanced Rails (Paperback)


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

Share