質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
Ruby on Rails 5

Ruby on Rails 5は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

RubyGems

RubyGemsはRubyによるプログラミングのためのパッケージマネジメントツールです。ユーザはこれを使用することで、Rubyライブラリのダウンロードやアップデートや、依存関係の自動解決が可能になります。

Ubuntu

Ubuntuは、Debian GNU/Linuxを基盤としたフリーのオペレーティングシステムです。

Q&A

解決済

1回答

4095閲覧

ruby.hが見つからないエラー

Kampachi_Percy

総合スコア21

Ruby on Rails 5

Ruby on Rails 5は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

RubyGems

RubyGemsはRubyによるプログラミングのためのパッケージマネジメントツールです。ユーザはこれを使用することで、Rubyライブラリのダウンロードやアップデートや、依存関係の自動解決が可能になります。

Ubuntu

Ubuntuは、Debian GNU/Linuxを基盤としたフリーのオペレーティングシステムです。

0グッド

0クリップ

投稿2019/07/24 01:00

編集2019/07/24 02:34

railsをインストールし、rails newで新規プロジェクトを生成後、bundle updateをかけたときにエラーが発生しました。

$ sudo bundle update The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`. Fetching gem metadata from https://rubygems.org/............ Fetching gem metadata from https://rubygems.org/. Resolving dependencies.... Using rake 12.3.3 Using concurrent-ruby 1.1.5 Using i18n 1.6.0 Using minitest 5.11.3 Using thread_safe 0.3.6 Using tzinfo 1.2.5 Using activesupport 5.2.3 Using builder 3.2.3 Using erubi 1.8.0 Using mini_portile2 2.4.0 Fetching nokogiri 1.10.3 Installing nokogiri 1.10.3 with native extensions Gem::Ext::BuildError: ERROR: Failed to build gem native extension. current directory: /var/lib/gems/2.5.0/gems/nokogiri-1.10.3/ext/nokogiri /usr/bin/ruby2.5 -r ./siteconf20190724-10300-1bi1wo0.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=/usr/bin/$(RUBY_BASE_NAME)2.5 --help --clean /usr/lib/ruby/2.5.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError) You have to install development tools first. from /usr/lib/ruby/2.5.0/mkmf.rb:574:in `block in try_compile' from /usr/lib/ruby/2.5.0/mkmf.rb:521:in `with_werror' from /usr/lib/ruby/2.5.0/mkmf.rb:574:in `try_compile' from extconf.rb:138:in `nokogiri_try_compile' from extconf.rb:162:in `block in add_cflags' from /usr/lib/ruby/2.5.0/mkmf.rb:632: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: /var/lib/gems/2.5.0/extensions/x86_64-linux/2.5.0/nokogiri-1.10.3/mkmf.log extconf failed, exit code 1 Gem files will remain installed in /var/lib/gems/2.5.0/gems/nokogiri-1.10.3 for inspection. Results logged to /var/lib/gems/2.5.0/extensions/x86_64-linux/2.5.0/nokogiri-1.10.3/gem_make.out An error occurred while installing nokogiri (1.10.3), and Bundler cannot continue. Make sure that `gem install nokogiri -v '1.10.3' --source 'https://rubygems.org/'` succeeds before bundling. In Gemfile: rails was resolved to 5.2.3, which depends on actioncable was resolved to 5.2.3, which depends on actionpack was resolved to 5.2.3, which depends on actionview was resolved to 5.2.3, which depends on rails-dom-testing was resolved to 2.0.3, which depends on nokogiri

指示された通りにmkmf.logを確認しました。

$ cat /var/lib/gems/2.5.0/extensions/x86_64-linux/2.5.0/nokogiri-1.10.3/mkmf.log "gcc -o conftest -I/usr/include/x86_64-linux-gnu/ruby-2.5.0 -I/usr/include/ruby-2.5.0/ruby/backward -I/usr/include/ruby-2.5.0 -I. -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -fdebug-prefix-map=/build/ruby2.5-Cn_Oyg/ruby2.5-2.5.1=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fstack-protector -rdynamic -Wl,-export-dynamic -lruby-2.5 -lpthread -lgmp -ldl -lcrypt -lm -lc " checked program was: /* begin */ 1: #include "ruby.h" 2: 3: int main(int argc, char **argv) 4: { 5: return 0; 6: } /* end */

前述の"ERROR: Failed to build gem native extension."とmkmf.logから、ruby.hが不足しているというエラーではないかと考えたので、ruby-devを導入しましたが、改善されません。
よろしくお願いします。

--ディストリビューション、バージョン情報追記
Ubuntu 18.04 LTS
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux-gnu]
ruby-dev 2.5.1
rails 5.2.3

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

yut148

2019/07/24 01:16

御利用のディストリビューションの明記をお願いします。 タグにも記載いただけた方が検索しやすいです。 また、ruby-devは具体的にはどのパッケージでしょうか。 稀にruby-devとrubyのパッケージの組み合わせが異なった場合、rubyが参照できない事もあります。
Kampachi_Percy

2019/07/24 02:35

ご指摘ありがとうございます。追記いたしました。 ruby-devとrubyのパッケージは共に2.5.1になっています。
yut148

2019/07/24 03:31

追加ありがとう御座います。 あいにくubuntuは詳しくなくすぐに再現できる環境を今は持ち合わせてはいないので即答できません。 恐縮です。
Kampachi_Percy

2019/07/24 03:50

どうにか自力で解決することができました。 お手数おかけしました。
guest

回答1

0

自己解決

https://teratail.com/questions/109106?link=qa_related_pc
を参考に、nokogiriをインストールしたあと、bundleを入れ直して再起動したところなぜかうまくいきました。
おさわがせしました。

投稿2019/07/24 03:49

Kampachi_Percy

総合スコア21

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問