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

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

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

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

MySQL

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

Ruby on Rails

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

Q&A

解決済

2回答

515閲覧

bundle installでmysql2がインストールできない

sw__023

総合スコア1

Ruby

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

MySQL

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

Ruby on Rails

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

1グッド

0クリップ

投稿2024/02/20 11:21

編集2024/02/20 11:22

実現したいこと

ローカルでRailsの勉強をしており、bundle installしたいのですが、大量のエラーが出ており詰まっております。

発生している問題・分からないこと

mysql2のインストール中に失敗し、bundle installが完了していないようです。

エラーメッセージ

error

1```ruby 2Installing mysql2 0.5.6 with native extensions 3Gem::Ext::BuildError: ERROR: Failed to build gem native extension. 4 5current directory: 6/Users/watasho/study/batch_sample/.bundle/ruby/3.2.0/gems/mysql2-0.5.6/ext/mysql2 7/Users/watasho/.rbenv/versions/3.2.2/bin/ruby extconf.rb 8--with-cppflags\=-I/opt/homebrew/opt/openssl@3/include 9--with-ldflags\=-L/opt/homebrew/opt/openssl@3/lib --with-openssl-dir\=/opt/homebrew/opt/openssl@3 10checking for rb_absint_size()... yes 11checking for rb_absint_singlebit_p()... yes 12checking for rb_gc_mark_movable()... yes 13checking for rb_wait_for_single_fd()... yes 14checking for rb_enc_interned_str() in ruby.h... yes 15----- 16Using --with-openssl-dir=/opt/homebrew/opt/openssl@3 17----- 18----- 19Using mysql_config at /opt/homebrew/bin/mysql_config 20----- 21checking for mysql.h... yes 22checking for errmsg.h... yes 23checking for SSL_MODE_DISABLED in mysql.h... yes 24checking for SSL_MODE_PREFERRED in mysql.h... yes 25checking for SSL_MODE_REQUIRED in mysql.h... yes 26checking for SSL_MODE_VERIFY_CA in mysql.h... yes 27checking for SSL_MODE_VERIFY_IDENTITY in mysql.h... yes 28checking for MYSQL.net.vio in mysql.h... yes 29checking for MYSQL.net.pvio in mysql.h... no 30checking for MYSQL_DEFAULT_AUTH in mysql.h... yes 31checking for MYSQL_ENABLE_CLEARTEXT_PLUGIN in mysql.h... yes 32checking for SERVER_QUERY_NO_GOOD_INDEX_USED in mysql.h... yes 33checking for SERVER_QUERY_NO_INDEX_USED in mysql.h... yes 34checking for SERVER_QUERY_WAS_SLOW in mysql.h... yes 35checking for MYSQL_OPTION_MULTI_STATEMENTS_ON in mysql.h... yes 36checking for MYSQL_OPTION_MULTI_STATEMENTS_OFF in mysql.h... yes 37checking for my_bool in mysql.h... no 38checking for mysql_ssl_set() in mysql.h... no 39----- 40Don't know how to set rpath on your system, if MySQL libraries are not in path mysql2 may not load 41----- 42----- 43Setting libpath to /opt/homebrew/Cellar/mysql/8.3.0/lib 44----- 45creating Makefile 46 47current directory: 48/Users/watasho/study/batch_sample/.bundle/ruby/3.2.0/gems/mysql2-0.5.6/ext/mysql2 49make DESTDIR\= sitearchdir\=./.gem.20240220-67817-pc3kku sitelibdir\=./.gem.20240220-67817-pc3kku 50clean 51 52current directory: 53/Users/watasho/study/batch_sample/.bundle/ruby/3.2.0/gems/mysql2-0.5.6/ext/mysql2 54make DESTDIR\= sitearchdir\=./.gem.20240220-67817-pc3kku sitelibdir\=./.gem.20240220-67817-pc3kku 55compiling client.c 56In file included from client.c:15: 57./mysql_enc_name_to_ruby.h:43:1: warning: a function declaration without a prototype is deprecated 58in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype] 59mysql2_mysql_enc_name_to_rb_hash (str, len) 60^ 61./mysql_enc_name_to_ruby.h:86:1: warning: a function declaration without a prototype is deprecated 62in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype] 63mysql2_mysql_enc_name_to_rb (str, len) 64^ 652 warnings generated. 66compiling infile.c 67compiling mysql2_ext.c 68compiling result.c 69result.c:304:35: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' 70[-Wshorten-64-to-32] 71 precision = field->length - (field->decimals > 0 ? 2 : 1); 72 ~ ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 731 warning generated. 74compiling statement.c 75linking shared-object mysql2/mysql2.bundle 76ld: library not found for -lzstd 77clang: error: linker command failed with exit code 1 (use -v to see invocation) 78make: *** [mysql2.bundle] Error 1 79 80make failed, exit code 2 81 82Gem files will remain installed in 83/Users/watasho/study/batch_sample/.bundle/ruby/3.2.0/gems/mysql2-0.5.6 for inspection. 84Results logged to 85/Users/watasho/study/batch_sample/.bundle/ruby/3.2.0/extensions/arm64-darwin-22/3.2.0/mysql2-0.5.6/gem_make.out 86 87/Users/watasho/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:125:in 88`run' 89/Users/watasho/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:51:in 90`block in make' 91/Users/watasho/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:43:in 92`each' 93/Users/watasho/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:43:in 94`make' 95/Users/watasho/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/ext/ext_conf_builder.rb:42:in 96`build' 97/Users/watasho/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:193:in 98`build_extension' 99/Users/watasho/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:227:in 100`block in build_extensions' 101/Users/watasho/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:224:in 102`each' 103/Users/watasho/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:224:in 104`build_extensions' 105/Users/watasho/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/installer.rb:852:in 106`build_extensions' 107/Users/watasho/study/batch_sample/.bundle/ruby/3.2.0/gems/bundler-2.4.10/lib/bundler/rubygems_gem_installer.rb:72:in 108`build_extensions' 109/Users/watasho/study/batch_sample/.bundle/ruby/3.2.0/gems/bundler-2.4.10/lib/bundler/rubygems_gem_installer.rb:28:in 110`install' 111/Users/watasho/study/batch_sample/.bundle/ruby/3.2.0/gems/bundler-2.4.10/lib/bundler/source/rubygems.rb:200:in 112`install' 113/Users/watasho/study/batch_sample/.bundle/ruby/3.2.0/gems/bundler-2.4.10/lib/bundler/installer/gem_installer.rb:54:in 114`install' 115/Users/watasho/study/batch_sample/.bundle/ruby/3.2.0/gems/bundler-2.4.10/lib/bundler/installer/gem_installer.rb:16:in 116`install_from_spec' 117/Users/watasho/study/batch_sample/.bundle/ruby/3.2.0/gems/bundler-2.4.10/lib/bundler/installer/parallel_installer.rb:156:in 118`do_install' 119/Users/watasho/study/batch_sample/.bundle/ruby/3.2.0/gems/bundler-2.4.10/lib/bundler/installer/parallel_installer.rb:147:in 120`block in worker_pool' 121/Users/watasho/study/batch_sample/.bundle/ruby/3.2.0/gems/bundler-2.4.10/lib/bundler/worker.rb:62:in 122`apply_func' 123/Users/watasho/study/batch_sample/.bundle/ruby/3.2.0/gems/bundler-2.4.10/lib/bundler/worker.rb:57:in 124`block in process_queue' 125/Users/watasho/study/batch_sample/.bundle/ruby/3.2.0/gems/bundler-2.4.10/lib/bundler/worker.rb:54:in 126`loop' 127/Users/watasho/study/batch_sample/.bundle/ruby/3.2.0/gems/bundler-2.4.10/lib/bundler/worker.rb:54:in 128`process_queue' 129/Users/watasho/study/batch_sample/.bundle/ruby/3.2.0/gems/bundler-2.4.10/lib/bundler/worker.rb:90:in 130`block (2 levels) in create_threads' 131 132An error occurred while installing mysql2 (0.5.6), and Bundler cannot continue. 133 134In Gemfile: 135 mysql2

こちらの記事を見て、以下を試してみましたが、エラー内容は変わらずでした。
Railsインストール時のMySQLエラーを解消する方法

brew install openssl ==> openssl@3: stable 3.2.1 (bottled) Cryptography and SSL/TLS Toolkit https://openssl.org/ /opt/homebrew/Cellar/openssl@3/3.2.1 (6,874 files, 32MB) * Poured from bottle using the formulae.brew.sh API on 2024-02-19 at 23:24:06 From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/o/openssl@3.rb License: Apache-2.0 ==> Dependencies Required: ca-certificates ✔ ==> Caveats A CA file has been bootstrapped using certificates from the system keychain. To add additional certificates, place .pem files in /opt/homebrew/etc/openssl@3/certs and run /opt/homebrew/opt/openssl@3/bin/c_rehash ==> Analytics install: 405,808 (30 days), 1,234,946 (90 days), 3,789,618 (365 days) install-on-request: 59,099 (30 days), 174,479 (90 days), 602,587 (365 days) build-error: 4,429 (30 days)
bundle config --local build.mysql2 "--with-ldflags=-L/opt/homebrew/opt/openssl@3/lib" bundle install

補足

brew
mysql: stable 8.3.0
openssl@3: stable 3.2.1

https://github.com/shota-watanabe/batch_sample_app

mavis👍を押しています

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

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

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

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

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

guest

回答2

0

ベストアンサー

私も同じ問題につまづいていましたが、MySQLのバージョンを8.0に下げることで解決できるようです。

brew uninstall mysql@8.3
brew uninstall mysql-client@8.3
brew uninstall mysql@8.0
brew uninstall mysql-client@8.0

上記をやった後で、bundle installをしてみてください。
一部解消しているようで、でもまだMacのhomebrewで解決していない、ごく最近の問題じゃないかなと思っています。

https://github.com/brianmario/mysql2/issues/1346
https://github.com/brianmario/mysql2/releases/tag/0.5.6

投稿2024/03/05 08:14

Naofumi

総合スコア7

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

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

sw__023

2024/03/14 12:02

回答ありがとうございます! 現状のmysqlをアンインストールして、 `bundle install mysql@8.0` 上記コマンド実行後、`bundle install` を試したところ問題が解決しました!
guest

0

途中にld: library not found for -lzstdとありますが、これに対応するlibzstd(開発用)を入れてみたらどうなりますでしょうか。

投稿2024/02/20 11:24

maisumakun

総合スコア145184

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

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

sw__023

2024/02/20 11:32 編集

ありがとうございます。 そちらすでに実施済みで、確認したところ以下のようになっていました。 こちらであってますでしょうか? brew info zstd => zstd: stable 1.5.5 (bottled)
maisumakun

2024/02/20 12:58

そうだったのですね、失礼しました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問