berkshelf / vagrant-berkshelf

A Vagrant plugin to add Berkshelf integration to the Chef provisioners
Other
379 stars 100 forks source link

Error building gem native extension for ffi when installing on Mac OS 10.6.8 #285

Closed kenny-evitt closed 9 years ago

kenny-evitt commented 9 years ago

When I run vagrant plugin install vagrant-berkshelf:

Installing the 'vagrant-berkshelf' plugin. This can take a few minutes...
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:

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

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

    /opt/vagrant/embedded/bin/ruby extconf.rb 
/opt/vagrant/embedded/lib/ruby/2.0.0/mkmf.rb:292:in `initialize_copy': Bad file descriptor (Errno::EBADF)
    from /opt/vagrant/embedded/lib/ruby/2.0.0/mkmf.rb:292:in `initialize_dup'
    from /opt/vagrant/embedded/lib/ruby/2.0.0/mkmf.rb:292:in `dup'
    from /opt/vagrant/embedded/lib/ruby/2.0.0/mkmf.rb:292:in `<module:Logging>'
    from /opt/vagrant/embedded/lib/ruby/2.0.0/mkmf.rb:289:in `<module:MakeMakefile>'
    from /opt/vagrant/embedded/lib/ruby/2.0.0/mkmf.rb:47:in `<top (required)>'
    from /opt/vagrant/embedded/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /opt/vagrant/embedded/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from extconf.rb:4:in `<main>'

Gem files will remain installed in /Users/user/.vagrant.d/gems/gems/ffi-1.9.8 for inspection.
Results logged to /Users/user/.vagrant.d/gems/gems/ffi-1.9.8/ext/ffi_c/gem_make.out

I have tried many things. gem install ffi -v '1.9.8' seems to work without issue. I don't have Xcode installed but I did just install OS X GCC 10.6 version 0.3.

I found the same error reported as this issue for Vagrant itself. The issue creator described a workaround that also seems to have worked for me:

I installed Ruby 2.0.0 with RVM – rvm install 2.0.0

I noted where the binaries were located by running rvm info 2.0.0.

I copied those binaries into the Vagrant embedded Ruby directory – sudo cp /Users/user/.rvm/rubies/ruby-2.0.0-p643/bin/{ruby,irb,gem,rake} /opt/vagrant/embedded/bin/.

Running vagrant plugin install vagrant-berkshelf then seemed to work.