Skip to content

Instantly share code, notes, and snippets.

@savishy
Last active May 25, 2018 15:50
Show Gist options
  • Save savishy/6f2d2e02f23c1eaada0957c488ae781e to your computer and use it in GitHub Desktop.
Save savishy/6f2d2e02f23c1eaada0957c488ae781e to your computer and use it in GitHub Desktop.
Vagrant tips and tricks.

Error during vagrant install: "The "libxml2" package isn't available"

The full error:

savis@freeman:~$ vagrant plugin install vagrant-aws vagrant-aws-winrm vagrant-reload
Installing the 'vagrant-aws' plugin. This can take a few minutes...
Building native extensions.  This could take a while...
Bundler, the underlying system Vagrant uses to install plugins,
reported an error. The error is shown below. These errors are usually
caused by misconfigured plugin installations or transient network
issues. The error from Bundler is:

ERROR: Failed to build gem native extension.

    current directory: C:/Users/savis/.vagrant.d/gems/2.4.2/gems/ovirt-engine-sdk-4.2.4/ext/ovirtsdk4c
C:/HashiCorp/Vagrant/embedded/mingw64/bin/ruby.exe -r ./siteconf20180421-8644-17edwfl.rb extconf.rb
checking for xml2-config... 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=C:/HashiCorp/Vagrant/embedded/mingw64/bin/$(RUBY_BASE_NAME)
        --with-libxml2-config
        --without-libxml2-config
        --with-pkg-config
        --without-pkg-config
extconf.rb:29:in `<main>': The "libxml2" package isn't available. (RuntimeError)

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

  C:/Users/savis/.vagrant.d/gems/2.4.2/extensions/x64-mingw32/2.4.0/ovirt-engine-sdk-4.2.4/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in C:/Users/savis/.vagrant.d/gems/2.4.2/gems/ovirt-engine-sdk-4.2.4 for inspection.
Results logged to C:/Users/savis/.vagrant.d/gems/2.4.2/extensions/x64-mingw32/2.4.0/ovirt-engine-sdk-4.2.4/gem_make.out

My System

  1. Vagrant 2.0.4
  2. Windows 10 x64
  3. Cygwin

What Ive tried

hashicorp/vagrant#8738

  1. Set NOKOGIRI_USE_SYSTEM_LIBRARIES=1 in Cygwin (using export command)
  2. Set the variable in system environment variables.
  3. Set the variable to true instead of 1.

Need to try

Solutions described in mitchellh/vagrant-aws#539

  1. Renamed the files ruby and rubyw packaged within Vagrant, to smething else.
  2. Installed latest version of Ruby with Devkit, from https://rubyinstaller.org/downloads/ (v2.5.1-1)

Error during vagrant up with Virtualbox - VT-x is not available

Problem

  1. Your laptop supports VT-x
  2. VT-x is enabled in the BIOS

However, vagrant up on a Virtualbox machine throws this inexplicable error.

Cause

In my case, this was because I was on Windows 10 Enterprise and Hyper-V was enabled. Virtualbox and Hyper-V do not work together.

Solution

Turn off Hyper-V. Restart the machine.

Reference: https://stackoverflow.com/questions/5482223/vt-x-is-not-available-when-i-start-my-virtual-machine

@savishy
Copy link
Author

savishy commented May 13, 2018

The extconf.rb file searches for an executable xml2-config which is not present for Windows. It gets installed by the libxml2-devel package.

Now, it is available for Cygwin.
So ... Another way out might be to install it on Cygwin?
http://cygwin.com/cgi-bin2/package-cat.cgi?file=x86_64%2Flibxml2-devel%2Flibxml2-devel-2.9.3-1&grep=.pc

UPDATE: It did get installed to Cygwin's /usr/bin.

savis@freeman:~$ which xml2-config
/usr/bin/xml2-config

But the plugin install still couldn't find the executable. Could it be a problem with PATH?

UPDATE:
The file that gets installed is xml2-config (Bash script). Perhaps extconf.rb knows we are on Windows, and is searching for a .bat script, or a .cmd script, or a .exe file.

@savishy
Copy link
Author

savishy commented May 19, 2018

UPDATE:

Found a xml2-config.bat file
https://mail.gnome.org/archives/xml/2012-December/txtbczNjoC9EX.txt

@ECHO OFF

setlocal ENABLEDELAYEDEXPANSION
rem http://batcheero.blogspot.co.il/2007/06/how-to-enabledelayedexpansion.html - windows xp

SET SELFDIR=%~dp0
IF %SELFDIR:~-1%==\ SET SELFDIR=%SELFDIR:~0,-1%
set SELFDIR=%SELFDIR:\=/%

set prefix=%SELFDIR%
set exec_prefix=%prefix%
set includedir=%prefix%/include
set libdir=%exec_prefix%/lib

IF "%1"=="" GOTO usage0

rem whats the point of resettingthes flags...
rem set cflags=false
rem set libs=false

:loop

    IF "%1"=="" Exit /B 0

    IF "%1"=="--version" (
	echo 2.4.12
	Exit /B 0
	)

    IF "%1"=="--help" (
          GOTO usage0
	)
 
    rem the code below does: if next arg is not any known argument nor empty then the next arg is prefix value otherwise print the prefix
    IF "%1"=="--prefix" ( 
          IF "%2"=="" ( SHIFT
                        echo %prefix%) ELSE (
            IF "%2"=="--cflags" ( SHIFT
                                  echo %prefix% ) ELSE (
              IF "%2"=="--libs" ( SHIFT
                                  echo %prefix%) ELSE (
                IF "%2"=="--prefix" ( SHIFT
                                      echo %prefix%) ELSE (
                 SET /A prefix=%2
                 set exec_prefix=!prefix!
                 set includedir=!prefix!/include
                 set libdir=!exec_prefix!/lib
                 SHIFT
                 SHIFT
                )
              )
            )
          )
	)

    IF "%1"=="--cflags" (

        echo -I!includedir!/libxml2/libxml -I!includedir!/libxml2 
	SHIFT
	)

    IF "%1"=="--libs" (
        echo -L!libdir! -lxml2 -lz  -liconv -lm -Wl,-s -lwsock32 -liberty -lMsup -lMstubs 
	SHIFT
	)


    GOTO :loop

Exit /B 1


:usage0

echo Usage: xml-config [OPTION]
echo _
echo Known values for OPTION are:
echo _
echo   --prefix=DIR		change libxml prefix [default $prefix]
echo   --libs		print library linking information
echo   --cflags		print pre-processor and compiler flags
echo   --help		display this help and exit
echo   --version		output version information
Exit /B 0

:usage1

echo Usage: xml-config [OPTION]
echo _
echo Known values for OPTION are:
echo _
echo   --prefix=DIR		change libxml prefix [default $prefix]
echo   --libs		print library linking information
echo   --cflags		print pre-processor and compiler flags
echo   --help		display this help and exit
echo   --version		output version information
Exit /B 1

Steps

  • Pasted above BAT script into /usr/bin/xml2-config.bat
  • Made it executable in Cygwin (chmod +x /usr/bin/xml2-config.bat
  • reran the command to install vagrant-aws: vagrant plugin install vagrant-aws --debug.

New Error libcurl

extconf.rb:40:in

': The "libcurl" package isn't available. (RuntimeError)`

@savishy
Copy link
Author

savishy commented May 25, 2018

UPDATE
As of the above comment, I stopped caring and gave up on Vagrant AWS and Windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment