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

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

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

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

RubyGems

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

Ruby on Rails

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

Q&A

解決済

2回答

10005閲覧

[Ruby on Rails]bundle install でのエラー解決方法

mokekepiropiro

総合スコア12

Ruby

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

RubyGems

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

Ruby on Rails

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

0グッド

0クリップ

投稿2016/10/15 11:30

編集2016/10/15 12:44

#bundle install でエラー
Railsチュートリアルを行っている最中なのですが、
下記エラーが発生し困っております。

解決方法をググって色々探し、試してみたのですが解決できませんでした。

また、関係あるかどうかわかりませんが
プロジェクトディレクトリ内でrails -v を実行するとエラーが表示されます。

vagrant@vagrant-ubuntu-trusty-64:/vagrant/sample_app$ rails -v /home/vagrant/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/dependency.rb:319:in ` to_specs': Could not find 'railties' (>= 0.a) among 33 total gem(s) (Gem::LoadError ) Checked in 'GEM_PATH=/vagrant/sample_app/path/ruby/2.3.0', execute `gem env` for mo re information from /home/vagrant/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/dependenc y.rb:328:in `to_spec' from /home/vagrant/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/ kernel_gem.rb:65:in `gem' from /home/vagrant/.rvm/gems/ruby-2.3.1/bin/rails:22:in `<main>' from /home/vagrant/.rvm/gems/ruby-2.3.1/bin/ruby_executable_hooks:15:in `ev al' from /home/vagrant/.rvm/gems/ruby-2.3.1/bin/ruby_executable_hooks:15:in `<m ain>'

##エラー内容

vagrant@vagrant-ubuntu-trusty-64:/vagrant/sample_app$ bundle install /*中略*/ Installing nokogiri 1.6.8.1 with native extensions Using rack-test 0.6.3 Using sprockets 3.7.0 Gem::Ext::BuildError: ERROR: Failed to build gem native extension. current directory: /vagrant/sample_app/path/ruby/2.3.0/gems/nio4r-1.2.1/ext/nio4r /home/vagrant/.rvm/rubies/ruby-2.3.1/bin/ruby -r ./siteconf20161015-19290-l2ka0a.rb extconf.rb checking for unistd.h... yes checking for rb_thread_blocking_region()... no checking for rb_thread_call_without_gvl()... yes checking for sys/select.h... yes checking for poll.h... yes checking for sys/epoll.h... yes checking for sys/event.h... no checking for port.h... no checking for sys/resource.h... yes creating Makefile To see why this extension failed to compile, please check the mkmf.log which can be found here: /vagrant/sample_app/path/ruby/2.3.0/extensions/x86_64-linux/2.3.0/nio4r-1.2.1/mkmf. log Text file busy @ unlink_internal - ./siteconf20161015-19290-l2ka0a.rb Gem files will remain installed in /vagrant/sample_app/path/ruby/2.3.0/gems/nio4r-1.2.1 for inspection. Results logged to /vagrant/sample_app/path/ruby/2.3.0/extensions/x86_64-linux/2.3.0/nio4r-1.2.1/gem_m ake.out An error occurred while installing nio4r (1.2.1), and Bundler cannot continue. Make sure that `gem install nio4r -v '1.2.1'` succeeds before bundling.

##環境

  • Ruby 2.3.1
  • Rails 5.0.0.1
  • Vagrant
  • Ubuntu 14

##mkmf.log

have_header: checking for unistd.h... -------------------- yes checked program was: /* begin */ 1: #include "ruby.h" 2: 3: int main(int argc, char **argv) 4: { 5: return 0; 6: } /* end */ checked program was: /* begin */ 1: #include "ruby.h" 2: 3: #include <unistd.h> /* end */ -------------------- have_func: checking for rb_thread_blocking_region()... -------------------- no conftest.c: In function ‘t’: conftest.c:13:57: error: ‘rb_thread_blocking_region’ undeclared (first use in this function) int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_thread_blocking_region; return !p; } ^ conftest.c:13:57: note: each undeclared identifier is reported only once for each function it appears in checked program was: /* begin */ 1: #include "ruby.h" 2: 3: /*top*/ 4: extern int t(void); 5: int main(int argc, char **argv) 6: { 7: if (argc > 1000000) { 8: printf("%p", &t); 9: } 10: 11: return 0; 12: } 13: int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_thread_blocking_region; return !p; } /* end */ /tmp/cc8EA8BT.o: In function `t': /vagrant/sample_app/path/ruby/2.3.0/gems/nio4r-1.2.1/ext/nio4r/conftest.c:14: undefined reference to `rb_thread_blocking_region' collect2: error: ld returned 1 exit status checked program was: /* begin */ 1: #include "ruby.h" 2: 3: /*top*/ 4: extern int t(void); 5: int main(int argc, char **argv) 6: { 7: if (argc > 1000000) { 8: printf("%p", &t); 9: } 10: 11: return 0; 12: } 13: extern void rb_thread_blocking_region(); 14: int t(void) { rb_thread_blocking_region(); return 0; } /* end */ -------------------- have_func: checking for rb_thread_call_without_gvl()... -------------------- yes conftest.c: In function ‘t’: conftest.c:13:57: error: ‘rb_thread_call_without_gvl’ undeclared (first use in this function) int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_thread_call_without_gvl; return !p; } ^ conftest.c:13:57: note: each undeclared identifier is reported only once for each function it appears in checked program was: /* begin */ 1: #include "ruby.h" 2: 3: /*top*/ 4: extern int t(void); 5: int main(int argc, char **argv) 6: { 7: if (argc > 1000000) { 8: printf("%p", &t); 9: } 10: 11: return 0; 12: } 13: int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_thread_call_without_gvl; return !p; } /* end */ checked program was: /* begin */ 1: #include "ruby.h" 2: 3: /*top*/ 4: extern int t(void); 5: int main(int argc, char **argv) 6: { 7: if (argc > 1000000) { 8: printf("%p", &t); 9: } 10: 11: return 0; 12: } 13: extern void rb_thread_call_without_gvl(); 14: int t(void) { rb_thread_call_without_gvl(); return 0; } /* end */ -------------------- have_header: checking for sys/select.h... -------------------- yes checked program was: /* begin */ 1: #include "ruby.h" 2: 3: #include <sys/select.h> /* end */ -------------------- have_header: checking for poll.h... -------------------- yes checked program was: /* begin */ 1: #include "ruby.h" 2: 3: #include <poll.h> /* end */ -------------------- have_header: checking for sys/epoll.h... -------------------- yes checked program was: /* begin */ 1: #include "ruby.h" 2: 3: #include <sys/epoll.h> /* end */ -------------------- have_header: checking for sys/event.h... -------------------- no conftest.c:3:23: fatal error: sys/event.h: No such file or directory #include <sys/event.h> ^ compilation terminated. checked program was: /* begin */ 1: #include "ruby.h" 2: 3: #include <sys/event.h> /* end */ -------------------- have_header: checking for port.h... -------------------- no conftest.c:3:18: fatal error: port.h: No such file or directory #include <port.h> ^ compilation terminated. checked program was: /* begin */ 1: #include "ruby.h" 2: 3: #include <port.h> /* end */ -------------------- have_header: checking for sys/resource.h... -------------------- yes checked program was: /* begin */ 1: #include "ruby.h" 2: 3: #include <sys/resource.h> /* end */ --------------------

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

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

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

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

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

guest

回答2

0

自分の環境が以下の状態で

sh

1$ cat /etc/os-release | grep VERSION= 2VERSION="14.04.5 LTS, Trusty Tahr" 3 4$ rvm -v 5rvm 1.27.0 (latest) 6 7$ gem env 8RubyGems Environment: 9 - RUBYGEMS VERSION: 2.5.1 10 - RUBY VERSION: 2.3.0 (2015-12-25 patchlevel 0) [x86_64-linux] 11 - INSTALLATION DIRECTORY: $HOME/.rvm/gems/ruby-2.3.0 12 - USER INSTALLATION DIRECTORY: $HOME/.gem/ruby/2.3.0 13 - RUBY EXECUTABLE: $HOME/.rvm/rubies/ruby-2.3.0/bin/ruby 14 - EXECUTABLE DIRECTORY: $HOME/.rvm/gems/ruby-2.3.0/bin 15 - SPEC CACHE DIRECTORY: $HOME/.gem/specs 16 - SYSTEM CONFIGURATION DIRECTORY: /etc 17 - RUBYGEMS PLATFORMS: 18 - ruby 19 - x86_64-linux 20 - GEM PATHS: 21 - $HOME/.rvm/gems/ruby-2.3.0 22 - $HOME/.rvm/gems/ruby-2.3.0@global 23 24$ rails -v 25Rails 5.0.0.1

nio4rインストールされています

sh

1$ gem list | grep nio4r 2nio4r (1.2.1)

gem_make.out の内容は以下の通り。

sh

1$ head -n 20 gem_make.out 2current directory: $HOME/.rvm/gems/ruby-2.3.0/gems/nio4r-1.2.1/ext/nio4r 3$HOME/.rvm/rubies/ruby-2.3.0/bin/ruby -r ./siteconf20161015-26705-1jnhbkz.rb extconf.rb 4checking for unistd.h... yes 5checking for rb_thread_blocking_region()... no 6checking for rb_thread_call_without_gvl()... yes 7checking for sys/select.h... yes 8checking for poll.h... yes 9checking for sys/epoll.h... yes 10checking for sys/event.h... no 11checking for port.h... no 12checking for sys/resource.h... yes 13creating Makefile 14 15To see why this extension failed to compile, please check the mkmf.log which can be found here: 16 17 $HOME/.rvm/gems/ruby-2.3.0/extensions/x86_64-linux/2.3.0/nio4r-1.2.1/mkmf.log 18 19current directory: $HOME/.rvm/gems/ruby-2.3.0/gems/nio4r-1.2.1/ext/nio4r 20make "DESTDIR=" clean

違いとしてText file busy @ unlink_internalが気になったのでググってみたら、以下のような情報がありました。

投稿2016/10/15 14:50

編集2016/10/15 15:17
tkmtmkt

総合スコア1800

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

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

0

ベストアンサー

bundle install

Gem::Ext::BuildError: ERROR: Failed to build gem native extension. current directory: /vagrant/sample_app/path/ruby/2.3.0/gems/nio4r-1.2.1/ext/nio4r /home/vagrant/.rvm/rubies/ruby-2.3.1/bin/ruby -r ./siteconf20161015-19290-l2ka0a.rb extconf.rb checking for unistd.h... yes checking for rb_thread_blocking_region()... no checking for rb_thread_call_without_gvl()... yes checking for sys/select.h... yes checking for poll.h... yes checking for sys/epoll.h... yes checking for sys/event.h... no checking for port.h... no checking for sys/resource.h... yes creating Makefile To see why this extension failed to compile, please check the mkmf.log which can be found here: /vagrant/sample_app/path/ruby/2.3.0/extensions/x86_64-linux/2.3.0/nio4r-1.2.1/mkmf. log Text file busy @ unlink_internal - ./siteconf20161015-19290-l2ka0a.rb Gem files will remain installed in /vagrant/sample_app/path/ruby/2.3.0/gems/nio4r-1.2.1 for inspection. Results logged to /vagrant/sample_app/path/ruby/2.3.0/extensions/x86_64-linux/2.3.0/nio4r-1.2.1/gem_m ake.out An error occurred while installing nio4r (1.2.1), and Bundler cannot continue. Make sure that `gem install nio4r -v '1.2.1'` succeeds before bundling.

と言う部分から、依存関係で必要になったnio4rというパッケージのインストールに失敗しています。失敗した理由はnio4rのコンパイルに失敗したからです。コンパイルに失敗した理由は、

To see why this extension failed to compile, please check the mkmf.log which can be found here: /vagrant/sample_app/path/ruby/2.3.0/extensions/x86_64-linux/2.3.0/nio4r-1.2.1/mkmf. log

と言う記載通り、ログファイルである/vagrant/sample_app/path/ruby/2.3.0/extensions/x86_64-linux/2.3.0/nio4r-1.2.1/mkmf.logを確認する必要があります。該当のログファイルの内容を確認してください。

※ ログファイルの内容がよくわからないから貼り付けるという場合は、コメントでは無く質問に追記するようにしてください。コメント欄は狭く、また、Markdownに対応していないため、読みづらくなる場合があります。


【追記】

Windows上でVagrantを使って、そのままゲスト側でWindows領域をマウントし、そのマウントした場所で色々操作しようとした場合におきる不具合の可能性があります。下記の何れかをお試しください。

  1. マウントしている/vagrant上でファイルを一切使わず、全てを別の場所にコピーして、そこで実行してみてください。rubyのパスなども全て変更してください。
  2. Synced FolderのtypeをVirtualBoxからrsyncに変えてみてください。下記設定を追加すれば変更できます。

config.vm.synced_folder ".", "/vagrant", type: "rsync"
注意点として、Windowsにrsyncが必要です。また、一部のバージョンでWindowsのみ失敗するバグが報告されています。また、rysncタイプはvagrant upしたときやvagrant rsyncした時しか同期されません。
やり方の参考: http://qiita.com/derui@github/items/44977e0de5b892009b2f
3. ホストにWindowsを使わず、MacやLinuxを使ってください。

どういうことかというと、Windows版VirtualBoxでLinuxから共有領域をマウントしたとき、シンボリックリンクが作れない、chmodやchownが正しく動かない、などの制限があり、実行される内容によっては失敗する場合があるからです。

投稿2016/10/15 11:54

編集2016/10/15 13:15
raccy

総合スコア21733

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

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

mokekepiropiro

2016/10/15 12:49

回答ありがとうございます。 mkmf.logファイルの内容を追記しました。 ※文字数制限の関係で一部省略してあります。 ログ・ファイルの内容を確認しましたがわたしにはよくわかりません。 もし何かわかるようでしたらご教授お願い致します。
raccy

2016/10/15 12:58

ログファイルの中身はこれだけですか…configチェックの内容しか載ってなくて、ちょっと原因が違うかも知れません。 うーん、もしかして、VagrantはWindowsで動作させて、Windows上のフォルダを直接マウント(/vagarntにアクセスすると直接Windowsになるような)していますか?
mokekepiropiro

2016/10/15 13:01

vagrantのマウントの設定はデフォルトのままなので そうかもしれません
raccy

2016/10/15 13:17

Windows特有の問題かも知れません。追記を参考にしてみてください。
mokekepiropiro

2016/10/15 13:26

丁寧な回答ありがとうございます。 追記していただいた内容の「1」についてはすでに試していて、同じエラーで失敗しました。 rubyを2.2.5にダウングレードもしてみましたが... 「2」「3」についてはまだ試していないので試してみます。
raccy

2016/10/15 13:30

/vagrant/sample_appを別のフォルダ/home/vagrant/sample_appに持って行っても駄目ですか?その配下の処理でエラーが起きているような気がします。
tkmtmkt

2016/10/15 14:23

gem_make.out ファイルが残っているのであれば、以下のように内容を確認してみてはどうでしょう。 tail -n 40 /vagrant/sample_app/path/ruby/2.3.0/extensions/x86_64-linux/2.3.0/nio4r-1.2.1/gem_make.out
raccy

2016/10/15 14:24

うーん、あとは /vagrant/sample_app/path/ruby/2.3.0/extensions/x86_64-linux/2.3.0/nio4r-1.2.1/gem_make.out の中身を確認するぐらいでしょうか。内容にエラーが無いか見てみてください。
mokekepiropiro

2016/10/16 13:21

/home/vagrant に新しくプロジェクトを作り直したらとりあえず動作したので、 rsyncで必要なファイルを同期させて、/home/vagrant で実行するようにしました。 もともとのプロジェクトはどう頑張っても動作しませんでした... おかげさまで、とりあえず解決しました。 回答ありがとうございました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.50%

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

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

質問する

関連した質問