めもめも のーと

ハマったこととか、覚えたこととか

久しぶりにRailsのbundle installではまった件

windows10のホスト上にvagrantCentOSを載せている環境。

bundle installを実行したら以下のエラー。

$ bundle install --path=vendor/bundle

~略~

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /vagrant/privatepj/rails42/vendor/bundle/ruby/2.3.0/gems/nokogiri-1.8.2/ext/nokogiri
/root/.rbenv/versions/2.3.4/bin/ruby -r ./siteconf20180608-12060-kysmi7.rb extconf.rb
checking if the C compiler accepts ... *** 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=/root/.rbenv/versions/2.3.4/bin/$(RUBY_BASE_NAME)
        --help
        --clean
/root/.rbenv/versions/2.3.4/lib/ruby/2.3.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
        from /root/.rbenv/versions/2.3.4/lib/ruby/2.3.0/mkmf.rb:571:in `block in try_compile'
        from /root/.rbenv/versions/2.3.4/lib/ruby/2.3.0/mkmf.rb:522:in `with_werror'
        from /root/.rbenv/versions/2.3.4/lib/ruby/2.3.0/mkmf.rb:571:in `try_compile'
        from extconf.rb:138:in `nokogiri_try_compile'
        from extconf.rb:162:in `block in add_cflags'
        from /root/.rbenv/versions/2.3.4/lib/ruby/2.3.0/mkmf.rb:629:in `with_cflags'
        from extconf.rb:161:in `add_cflags'
        from extconf.rb:410:in `<main>'

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

  /vagrant/privatepj/rails42/vendor/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0-static/nokogiri-1.8.2/mkmf.log

Text file busy @ unlink_internal - ./siteconf20180608-12060-kysmi7.rb

Gem files will remain installed in /vagrant/privatepj/rails42/vendor/bundle/ruby/2.3.0/gems/nokogiri-1.8.2 for inspection.
Results logged to /vagrant/privatepj/rails42/vendor/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0-static/nokogiri-1.8.2/gem_make.out

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

原因はプロジェクトの作成先ディレクトリが、vagrantWindowsと共有しているフォルダだったための模様。 確かにエラーログを見るとビルドそのものに失敗している感じだった。

こういうエラー、久しぶりだ。Rails学習の初期にWindows上に環境作ろうとしてよくはまってた。 最近は仮想環境かMac上にしか作ってなかったから油断した。

てか、まだWindowsと相性悪いのかRails。。