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

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

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

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

MySQL

MySQL(マイエスキューエル)は、TCX DataKonsultAB社などが開発するRDBMS(リレーショナルデータベースの管理システム)です。世界で最も人気の高いシステムで、オープンソースで開発されています。MySQLデータベースサーバは、高速性と信頼性があり、Linux、UNIX、Windowsなどの複数のプラットフォームで動作することができます。

Ruby on Rails

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

Q&A

解決済

1回答

1062閲覧

mysql2 bundle installできない

ken-fuku

総合スコア6

Ruby

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

MySQL

MySQL(マイエスキューエル)は、TCX DataKonsultAB社などが開発するRDBMS(リレーショナルデータベースの管理システム)です。世界で最も人気の高いシステムで、オープンソースで開発されています。MySQLデータベースサーバは、高速性と信頼性があり、Linux、UNIX、Windowsなどの複数のプラットフォームで動作することができます。

Ruby on Rails

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

0グッド

0クリップ

投稿2020/04/05 11:07

前提・実現したいこと

bundle installしようとしたらmysql2がインストールされないという事態が発生した。

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

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.

該当のソースコード

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 13.0.1 Following files may not be writable, so sudo is needed: /Library/Ruby/Gems/2.6.0 /Library/Ruby/Gems/2.6.0/build_info /Library/Ruby/Gems/2.6.0/cache /Library/Ruby/Gems/2.6.0/doc /Library/Ruby/Gems/2.6.0/extensions /Library/Ruby/Gems/2.6.0/gems /Library/Ruby/Gems/2.6.0/specifications 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.2.4.1 Using builder 3.2.4 Using erubi 1.9.0 Using mini_portile2 2.4.0 Using nokogiri 1.10.8 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.2.4.1 Using rack 2.2.2 Using rack-test 1.1.0 Using actionpack 5.2.4.1 Using nio4r 2.5.2 Using websocket-extensions 0.1.4 Using websocket-driver 0.7.1 Using actioncable 5.2.4.1 Using globalid 0.4.2 Using activejob 5.2.4.1 Using mini_mime 1.0.2 Using mail 2.7.1 Using actionmailer 5.2.4.1 Using activemodel 5.2.4.1 Using arel 9.0.0 Using activerecord 5.2.4.1 Using mimemagic 0.3.4 Using marcel 0.3.3 Using activestorage 5.2.4.1 Using public_suffix 4.0.3 Using addressable 2.7.0 Using io-like 0.3.1 Using archive-zip 0.12.0 Using bcrypt 3.1.13 Using bindex 0.8.1 Using msgpack 1.3.3 Using bootsnap 1.4.5 Using bundler 2.1.4 Using byebug 11.1.1 Using regexp_parser 1.7.0 Using xpath 3.2.0 Using capybara 3.31.0 Using childprocess 3.0.0 Using chromedriver-helper 2.1.1 Using chunky_png 1.3.11 Using coderay 1.1.2 Using coffee-script-source 1.12.2 Using execjs 2.7.0 Using coffee-script 2.4.1 Using method_source 0.9.2 Using thor 1.0.1 Using railties 5.2.4.1 Using coffee-rails 4.2.2 Using multi_json 1.14.1 Using sass 3.4.25 Using compass-core 1.0.3 Using compass-import-once 1.0.5 Using rb-fsevent 0.10.3 Using ffi 1.12.2 Using rb-inotify 0.10.1 Using compass 1.0.3 Using sprockets 3.7.2 Using sprockets-rails 3.2.1 Using tilt 2.0.10 Using sass-rails 5.0.8 Using compass-rails 3.1.0 Using orm_adapter 0.5.0 Using responders 3.0.0 Using warden 1.2.8 Using devise 4.7.1 Using jbuilder 2.10.0 Using kaminari-core 1.2.0 Using kaminari-actionview 1.2.0 Using kaminari-activerecord 1.2.0 Using kaminari 1.2.0 Using ruby_dep 1.5.0 Using listen 3.1.5 Fetching mysql2 0.5.3 Your user account isn't allowed to install to the system RubyGems. You can cancel this installation and run: bundle install --path vendor/bundle to install the gems into ./vendor/bundle/, or you can enter your password and install the bundled gems to RubyGems using sudo. Password: Installing mysql2 0.5.3 with native extensions Gem::Ext::BuildError: ERROR: Failed to build gem native extension. current directory: /private/var/folders/t1/24y7lj016md7m0gxdts9c1t00000gn/T/bundler20200405-31805-14pkgzhmysql2-0.5.3/gems/mysql2-0.5.3/ext/mysql2 /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0 -r ./siteconf20200405-31805-aee2vn.rb extconf.rb --with-ldflags\=-L/usr/local/opt/openssl/lib checking for rb_absint_size()... *** 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.6/usr/bin/$(RUBY_BASE_NAME) /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/tmpdir.rb:89:in `mkdir': No such file or directory @ dir_s_mkdir - /var/folders/c9/yt_mxkkn4sz69h6d2rp7gds00000gn/T/mkmf_20200405-31819-n9mezs (Errno::ENOENT) from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/tmpdir.rb:89:in `block in mktmpdir' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/tmpdir.rb:135:in `create' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/tmpdir.rb:87:in `mktmpdir' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:543:in `try_link0' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:570:in `try_link' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:782:in `try_func' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:1069:in `block in have_func' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:959:in `block in checking_for' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:361:in `block (2 levels) in postpone' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:331:in `open' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:361:in `block in postpone' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:331:in `open' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:357:in `postpone' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:958:in `checking_for' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:1068:in `have_func' from extconf.rb:25:in `<main>' To see why this extension failed to compile, please check the mkmf.log which can be found here: /var/folders/t1/24y7lj016md7m0gxdts9c1t00000gn/T/bundler20200405-31805-14pkgzhmysql2-0.5.3/extensions/universal-darwin-19/2.6.0/mysql2-0.5.3/mkmf.log extconf failed, exit code 1 Gem files will remain installed in /var/folders/t1/24y7lj016md7m0gxdts9c1t00000gn/T/bundler20200405-31805-14pkgzhmysql2-0.5.3/gems/mysql2-0.5.3 for inspection. Results logged to /var/folders/t1/24y7lj016md7m0gxdts9c1t00000gn/T/bundler20200405-31805-14pkgzhmysql2-0.5.3/extensions/universal-darwin-19/2.6.0/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ファイルをインストールしようとしたがこれもできなかった
% sudo gem install mysql2 -v '0.5.3'
Password:
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.

current directory: /Library/Ruby/Gems/2.6.0/gems/mysql2-0.5.3/ext/mysql2

/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0 -r ./siteconf20200405-31837-pyp9ge.rb extconf.rb
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/bin/mysql_config

checking for mysql.h... yes
checking for errmsg.h... yes
checking for SSL_MODE_DISABLED in mysql.h... yes
checking for SSL_MODE_PREFERRED in mysql.h... yes
checking for SSL_MODE_REQUIRED in mysql.h... yes
checking for SSL_MODE_VERIFY_CA in mysql.h... yes
checking for SSL_MODE_VERIFY_IDENTITY in mysql.h... yes
checking for MYSQL.net.vio in mysql.h... yes
checking for MYSQL.net.pvio in mysql.h... no
checking for MYSQL_ENABLE_CLEARTEXT_PLUGIN in mysql.h... yes
checking for SERVER_QUERY_NO_GOOD_INDEX_USED in mysql.h... yes
checking for SERVER_QUERY_NO_INDEX_USED in mysql.h... yes
checking for SERVER_QUERY_WAS_SLOW in mysql.h... yes
checking for MYSQL_OPTION_MULTI_STATEMENTS_ON in mysql.h... yes
checking for MYSQL_OPTION_MULTI_STATEMENTS_OFF in mysql.h... yes
checking for my_bool in mysql.h... no

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/Cellar/mysql/8.0.19/lib

creating Makefile

current directory: /Library/Ruby/Gems/2.6.0/gems/mysql2-0.5.3/ext/mysql2
make "DESTDIR=" clean

current directory: /Library/Ruby/Gems/2.6.0/gems/mysql2-0.5.3/ext/mysql2
make "DESTDIR="
compiling client.c
compiling infile.c
compiling mysql2_ext.c
compiling result.c
compiling statement.c
linking shared-object mysql2/mysql2.bundle
ld: warning: directory not found for option '-L/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.Internal.sdk/usr/local/lib'
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 /Library/Ruby/Gems/2.6.0/gems/mysql2-0.5.3 for inspection.
Results logged to /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-19/2.6.0/mysql2-0.5.3/gem_make.out

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

which bundler -> /usr/bin/bundler
gemリストにmysql2はありませんでした。

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

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

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

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

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

otn

2020/04/05 11:56

エラーメッセージは、簡単な英文なので、読みましょう。
ken-fuku

2020/04/05 12:07

書き忘れておりましたが、エラーメッセージを実行しところ Building native extensions. This could take a while... ERROR: Error installing mysql2: ERROR: Failed to build gem native extension. current directory: /Library/Ruby/Gems/2.6.0/gems/mysql2-0.5.3/ext/mysql2 /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0 -r ./siteconf20200405-32158-xeehz6.rb extconf.rb 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/bin/mysql_config ----- checking for mysql.h... yes checking for errmsg.h... yes checking for SSL_MODE_DISABLED in mysql.h... yes checking for SSL_MODE_PREFERRED in mysql.h... yes checking for SSL_MODE_REQUIRED in mysql.h... yes checking for SSL_MODE_VERIFY_CA in mysql.h... yes checking for SSL_MODE_VERIFY_IDENTITY in mysql.h... yes checking for MYSQL.net.vio in mysql.h... yes checking for MYSQL.net.pvio in mysql.h... no checking for MYSQL_ENABLE_CLEARTEXT_PLUGIN in mysql.h... yes checking for SERVER_QUERY_NO_GOOD_INDEX_USED in mysql.h... yes checking for SERVER_QUERY_NO_INDEX_USED in mysql.h... yes checking for SERVER_QUERY_WAS_SLOW in mysql.h... yes checking for MYSQL_OPTION_MULTI_STATEMENTS_ON in mysql.h... yes checking for MYSQL_OPTION_MULTI_STATEMENTS_OFF in mysql.h... yes checking for my_bool in mysql.h... no ----- 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/Cellar/mysql/8.0.19/lib ----- creating Makefile current directory: /Library/Ruby/Gems/2.6.0/gems/mysql2-0.5.3/ext/mysql2 make "DESTDIR=" clean current directory: /Library/Ruby/Gems/2.6.0/gems/mysql2-0.5.3/ext/mysql2 make "DESTDIR=" compiling client.c compiling infile.c compiling mysql2_ext.c compiling result.c compiling statement.c linking shared-object mysql2/mysql2.bundle ld: warning: directory not found for option '-L/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.Internal.sdk/usr/local/lib' 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 /Library/Ruby/Gems/2.6.0/gems/mysql2-0.5.3 for inspection. Results logged to /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-19/2.6.0/mysql2-0.5.3/gem_make.out といったメッセージが表示されました。こちらはどのようにすればよろしいでしょうか。
otn

2020/04/05 12:12

エラーメッセージを、読みましょうと言ってます。 「エラーメッセージを実行する」の意味が分かりませんが、 > ld: library not found for -lssl なので、sslのライブラリをインストールし漏れているのでは?
guest

回答1

0

ベストアンサー

あちらこちらでパーミッションエラーが出ているのが原因でしょうが、sudo(root権限)が必要なruby環境構築はお勧めしません。
MacOSなら、Homebrew(パッケージ管理ツール)とrbenv(ruby管理ツール)で環境構築するのがお勧めです。

homebrewをインストールしてPathを通す
(必要なら)homebrewでmysqlをインストール、設定する
homebrewでrbenvをインストールしてPathを通す
rbenvで必要なバージョンのrubyをインストールする
gem(rails)をインストールするしてrailsアプリを構築する。

すべて一般ユーザ(あなた)で実行できます。
参考にしてください。

投稿2020/04/05 12:07

technocore

総合スコア7200

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

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

ken-fuku

2020/04/05 15:05

おっしゃる通り環境を再構築したらなんとか解決できました。 おそらく様々なエラーを解決すべくググっていろいろと設定を変えまくってたのが原因だったようです。 ありがとうございました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問