mitchellh / vagrant-google

Vagrant provider for GCE.
Apache License 2.0
334 stars 100 forks source link

Failing to compile nokogiri on Vagrant 2.2.8 #238

Closed gcapizzi closed 4 years ago

gcapizzi commented 4 years ago

Hi! πŸ‘‹ Installation is failing for me on latest Vagrant (2.2.8):

❯ vagrant plugin install vagrant-google
Installing the 'vagrant-google' plugin. This can take a few minutes...
Fetching formatador-0.2.5.gem
Fetching excon-0.73.0.gem
Fetching fog-core-2.1.0.gem
Fetching fog-json-1.2.0.gem
Fetching mini_portile2-2.4.0.gem
Building native extensions. This could take a while...
Vagrant failed to properly resolve required dependencies. These
errors can commonly be caused by misconfigured plugin installations
or transient network issues. The reported error is:

ERROR: Failed to build gem native extension.

    current directory: /Users/giuseppe/.vagrant.d/gems/2.6.6/gems/nokogiri-1.10.9/ext/nokogiri
/opt/vagrant/embedded/bin/ruby -I /opt/vagrant/embedded/lib/ruby/2.6.0 -r ./siteconf20200507-26352-1b2ut8d.rb extconf.rb
checking if the C compiler accepts -I/opt/vagrant/embedded/include -I/opt/vagrant/embedded/include/libxml2 -I /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/libxml2... *** 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
    --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=/opt/vagrant/embedded/bin/$(RUBY_BASE_NAME)
    --help
    --clean
/opt/vagrant/embedded/lib/ruby/2.6.0/mkmf.rb:467:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /opt/vagrant/embedded/lib/ruby/2.6.0/mkmf.rb:585:in `block in try_compile'
    from /opt/vagrant/embedded/lib/ruby/2.6.0/mkmf.rb:532:in `with_werror'
    from /opt/vagrant/embedded/lib/ruby/2.6.0/mkmf.rb:585:in `try_compile'
    from extconf.rb:138:in `nokogiri_try_compile'
    from extconf.rb:162:in `block in add_cflags'
    from /opt/vagrant/embedded/lib/ruby/2.6.0/mkmf.rb:643:in `with_cflags'
    from extconf.rb:161:in `add_cflags'
    from extconf.rb:416:in `<main>'

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

  /Users/giuseppe/.vagrant.d/gems/2.6.6/extensions/x86_64-darwin-19/2.6.0/nokogiri-1.10.9/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Users/giuseppe/.vagrant.d/gems/2.6.6/gems/nokogiri-1.10.9 for inspection.
Results logged to /Users/giuseppe/.vagrant.d/gems/2.6.6/extensions/x86_64-darwin-19/2.6.0/nokogiri-1.10.9/gem_make.out

Here are the contents of mkmf.log:

❯ cat /Users/giuseppe/.vagrant.d/gems/2.6.6/extensions/x86_64-darwin-19/2.6.0/nokogiri-1.10.9/mkmf.log
"clang -o conftest -I/opt/vagrant/embedded/include/ruby-2.6.0/x86_64-darwin19 -I/opt/vagrant/embedded/include/ruby-2.6.0/ruby/backward -I/opt/vagrant/embedded/include/ruby-2.6.0 -I. -I/opt/vagrant/embedded/include -mmacosx-version-min=10.9 -isysroot /Users/vagrant/SDKs/MacOSX10.9.sdk -I/opt/vagrant/embedded/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -I/opt/vagrant/embedded/include -mmacosx-version-min=10.9 -isysroot /Users/vagrant/SDKs/MacOSX10.9.sdk -fno-common -pipe -I/opt/vagrant/embedded/include -I/opt/vagrant/embedded/include/libxml2 -I /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/libxml2 conftest.c  -L. -L/opt/vagrant/embedded/lib -L/opt/vagrant/embedded/lib -L.  -mmacosx-version-min=10.9 -isysroot /Users/vagrant/SDKs/MacOSX10.9.sdk -fstack-protector-strong -L/opt/vagrant/embedded/lib     -lruby.2.6    "
clang: warning: no such sysroot directory: '/Users/vagrant/SDKs/MacOSX10.9.sdk' [-Wmissing-sysroot]
In file included from conftest.c:1:
In file included from /opt/vagrant/embedded/include/ruby-2.6.0/ruby.h:33:
In file included from /opt/vagrant/embedded/include/ruby-2.6.0/ruby/ruby.h:29:
/opt/vagrant/embedded/include/ruby-2.6.0/ruby/defines.h:123:10: fatal error: 'stdio.h' file not found
#include <stdio.h>
         ^~~~~~~~~
1 error generated.
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5:   return 0;
6: }
/* end */

It looks like nokogiri is failing to compile but I can't see how stdio.h might be missing, maybe something wrong with the Ruby version shipped in latest Vagrant?

I'd love to help with this but I need someone to point me in the right direction πŸ™‚

Thanks!

Temikus commented 4 years ago

Looks like MacOS SDK is missing. Can you try doing xcode-select --install and then retry installation?

gcapizzi commented 4 years ago

It looks like I already have the Command Line Tools installed:

❯ xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
gcapizzi commented 4 years ago

OK this was actually a Vagrant bug (https://github.com/hashicorp/vagrant/issues/11593), fixed in 2.2.9. I thought it was a plugin problem as all my other plugins installed successfully, but turns out this was my only plugin with a native extension! Closing πŸ™‚