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

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

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

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

Ruby on Rails

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

Q&A

解決済

2回答

1589閲覧

bundle installができない エラー

FigHy

総合スコア19

Ruby

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

Ruby on Rails

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

0グッド

2クリップ

投稿2018/01/16 09:55

編集2018/01/16 16:42

昨日、nokogiriのインストールでエラーが出るという質問を投稿させていただきました。
nokogiriのせいなのかと思っていたのですが、そもそもrails sもできないという状況です。
railsを消した記憶もないのですが・・・OSのバージョンアップのせいなのかどうなのか・・・
nokogiriも入っているみたいですが、バージョンが1.5.1みたいです。

bundlerはuser/local/binに入っています。
自分でもよくわからなくなってきたため、もしよろしければ何か解決策をいただければと思います。
よろしくお願いします><

追記

lang

1$rbenv install 2.4.1 2と打ちましたが、 3$ ruby -v 4ruby 2.3.3p222 (2016-11-21 revision 56859) [universal.x86_64-darwin17] 5と、バージョンアップもできていません。 6 7$ rails -v 8Rails is not currently installed on this system. To get the latest version, simply type: 9 10 $ sudo gem install rails 11 12You can then rerun your "rails" command. 13

試したコマンドの1部

lang

1My:.bundle fig$ bundle config 2Settings are listed in order of priority. The top value will be used. 3 4My:~ fig$ gem install rails --version='4.2.6' 5ERROR: While executing gem ... (Gem::FilePermissionError) 6 You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory. 7 8My:~ fig$ gem install bundler 9ERROR: While executing gem ... (Gem::FilePermissionError) 10 You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory. 11 12My:~ fig$ rails -v 13Rails is not currently installed on this system. To get the latest version, simply type: 14 15 $ sudo gem install rails 16 17You can then rerun your "rails" command. 18 19My:spacemarket fig$ bundle install --path vendor/bundle 20/Library/Ruby/Site/2.3.0/rubygems.rb:289:in `find_spec_for_exe': can't find gem bundler (>= 0.a) with executable bundle (Gem::GemNotFoundException) 21 from /Library/Ruby/Site/2.3.0/rubygems.rb:263:in `bin_path' 22 from /usr/local/bin/bundle:22:in `<main>' 23 24My:spacemarket fig$ bundler -v 25/Library/Ruby/Site/2.3.0/rubygems.rb:289:in `find_spec_for_exe': can't find gem bundler (>= 0.a) with executable bundler (Gem::GemNotFoundException) 26 from /Library/Ruby/Site/2.3.0/rubygems.rb:263:in `bin_path' 27 from /usr/local/bin/bundler:22:in `<main>' 28 29My:spacemarket fig$ sudo gem install rails 30Password: 31Building native extensions. This could take a while... 32ERROR: Error installing rails: 33 ERROR: Failed to build gem native extension. 34 35 current directory: /Library/Ruby/Gems/2.3.0/gems/nokogiri-1.8.1/ext/nokogiri 36/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r ./siteconf20180116-32652-18sk4ej.rb extconf.rb 37checking if the C compiler accepts ... yes 38checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... no 39Building nokogiri using packaged libraries. 40Using mini_portile version 2.3.0 41checking for iconv.h... yes 42checking for gzdopen() in -lz... yes 43checking for iconv... yes 44************************************************************************ 45IMPORTANT NOTICE: 46 47Building Nokogiri with a packaged version of libxml2-2.9.5. 48 49Team Nokogiri will keep on doing their best to provide security 50updates in a timely manner, but if this is a concern for you and want 51to use the system library instead; abort this installation process and 52reinstall nokogiri as follows: 53 54 gem install nokogiri -- --use-system-libraries 55 [--with-xml2-config=/path/to/xml2-config] 56 [--with-xslt-config=/path/to/xslt-config] 57 58If you are using Bundler, tell it to use the option: 59 60 bundle config build.nokogiri --use-system-libraries 61 bundle install 62 63Note, however, that nokogiri is not fully compatible with arbitrary 64versions of libxml2 provided by OS/package vendors. 65************************************************************************ 66Extracting libxml2-2.9.5.tar.gz into tmp/x86_64-apple-darwin17/ports/libxml2/2.9.5... OK 67Running 'configure' for libxml2 2.9.5... OK 68Running 'compile' for libxml2 2.9.5... ERROR, review '/Library/Ruby/Gems/2.3.0/gems/nokogiri-1.8.1/ext/nokogiri/tmp/x86_64-apple-darwin17/ports/libxml2/2.9.5/compile.log' to see what happened. Last lines are: 69======================================================================== 70 CCLD libxml2.la 71 CC testdso.lo 72 CCLD testdso.la 73 CC xmllint.o 74 CCLD xmllint 75ld: 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 76Undefined symbols for architecture i386: 77 "_lzma_auto_decoder", referenced from: 78 _xz_head in libxml2.a(xzlib.o) 79 "_lzma_code", referenced from: 80 _xz_decomp in libxml2.a(xzlib.o) 81 "_lzma_end", referenced from: 82 ___libxml2_xzclose in libxml2.a(xzlib.o) 83 "_lzma_properties_decode", referenced from: 84 _is_format_lzma in libxml2.a(xzlib.o) 85ld: symbol(s) not found for architecture i386 86clang: error: linker command failed with exit code 1 (use -v to see invocation) 87make[2]: *** [xmllint] Error 1 88make[1]: *** [all-recursive] Error 1 89make: *** [all] Error 2 90======================================================================== 91*** extconf.rb failed *** 92Could not create Makefile due to some reason, probably lack of necessary 93libraries and/or headers. Check the mkmf.log file for more details. You may 94need configuration options. 95 96Provided configuration options: 97 --with-opt-dir 98 --without-opt-dir 99 --with-opt-include 100 --without-opt-include=${opt-dir}/include 101 --with-opt-lib 102 --without-opt-lib=${opt-dir}/lib 103 --with-make-prog 104 --without-make-prog 105 --srcdir=. 106 --curdir 107 --ruby=/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/$(RUBY_BASE_NAME) 108 --help 109 --clean 110 --use-system-libraries 111 --enable-static 112 --disable-static 113 --with-zlib-dir 114 --without-zlib-dir 115 --with-zlib-include 116 --without-zlib-include=${zlib-dir}/include 117 --with-zlib-lib 118 --without-zlib-lib=${zlib-dir}/lib 119 --enable-cross-build 120 --disable-cross-build 121/Library/Ruby/Gems/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) 122 from /Library/Ruby/Gems/2.3.0/gems/mini_portile2-2.3.0/lib/mini_portile2/mini_portile.rb:373:in `chdir' 123 from /Library/Ruby/Gems/2.3.0/gems/mini_portile2-2.3.0/lib/mini_portile2/mini_portile.rb:373:in `execute' 124 from /Library/Ruby/Gems/2.3.0/gems/mini_portile2-2.3.0/lib/mini_portile2/mini_portile.rb:115:in `compile' 125 from /Library/Ruby/Gems/2.3.0/gems/mini_portile2-2.3.0/lib/mini_portile2/mini_portile.rb:154:in `cook' 126 from extconf.rb:365:in `block (2 levels) in process_recipe' 127 from extconf.rb:257:in `block in chdir_for_build' 128 from extconf.rb:256:in `chdir' 129 from extconf.rb:256:in `chdir_for_build' 130 from extconf.rb:364:in `block in process_recipe' 131 from extconf.rb:262:in `tap' 132 from extconf.rb:262:in `process_recipe' 133 from extconf.rb:548:in `<main>' 134 135To see why this extension failed to compile, please check the mkmf.log which can be found here: 136 137 /Library/Ruby/Gems/2.3.0/extensions/universal-darwin-17/2.3.0/nokogiri-1.8.1/mkmf.log 138 139extconf failed, exit code 1 140 141Gem files will remain installed in /Library/Ruby/Gems/2.3.0/gems/nokogiri-1.8.1 for inspection. 142Results logged to /Library/Ruby/Gems/2.3.0/extensions/universal-darwin-17/2.3.0/nokogiri-1.8.1/gem_make.out

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

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

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

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

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

guest

回答2

0

ベストアンサー

まず rbenv global でしっかり対象バージョンのrubyにrbenvがスイッチしているか確認してください
それで変更されているならbundler, gemともにrbenvでインストールしているruby以下のパスでないためこのエラーが起こっていると思われます。

rbenvでインストールしたrubyのgemは以下のパスにビルドされます.
/Users/hogehoge/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/
しかし, パスはsystemに入っているruby, 及びgemを参照するため食い違いが起こっているわけです.
要はパスを書き換えてしまえばいいのですがそれだと色々面倒なことになるので今回は違う解決策を載せておきます.
私もこの問題に陥ったため, 私の場合での解決策だと予めご了承ください.

  • sudo rbenv exec gem install bundler
  • rbenv exec bundle install --path=vendor/bundle

これでディレクトリ内のgemfileをinstallできます。
もし個別にgemをインストールしたい場合は rbenv exec gem install hogehoge
としてください.

rbenv exec の意味はrbenvでglobalになっているrubyのgemやbundlerを指定して実行します。
これによって上記の/Users/hogehoge/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems
以下にgemがインストールされ, rbenv exec bundlerで, このgems以下のbundlerを指定しているということです.

これでインストールされたgem, 例えばrailsをコマンドとして実行したい場合は
rbenv exec bundler exec rails new などで実行が可能です.
コマンドが冗長になってしまうのでそれが嫌であればaliasするかpathをわかりやすいようにexportしたほうが良いかもしれません

これで解決できない場合は一度rbenvを消し, system側のrubyも再インストールしたほうが手っ取り早いかもしれません

投稿2018/01/20 04:08

編集2018/01/20 04:15
Oyakodon

総合スコア23

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

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

FigHy

2018/01/21 17:40

ありがとうございました!無事に解決することができました!
guest

0

すでに見ているかもしれませんが、失敗ログが以下のファイルに記載されていると思いますので、もし見ていないのであれば見てみるのもいいかと思います。

/Library/Ruby/Gems/2.3.0/extensions/universal-darwin-17/2.3.0/nokogiri-1.8.1/mkmf.log

結局、nokogiriがコンパイル失敗してインストール失敗していると思います。ライブラリが不足しているからからnokogiriコンパイルできないというパターンは自分も遭遇したことがあります。

その時は、libxml2libxsltlibiconvをOS上にインストールしたら行けました。

以下も参考にしてみてはいかがでしょうか。

https://qiita.com/omega999/items/cd0420aae064cfddc725

投稿2018/01/21 04:38

yatta47

総合スコア208

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

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

FigHy

2018/01/21 17:40

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

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.50%

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

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

質問する

関連した質問