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

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

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

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

Q&A

解決済

1回答

2368閲覧

Rails s エラーが出て困っています。

退会済みユーザー

退会済みユーザー

総合スコア0

Ruby on Rails

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

0グッド

1クリップ

投稿2018/05/22 04:09

編集2018/05/22 04:57

前提・実現したいこと

railsの動作確認を行おうとしています。
$rails s を実行しようとすると下記の様に表示されて困っています。

どなたか教えて頂けませんでしょうか?
宜しくお願い致します。

発生している問題・エラーメッセージ

$bundle install

i$ bundle install Fetching gem metadata from https://rubygems.org/.......... Fetching gem metadata from https://rubygems.org/. Resolving dependencies... Using rake 12.3.1 Using concurrent-ruby 1.0.5 Using i18n 1.0.1 Using minitest 5.11.3 Using thread_safe 0.3.6 Using tzinfo 1.2.5 Using activesupport 5.2.0 Using builder 3.2.3 Using erubi 1.7.1 Using mini_portile2 2.3.0 Fetching nokogiri 1.8.2 Installing nokogiri 1.8.2 with native extensions Gem::Ext::BuildError: ERROR: Failed to build gem native extension. current directory: /Users/eri/MyVagrant/MyPro/vendor/bundle/ruby/2.3.0/gems/nokogiri-1.8.2/ext/nokogiri /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r ./siteconf20180522-28434-1sm7ntj.rb extconf.rb --use-system-librariescurrent directory: checking if the C compiler accepts ... yes checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... no Building nokogiri using packaged libraries. Using mini_portile version 2.3.0 checking for iconv.h... yes checking for gzdopen() in -lz... yes checking for iconv... yes ************************************************************************ IMPORTANT NOTICE: Building Nokogiri with a packaged version of libxml2-2.9.7. Team Nokogiri will keep on doing their best to provide security updates in a timely manner, but if this is a concern for you and want to use the system library instead; abort this installation process and reinstall nokogiri as follows: gem install nokogiri -- --use-system-libraries [--with-xml2-config=/path/to/xml2-config] [--with-xslt-config=/path/to/xslt-config] If you are using Bundler, tell it to use the option: bundle config build.nokogiri --use-system-libraries bundle install Note, however, that nokogiri is not fully compatible with arbitrary versions of libxml2 provided by OS/package vendors. ************************************************************************ Extracting libxml2-2.9.7.tar.gz into tmp/x86_64-apple-darwin17/ports/libxml2/2.9.7... OK Running 'configure' for libxml2 2.9.7... OK Running 'compile' for libxml2 2.9.7... ERROR, review '/Users/eri/MyVagrant/MyPro/vendor/bundle/ruby/2.3.0/gems/nokogiri-1.8.2/ext/nokogiri/tmp/x86_64-apple-darwin17/ports/libxml2/2.9.7/compile.log' to see what happened. Last lines are: ======================================================================== CCLD libxml2.la CC testdso.lo CCLD testdso.la CC xmllint.o CCLD xmllint ld: warning: ignoring file /usr/local/Cellar/xz/5.2.3/lib/liblzma.dylib, file was built for x86_64 which is not the architecture being linked (i386): /usr/local/Cellar/xz/5.2.3/lib/liblzma.dylib Undefined symbols for architecture i386: "_lzma_auto_decoder", referenced from: _xz_head in libxml2.a(xzlib.o) "_lzma_code", referenced from: _xz_decomp in libxml2.a(xzlib.o) "_lzma_end", referenced from: ___libxml2_xzclose in libxml2.a(xzlib.o) "_lzma_properties_decode", referenced from: _is_format_lzma in libxml2.a(xzlib.o) ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation) make[2]: *** [xmllint] Error 1 make[1]: *** [all-recursive] Error 1 make: *** [all] Error 2 ======================================================================== *** 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=/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/$(RUBY_BASE_NAME) --help --clean --use-system-libraries --enable-static --disable-static --with-zlib-dir --without-zlib-dir --with-zlib-include --without-zlib-include=${zlib-dir}/include --with-zlib-lib --without-zlib-lib=${zlib-dir}/lib --enable-cross-build --disable-cross-build /Users/eri/MyVagrant/MyPro/vendor/bundle/ruby/2.3.0/gems/mini_portile2-2.3.0/lib/mini_portile2/mini_portile.rb:402:in `block in execute': Failed to complete compile task (RuntimeError) from /Users/eri/MyVagrant/MyPro/vendor/bundle/ruby/2.3.0/gems/mini_portile2-2.3.0/lib/mini_portile2/mini_portile.rb:373:in `chdir' from /Users/eri/MyVagrant/MyPro/vendor/bundle/ruby/2.3.0/gems/mini_portile2-2.3.0/lib/mini_portile2/mini_portile.rb:373:in `execute' from /Users/eri/MyVagrant/MyPro/vendor/bundle/ruby/2.3.0/gems/mini_portile2-2.3.0/lib/mini_portile2/mini_portile.rb:115:in `compile' from /Users/eri/MyVagrant/MyPro/vendor/bundle/ruby/2.3.0/gems/mini_portile2-2.3.0/lib/mini_portile2/mini_portile.rb:154:in `cook' from extconf.rb:365:in `block (2 levels) in process_recipe' from extconf.rb:257:in `block in chdir_for_build' from extconf.rb:256:in `chdir' from extconf.rb:256:in `chdir_for_build' from extconf.rb:364:in `block in process_recipe' from extconf.rb:262:in `tap' from extconf.rb:262:in `process_recipe' from extconf.rb:551:in `<main>' To see why this extension failed to compile, please check the mkmf.log which can be found here: /Users/eri/MyVagrant/MyPro/vendor/bundle/ruby/2.3.0/extensions/universal-darwin-17/2.3.0/nokogiri-1.8.2/mkmf.log extconf failed, exit code 1 Gem files will remain installed in /Users/eri/MyVagrant/MyPro/vendor/bundle/ruby/2.3.0/gems/nokogiri-1.8.2 for inspection. Results logged to /Users/eri/MyVagrant/MyPro/vendor/bundle/ruby/2.3.0/extensions/universal-darwin-17/2.3.0/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' --source 'https://rubygems.org/'` succeeds before bundling. In Gemfile: rails was resolved to 5.2.0, which depends on actioncable was resolved to 5.2.0, which depends on actionpack was resolved to 5.2.0, which depends on actionview was resolved to 5.2.0, which depends on rails-dom-testing was resolved to 2.0.3, which depends on nokogiri

Gemfileの中身です。

# frozen_string_literal: true source "https://rubygems.org" git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } gem "rails" gem"rdefs" gem 'therubyracer', platforms: :ruby

試したこと

$rails s -b 0.0.0.0
下記サイト様を参考
https://techacademy.jp/magazine/7197
https://qiita.com/Thort/items/f7204832ea7bc704d677
https://qiita.com/yuitnnn/items/b45bba658d86eabdbb26

補足情報(FW/ツールのバージョンなど)

os: Mac 10.13.4
ruby: 2.4.0p0
Rails: 5.2.0
sqlite3: 3.7.17
Bundler: 1.16.2
gem: 2.5.2

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

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

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

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

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

guest

回答1

0

ベストアンサー

/home/vagrant/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/bundler-1.16.2/lib/bundler/runtime.rb:84:in `rescue in block (2 levels) in require': There was an error while trying to load the gem 'uglifier'. (Bundler::GemRequireError)

Gem Load Error is: Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes.

上記のエラーメッセージから、bundle installした際に何かしらの失敗があると推測しました。
bundle install 実行時のログを追記できますでしょうか。

bundleログを受けての追記

以下の部分でインストールに失敗しています。

Plain

1IMPORTANT NOTICE: 2 3Building Nokogiri with a packaged version of libxml2-2.9.7. 4 5Team Nokogiri will keep on doing their best to provide security 6updates in a timely manner, but if this is a concern for you and want 7to use the system library instead; abort this installation process and 8reinstall nokogiri as follows: 9 10 gem install nokogiri -- --use-system-libraries 11 [--with-xml2-config=/path/to/xml2-config] 12 [--with-xslt-config=/path/to/xslt-config] 13 14If you are using Bundler, tell it to use the option: 15 16 bundle config build.nokogiri --use-system-libraries 17 bundle install

指示のとおり、以下を実行してみてください。

gem install nokogiri -- --use-system-libraries

bundle config build.nokogiri --use-system-libraries
bundle install

投稿2018/05/22 04:19

編集2018/05/22 04:32
kazto

総合スコア7196

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

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

退会済みユーザー

退会済みユーザー

2018/05/22 04:25

回答ありがとうございます。 実行ログ記載しましたので、確認宜しくお願い致します。
kazto

2018/05/22 04:33

回答更新しました。
退会済みユーザー

退会済みユーザー

2018/05/22 04:56

ローカル開発環境に入る前に、kaztoさんの指示通り実行してみました。
退会済みユーザー

退会済みユーザー

2018/05/22 04:58

bundle install 編集しましたので、宜しくお願いいたします。
kazto

2018/05/22 05:21

なるほど、つまり「--use-system-libraries」をつけても何も変わらなかった、と。 調べてみましたが、Macではnokogiriのインストールはめんどくさいようです。 https://qiita.com/nipe0324/items/b12668806ab6be890208 いったん、上記URLを参考にインストールを進めてみていただけますでしょうか。
退会済みユーザー

退会済みユーザー

2018/05/22 05:29

13:56のコメントですが、 vagrant upする前とのことです。 説明が下手で申し訳ありません。
退会済みユーザー

退会済みユーザー

2018/05/22 07:05

はい! ありがとうございました!
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問