実現したいこと
ローカルで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

回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2024/03/14 12:02