##vagrant上でCentOSを使ってRuby on railsのローカル開発環境を構築しようと思っています。
しかし
gem install rails
と打っても
Building native extensions. This could take a while... ERROR: Error installing rails: ERROR: Failed to build gem native extension. current directory: /home/vagrant/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/nokogiri-1.10.9/ext/nokogiri /home/vagrant/.rbenv/versions/2.6.6/bin/ruby -I /home/vagrant/.rbenv/versions/2.6.6/lib/ruby/site_ruby/2.6.0 -r ./siteconf20200628-1122-1k5kgq1.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=/home/vagrant/.rbenv/versions/2.6.6/bin/$(RUBY_BASE_NAME) --help --clean /home/vagrant/.rbenv/versions/2.6.6/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 /home/vagrant/.rbenv/versions/2.6.6/lib/ruby/2.6.0/mkmf.rb:585:in `block in try_compile' from /home/vagrant/.rbenv/versions/2.6.6/lib/ruby/2.6.0/mkmf.rb:532:in `with_werror' from /home/vagrant/.rbenv/versions/2.6.6/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 /home/vagrant/.rbenv/versions/2.6.6/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: /home/vagrant/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/extensions/x86_64-linux/2.6.0/nokogiri-1.10.9/mkmf.log extconf failed, exit code 1 Gem files will remain installed in /home/vagrant/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/nokogiri-1.10.9 for inspection. Results logged to /home/vagrant/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/extensions/x86_64-linux/2.6.0/nokogiri-1.10.9/gem_make.out
と表示され上手くインストールされません。
不思議なことに
which rails
とすると
~/.rbenv/shims/rails
と表示されます。
しかし
rails -v
とすると
Traceback (most recent call last): 20: from /home/vagrant/.rbenv/versions/2.6.6/bin/rails:23:in `<main>' 19: from /home/vagrant/.rbenv/versions/2.6.6/lib/ruby/site_ruby/2.6.0/rubygems.rb:297:in `activate_bin_path' 18: from /home/vagrant/.rbenv/versions/2.6.6/lib/ruby/site_ruby/2.6.0/rubygems.rb:297:in `synchronize' 17: from /home/vagrant/.rbenv/versions/2.6.6/lib/ruby/site_ruby/2.6.0/rubygems.rb:298:in `block in activate_bin_path' 16: from /home/vagrant/.rbenv/versions/2.6.6/lib/ruby/site_ruby/2.6.0/rubygems/specification.rb:1371:in `activate' 15: from /home/vagrant/.rbenv/versions/2.6.6/lib/ruby/site_ruby/2.6.0/rubygems/specification.rb:1389:in `activate_dependencies' 14: from /home/vagrant/.rbenv/versions/2.6.6/lib/ruby/site_ruby/2.6.0/rubygems/specification.rb:1389:in `each' 13: from /home/vagrant/.rbenv/versions/2.6.6/lib/ruby/site_ruby/2.6.0/rubygems/specification.rb:1403:in `block in activate_dependencies' 12: from /home/vagrant/.rbenv/versions/2.6.6/lib/ruby/site_ruby/2.6.0/rubygems/specification.rb:1371:in `activate' 11: from /home/vagrant/.rbenv/versions/2.6.6/lib/ruby/site_ruby/2.6.0/rubygems/specification.rb:1389:in `activate_dependencies' 10: from /home/vagrant/.rbenv/versions/2.6.6/lib/ruby/site_ruby/2.6.0/rubygems/specification.rb:1389:in `each' 9: from /home/vagrant/.rbenv/versions/2.6.6/lib/ruby/site_ruby/2.6.0/rubygems/specification.rb:1403:in `block in activate_dependencies' 8: from /home/vagrant/.rbenv/versions/2.6.6/lib/ruby/site_ruby/2.6.0/rubygems/specification.rb:1371:in `activate' 7: from /home/vagrant/.rbenv/versions/2.6.6/lib/ruby/site_ruby/2.6.0/rubygems/specification.rb:1389:in `activate_dependencies' 6: from /home/vagrant/.rbenv/versions/2.6.6/lib/ruby/site_ruby/2.6.0/rubygems/specification.rb:1389:in `each' 5: from /home/vagrant/.rbenv/versions/2.6.6/lib/ruby/site_ruby/2.6.0/rubygems/specification.rb:1403:in `block in activate_dependencies' 4: from /home/vagrant/.rbenv/versions/2.6.6/lib/ruby/site_ruby/2.6.0/rubygems/specification.rb:1371:in `activate' 3: from /home/vagrant/.rbenv/versions/2.6.6/lib/ruby/site_ruby/2.6.0/rubygems/specification.rb:1389:in `activate_dependencies' 2: from /home/vagrant/.rbenv/versions/2.6.6/lib/ruby/site_ruby/2.6.0/rubygems/specification.rb:1389:in `each' 1: from /home/vagrant/.rbenv/versions/2.6.6/lib/ruby/site_ruby/2.6.0/rubygems/specification.rb:1400:in `block in activate_dependencies' /home/vagrant/.rbenv/versions/2.6.6/lib/ruby/site_ruby/2.6.0/rubygems/dependency.rb:311:in `to_specs': Could not find 'nokogiri' (>= 1.5.9) among 104 total gem(s) (Gem::MissingSpecError) Checked in 'GEM_PATH=/home/vagrant/.gem/ruby/2.6.0:/home/vagrant/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0', execute `gem env` for more information
となってしまいます。
試行錯誤中ですが、アドバイスいただけると嬉しいです。
以前自分でググりながらrbenv,ruby-buildの他にbundleやdevelopment tools、homebrewなども開発環境に入れてしましました。
それも原因かもしれません。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。