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

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

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

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

RubyGems

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

Ruby on Rails

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

Q&A

2回答

6320閲覧

Rubyのインストールのbundle installでエラーが出てしまいます。

KyutoYosihama

総合スコア30

Ruby

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

RubyGems

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

Ruby on Rails

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

0グッド

0クリップ

投稿2020/03/11 05:58

qiita
のRailsインストールの部分で詰まっています。

bundle install --path=vendor/bundle

を打つと、

An error occurred while installing mysql2 (0.5.3), and Bundler cannot continue.
Make sure that gem install mysql2 -v ‘0.5.3’ --source ‘https://rubygems.org/’ succeeds before
bundling.

が表示されてしまいます。

qiita

qiita

などを参考に調べているのですが、解決せず。。
また、

mysql client is missing. You may need to ‘brew install mysql’ or ‘port install mysql’, and try
again.

*** 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.

上記のメッセージも出ているので、mkmf.logをみたのですがわからず。。

mysqlは

brew install mysql@5.7

で入れていて、
mysql --version

mysql Ver 14.14 Distrib 5.7.29, for osx10.14 (x86_64) using EditLine wrapper

です。

$ bundle config --local build.mysql2 "--with-ldflags=-L/usr/local/opt/openssl/lib"

を打ったあとに、

bundle install

をしてもダメでした。

どうすれば良いか、教えていただけますでしょうか?
お手数お掛けしますが、よろしくおねがい致します。

現状、bundle installを打って出ているメッセージを以下に載せます。

Fetching gem metadata from https://rubygems.org/....... Fetching gem metadata from https://rubygems.org/. Resolving dependencies............................................. Using rake 13.0.1 Using CFPropertyList 2.3.6 Using concurrent-ruby 1.1.6 Using i18n 1.8.2 Using minitest 5.14.0 Using thread_safe 0.3.6 Using tzinfo 1.2.6 Using activesupport 5.0.7.2 Using builder 3.2.4 Using erubis 2.7.0 Using mini_portile2 2.4.0 Using nokogiri 1.10.9 Using rails-dom-testing 2.0.3 Using crass 1.0.6 Using loofah 2.4.0 Using rails-html-sanitizer 1.3.0 Using actionview 5.0.7.2 Using rack 2.2.2 Using rack-test 0.6.3 Using actionpack 5.0.7.2 Using nio4r 2.5.2 Using websocket-extensions 0.1.4 Using websocket-driver 0.6.5 Using actioncable 5.0.7.2 Using globalid 0.4.2 Using activejob 5.0.7.2 Using mini_mime 1.0.2 Using mail 2.7.1 Using actionmailer 5.0.7.2 Using activemodel 5.0.7.2 Using arel 7.1.4 Using activerecord 5.0.7.2 Using multi_json 1.14.1 Using method_source 0.9.2 Using thor 0.20.3 Using railties 5.0.7.2 Using activerecord-session_store 1.1.3 Using public_suffix 4.0.3 Using addressable 2.7.0 Using gyoku 1.3.1 Using akami 1.3.1 Using ast 2.4.0 Using parser 2.7.0.4 Using astrolabe 1.3.1 Using execjs 2.7.0 Using autoprefixer-rails 8.6.5 Using awesome_print 1.8.0 Using bcrypt 3.1.13 Using coderay 1.1.2 Using erubi 1.9.0 Using better_errors 2.6.0 Using debug_inspector 0.0.3 Using binding_of_caller 0.8.0 Using uniform_notifier 1.13.0 Using bullet 6.1.0 Using bundler 2.1.4 Using byebug 11.0.1 Using cancancan 3.0.2 Using mini_magick 4.10.1 Using ffi 1.12.2 Using ruby-vips 2.0.17 Using image_processing 1.10.3 Using mimemagic 0.3.4 Using carrierwave 2.1.0 Using chartkick 3.3.1 Using multipart-post 2.1.1 Using faraday 0.17.3 Using chatwork 0.4.1 Using chronic 0.10.2 Using orm_adapter 0.5.0 Using ckeditor 5.1.0 Using coffee-script-source 1.12.2 Using coffee-script 2.4.1 Using coffee-rails 4.1.1 Using deep_merge 1.2.1 Using dry-core 0.4.9 Using dry-configurable 0.8.3 Using dry-equalizer 0.2.2 Using dry-logic 0.6.1 Using dry-container 0.7.2 Using dry-inflector 0.1.2 Using dry-types 0.15.0 Using dry-validation 0.13.0 Using config 1.7.2 Using connection_pool 2.2.2 Using cookiejar 0.3.3 Using cropper-rails 2.3.2.1 Using daemons 1.3.1 Using database_cleaner 1.8.3 Using diff-lcs 1.3 Using unf_ext 0.0.7.6 Using unf 0.1.4 Using domain_name 0.5.20190701 Using dotenv 2.7.5 Using dotenv-rails 2.7.5 Using sprockets 3.7.2 Using sprockets-rails 3.2.1 Using rails 5.0.7.2 Using dropzonejs-rails 0.8.4 Using eventmachine 1.2.7 Using em-socksify 0.3.2 Using http_parser.rb 0.6.0 Using em-http-request 1.1.5 Using excon 0.72.0 Using factory_bot 5.1.1 Using factory_bot_rails 5.1.1 Using faker 2.10.2 Using fast-stemmer 1.0.2 Using faye-websocket 0.10.9 Using faye 1.2.4 Using fission 0.5.0 Using formatador 0.2.5 Using fog-core 1.45.0 Using fog-json 1.2.0 Using ipaddress 0.8.3 Using xml-simple 1.1.5 Using fog-aliyun 0.3.6 Using fog-xml 0.1.3 Using fog-atmos 0.1.0 Using fog-aws 2.0.1 Using mime-types-data 3.2019.1009 Using mime-types 3.3.1 Using fog-brightbox 0.16.1 Using fog-cloudatcost 0.1.2 Using fog-digitalocean 0.4.0 Using fog-dnsimple 1.0.0 Using fog-dynect 0.0.3 Using fog-ecloud 0.3.0 Using fog-google 0.1.0 Using fog-internet-archive 0.0.1 Using fog-joyent 0.0.1 Using fog-local 0.6.0 Using fog-openstack 0.3.10 Using fog-powerdns 0.2.0 Using fog-profitbricks 4.1.1 Using fog-rackspace 0.1.6 Using fog-radosgw 0.0.5 Using fog-riakcs 0.1.0 Using fog-sakuracloud 1.7.5 Using fog-serverlove 0.1.2 Using fog-softlayer 1.1.4 Using fog-storm_on_demand 0.1.1 Using fog-terremark 0.1.0 Using fog-vmfusion 0.1.0 Using fog-voxel 0.1.0 Using json 1.8.6 Using optimist 3.0.0 Using rbvmomi 2.3.0 Using fog-vsphere 3.2.5 Using xmlrpc 0.3.0 Using fog-xenserver 1.0.0 Using fog 1.41.0 Using font-awesome-rails 4.7.0.5 Using geokit 1.13.1 Using gmo 0.4.0 Using request_store 1.5.0 Using gon 6.3.2 Using rb-fsevent 0.10.3 Using rb-inotify 0.10.1 Using listen 3.2.1 Using lumberjack 1.2.4 Using nenv 0.3.0 Using shellany 0.0.1 Using notiffany 0.1.3 Using pry 0.12.2 Using guard 2.16.1 Using guard-compat 1.2.1 Using rspec-support 3.9.2 Using rspec-core 3.9.1 Using rspec-expectations 3.9.0 Using rspec-mocks 3.9.1 Using rspec 3.9.0 Using guard-rspec 4.7.3 Using temple 0.8.2 Using tilt 2.0.10 Using haml 5.1.2 Using hashie 4.1.0 Using holiday_jp 0.7.1 Using http-accept 1.7.0 Using http-cookie 1.0.3 Using multi_xml 0.6.0 Using httparty 0.18.0 Using socksify 1.7.1 Using httpi 2.4.4 Using hubspot-ruby 0.9.0 Using jbuilder 2.10.0 Using jquery-rails 4.3.5 Using turbolinks-source 5.2.0 Using turbolinks 5.2.1 Using jquery-turbolinks 2.1.0 Using jquery-ui-rails 6.0.1 Using jwt 2.2.1 Using kaminari-core 1.2.0 Using kaminari-actionview 1.2.0 Using kaminari-activerecord 1.2.0 Using kaminari 1.2.0 Using rjb 1.6.1 Using yajl-ruby 1.4.1 Using kuromoji-ruby 0.0.4 Using libv8 3.16.14.19 (x86_64-darwin-18) Using magnific-popup-rails 1.1.0 Using ruby2_keywords 0.0.2 Using mustermann 1.1.1 Using rack-protection 2.0.8.1 Using sinatra 2.0.8.1 Using thin 1.7.2 Using skinny 0.2.2 Using sqlite3 1.4.2 Using sqlite3-ruby 1.3.3 Using mailcatcher 0.2.4 Using meta-tags 2.13.0 Fetching mysql2 0.5.3 Installing mysql2 0.5.3 with native extensions Gem::Ext::BuildError: ERROR: Failed to build gem native extension. current directory: /Users/user/workspace/kbr_server/vendor/bundler/ruby/2.3.0/gems/mysql2-0.5.3/ext/mysql2 /Users/user/.rbenv/versions/2.3.1/bin/ruby -I /Users/user/.rbenv/versions/2.3.1/lib/ruby/site_ruby/2.3.0 -r ./siteconf20200311-58269-p2qkug.rb extconf.rb --with-ldflags\=-L/usr/local/opt/openssl@1.1/lib checking for rb_absint_size()... yes checking for rb_absint_singlebit_p()... yes checking for rb_wait_for_single_fd()... yes checking for main() in -lmysqlclient... no ----- mysql client is missing. You may need to 'brew install mysql' or 'port install mysql', and try again. ----- *** 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=/Users/user/.rbenv/versions/2.3.1/bin/$(RUBY_BASE_NAME) --with-mysql-dir --without-mysql-dir --with-mysql-include --without-mysql-include=${mysql-dir}/include --with-mysql-lib --without-mysql-lib=${mysql-dir}/lib --with-mysql-config --without-mysql-config --with-mysql-dir --without-mysql-dir --with-mysql-include --without-mysql-include=${mysql-dir}/include --with-mysql-lib --without-mysql-lib=${mysql-dir}/lib --with-mysqlclientlib --without-mysqlclientlib To see why this extension failed to compile, please check the mkmf.log which can be found here: /Users/user/workspace/kbr_server/vendor/bundler/ruby/2.3.0/extensions/x86_64-darwin-18/2.3.0-static/mysql2-0.5.3/mkmf.log extconf failed, exit code 1 Gem files will remain installed in /Users/user/workspace/kbr_server/vendor/bundler/ruby/2.3.0/gems/mysql2-0.5.3 for inspection. Results logged to /Users/user/workspace/kbr_server/vendor/bundler/ruby/2.3.0/extensions/x86_64-darwin-18/2.3.0-static/mysql2-0.5.3/gem_make.out An error occurred while installing mysql2 (0.5.3), and Bundler cannot continue. Make sure that `gem install mysql2 -v '0.5.3' --source 'https://rubygems.org/'` succeeds before bundling. In Gemfile: mysql2

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

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

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

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

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

hoshi-takanori

2020/03/11 06:59

/usr/local/lib/libmysqlclient.* とか /usr/local/include/mysql って存在してますか?
KyutoYosihama

2020/03/11 07:12

lsでみましたが両方存在していなかったです。。
hoshi-takanori

2020/03/11 07:19

エラーメッセージを見ると -lmysqlclient がないと言ってますので、mysql のヘッダやライブラリの場所(たぶん /usr/local/Cellar/mysql@5.7/ あたり)を探して、bundle config --local build.mysql2 で --with-mysql-include や --with-mysql-lib などの設定が必要だと思います。
hoshi-takanori

2020/03/11 07:27

または、brew link mysql@5.7 でいけるかも…。
KyutoYosihama

2020/03/11 07:35

>mysql のヘッダやライブラリの場所(たぶん /usr/local/Cellar/mysql@5.7/ あたり) というのはwhich mysqlで表示される場所でしょうか? >bundle config --local build.mysql2 で --with-mysql-include や --with-mysql-lib などの設定が必要だと思います。 というのは、brew info openssl を打ったら export LDFLAGS=“-L/usr/local/opt/openssl@1.1/lib” export CPPFLAGS=“-I/usr/local/opt/openssl@1.1/include” とあったので、 $ bundle config --local build.mysql2 “--with-cppflags=-I/usr/local/opt/openssl@1.1/include” $ bundle config --local build.mysql2 “--with-ldflags=-L/usr/local/opt/openssl@1.1/lib” を打ったのですが、それとはまた違うのでしょうか?
hoshi-takanori

2020/03/11 07:47

openssl というのは暗号通信ライブラリで、それとは別に MySQL そのもののライブラリが必要です。 で、brew link mysql@5.7 すればたぶん標準的な場所 (/usr/local/lib/libmysqlclient.* や /usr/local/include/mysql) にシンボリックリンクが作られるので、bundle config しなくて良くなるかもです。
KyutoYosihama

2020/03/11 08:14

>brew link mysql@5.7 を打つと >Warning: mysql@5.7 is keg-only and must be linked with --force > >If you need to have this software first in your PATH instead consider running: > echo 'export PATH="/usr/local/opt/mysql@5.7/bin:$PATH"' >> ~/.bash_profile と出てきたのですが、.bash_profileには export PATH="/usr/local/opt/mysql@5.7/bin:$PATH はすでに記載があって、ちゃんとした動作したのがわからないのですが、どう調べればいいのでしょうか?
hoshi-takanori

2020/03/11 08:59

PATH の設定は mysql コマンドを使えるようにするためですが、ビルドするためにはヘッダーファイルやライブラリの場所を指定する必要がありまして…。MySQL の最新版を入れる予定がないのでしたら、brew link mysql@5.6 --force して bundle install すればいいと思います。
KyutoYosihama

2020/03/11 09:19

すいません、全然わからなくて。。 mysqlは5.6に入れ直す必要があるということでしょうか?
hoshi-takanori

2020/03/11 09:22

あー、ごめんなさい。5.7 でしたね。brew link mysql@5.7 --force です。
KyutoYosihama

2020/03/11 09:42

すいません。よくわかっていなくて。。 上記を打つと Linking /usr/local/Cellar/mysql@5.7/5.7.29... 87 symlinks created If you need to have this software first in your PATH instead consider running: echo 'export PATH="/usr/local/opt/mysql@5.7/bin:$PATH"' >> ~/.bash_profile となりました。 bundle install は bundle install --path=vendor/bundle で打っても大丈夫でしょうか?
KyutoYosihama

2020/03/11 09:56

試してみましたが、ダメでした。。
hoshi-takanori

2020/03/11 10:10

それは残念。では、 bundle config --local build.mysql2 “--with-mysql-dir=/usr/local/opt/mysql@5.7” ですかね。
KyutoYosihama

2020/03/11 10:27

現状の説明をすると、 bundle install をすると以下 /Users/user/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.16.4/lib/bundler/rubygems_integration.rb:200: warning: constant Gem::ConfigMap is deprecated Fetching gem metadata from https://rubygems.org/....... Fetching gem metadata from https://rubygems.org/. Resolving dependencies................................. Using rake 13.0.1 ・・・ Fetching mysql2 0.5.3 Installing mysql2 0.5.3 with native extensions Gem::Ext::BuildError: ERROR: Failed to build gem native extension. current directory: /Users/user/workspace/kbr_server/vendor/bundler/ruby/2.3.0/gems/mysql2-0.5.3/ext/mysql2 /Users/user/.rbenv/versions/2.3.1/bin/ruby -I /Users/user/.rbenv/versions/2.3.1/lib/ruby/site_ruby/2.3.0 -r ./siteconf20200311-1571-17wqsso.rb extconf.rb \“--with-ldflags\=-L/usr/local/opt/openssl@1.1/lib\” checking for rb_absint_size()... yes checking for rb_absint_singlebit_p()... yes checking for rb_wait_for_single_fd()... yes ----- Using mysql_config at /usr/local/opt/mysql@5.7/bin/mysql_config ----- checking for mysql.h... yes ・・・ ----- Don't know how to set rpath on your system, if MySQL libraries are not in path mysql2 may not load ----- ----- Setting libpath to /usr/local/opt/mysql@5.7/lib ----- creating Makefile current directory: /Users/user/workspace/kbr_server/vendor/bundler/ruby/2.3.0/gems/mysql2-0.5.3/ext/mysql2 make "DESTDIR=" clean current directory: /Users/user/workspace/kbr_server/vendor/bundler/ruby/2.3.0/gems/mysql2-0.5.3/ext/mysql2 make "DESTDIR=" compiling infile.c compiling client.c compiling mysql2_ext.c compiling statement.c compiling result.c linking shared-object mysql2/mysql2.bundle ld: library not found for -lssl clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [mysql2.bundle] Error 1 make failed, exit code 2 Gem files will remain installed in /Users/user/workspace/kbr_server/vendor/bundler/ruby/2.3.0/gems/mysql2-0.5.3 for inspection. Results logged to /Users/user/workspace/kbr_server/vendor/bundler/ruby/2.3.0/extensions/x86_64-darwin-18/2.3.0-static/mysql2-0.5.3/gem_make.out An error occurred while installing mysql2 (0.5.3), and Bundler cannot continue. Make sure that `gem install mysql2 -v '0.5.3' --source 'https://rubygems.org/'` succeeds before bundling. In Gemfile: mysql2 それで gem install mysql2 -v '0.5.3' --source 'https://rubygems.org/ を打つと ERROR: While executing gem ... (Errno::EACCES) Permission denied @ rb_sysopen - /Users/user/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/mysql2-0.5.3/CHANGELOG.md が表示されます。
KyutoYosihama

2020/03/11 10:27

bundle config --local build.mysql2 “--with-mysql-dir=/usr/local/opt/mysql@5.7” は少々お待ちください。
KyutoYosihama

2020/03/11 15:38

ご連絡遅くなり申し訳ありません。 bundle config --local build.mysql2 "--with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include" を打つことでbundle installが出来ました。 正直、opensslの部分はbrew info opensslの時にopenssl@1.1となっていたので出来た理由はわかりませんが。。。 理由はわかりますでしょうか?もしくはどこかの値を見ることでわかりますでしょうか? お手数おかけしますが、教えて頂けると嬉しいです。
guest

回答2

0

Rubyのバージョンは2.3.1でやらないといけないのです。

2.3.1のような古いバージョンを使うのは初めてなのですが試してみました。
結果報告ですが、普段通りのrailsインストール手順で問題なく動きました。
試してみたバージョンです。

$ ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin19]

rails : 5.0.7.2

$ mysql --version
mysql Ver 8.0.19 for osx10.15 on x86_64 (Homebrew)

起動時のメッセージ

$ bundle exec rails s => Booting Puma => Rails 5.0.7.2 application starting in development on http://localhost:3000 => Run `rails server -h` for more startup options Puma starting in single mode... * Version 3.12.4 (ruby 2.3.1-p112), codename: Llamas in Pajamas * Min threads: 5, max threads: 5 * Environment: development * Listening on tcp://localhost:3000 Use Ctrl-C to stop

ブラウザでアクセス時のメッセージ

Started GET "/" for ::1 at 2020-03-11 20:46:09 +0900 Processing by Rails::WelcomeController#index as HTML Parameters: {"internal"=>true} Rendering vendor/bundle/ruby/2.3.0/gems/railties-5.0.7.2/lib/rails/templates/rails/welcome/index.html.erb Rendered vendor/bundle/ruby/2.3.0/gems/railties-5.0.7.2/lib/rails/templates/rails/welcome/index.html.erb (3.1ms) Completed 200 OK in 21ms (Views: 9.8ms | ActiveRecord: 0.0ms)

投稿2020/03/11 12:01

technocore

総合スコア7398

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

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

KyutoYosihama

2020/03/11 15:41

確認していただきありがとうございます。 MySQLのバージョンは5.7が望ましいということでそのバージョンで行なっております。 上記の確認も参考にして見ていきます。
guest

0

>/Users/user/workspace/kbr_server/vendor/bundler/ruby/2.3.0/

エラーメッセージをみましたが、ruby2.3系を使ってますか?
ruby2.3系は1年ほど前にサポート終了しています。
もっと新しいrubyを使った方が良いのでは?

Ruby 2.3.8 リリース
https://www.ruby-lang.org/ja/news/2018/10/17/ruby-2-3-8-released/

投稿2020/03/11 06:58

technocore

総合スコア7398

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

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

KyutoYosihama

2020/03/11 07:03

今回は会社のシステムに合わせてローカルの開発環境を作成しないといけなかったので、 Rubyのバージョンは2.3.1でやらないといけないのです。 Ruby 2.3.8は2.3.1との差は少ないのでしょうか?
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

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

ただいまの回答率
85.30%

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

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

質問する

関連した質問