railsでアプリの作成を開始しましたが、エラーが出て前に進めません。
原因や解決方法が分かればご教示ください!
①聞きたいことのまとめ
rails db:create
コマンドで、下記のエラーが出るので解決したい。
LoadError: dlopen(/Library/Ruby/Gems/2.6.0/gems/mysql2-0.5.3/lib/mysql2/mysql2.bundle, 0x0009): dependent dylib '/usr/local/opt/mysql/lib/libssl.1.1.dylib' not found for '/Library/Ruby/Gems/2.6.0/gems/mysql2-0.5.3/lib/mysql2/mysql2.bundle' - /Library/Ruby/Gems/2.6.0/gems/mysql2-0.5.3/lib/mysql2/mysql2.bundle
のエラーを解決したい。
②起きている問題
データベースはMySQLを使用
↓
railsアプリ作成中に、MySQLの権限まわりでエラーが多発するので、下記の記事を参考にMySQLを再インストール(最初はエラー解決を目指していたが、時間がもったいない+重要なデータが無いので再インストールすることにした)
https://qiita.com/akiko-pusu/items/aef52b723da2cb5dc596
※エラーが多発するのは、以前Udemyの講座https://www.udemy.com/share/101ZvECEIdclxRTXw=/
で権限をいじったからだと思われる
↓
MySQLの再インストールが完了したのち、改めてアプリを作成
rails _5.2.4.1_ new bulletinboard --database=mysql --skip-test
でアプリを作成。その後、
rails db:create
でデータベースを作成しようとしたところ、以下のエラーが発生し直らなくなった
% rails db:create rails aborted! LoadError: dlopen(/Library/Ruby/Gems/2.6.0/gems/mysql2-0.5.3/lib/mysql2/mysql2.bundle, 0x0009): dependent dylib '/usr/local/opt/mysql/lib/libssl.1.1.dylib' not found for '/Library/Ruby/Gems/2.6.0/gems/mysql2-0.5.3/lib/mysql2/mysql2.bundle' - /Library/Ruby/Gems/2.6.0/gems/mysql2-0.5.3/lib/mysql2/mysql2.bundle /Library/Ruby/Gems/2.6.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require' /Library/Ruby/Gems/2.6.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi' /Library/Ruby/Gems/2.6.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register' /Library/Ruby/Gems/2.6.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi' /Library/Ruby/Gems/2.6.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require' /Library/Ruby/Gems/2.6.0/gems/activesupport-5.2.4.1/lib/active_support/dependencies.rb:291:in `block in require' /Library/Ruby/Gems/2.6.0/gems/activesupport-5.2.4.1/lib/active_support/dependencies.rb:257:in `load_dependency' /Library/Ruby/Gems/2.6.0/gems/activesupport-5.2.4.1/lib/active_support/dependencies.rb:291:in `require' /Library/Ruby/Gems/2.6.0/gems/mysql2-0.5.3/lib/mysql2.rb:36:in `<main>' /Library/Ruby/Gems/2.6.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require' /Library/Ruby/Gems/2.6.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi' /Library/Ruby/Gems/2.6.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register' /Library/Ruby/Gems/2.6.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi' /Library/Ruby/Gems/2.6.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require' /Library/Ruby/Gems/2.6.0/gems/bundler-2.1.4/lib/bundler/runtime.rb:74:in `block (2 levels) in require' /Library/Ruby/Gems/2.6.0/gems/bundler-2.1.4/lib/bundler/runtime.rb:69:in `each' /Library/Ruby/Gems/2.6.0/gems/bundler-2.1.4/lib/bundler/runtime.rb:69:in `block in require' /Library/Ruby/Gems/2.6.0/gems/bundler-2.1.4/lib/bundler/runtime.rb:58:in `each' /Library/Ruby/Gems/2.6.0/gems/bundler-2.1.4/lib/bundler/runtime.rb:58:in `require' /Library/Ruby/Gems/2.6.0/gems/bundler-2.1.4/lib/bundler.rb:174:in `require' /Users/machoair/Work/bulletinboard/config/application.rb:18:in `<main>' /Library/Ruby/Gems/2.6.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require' /Library/Ruby/Gems/2.6.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi' /Library/Ruby/Gems/2.6.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register' /Library/Ruby/Gems/2.6.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi' /Library/Ruby/Gems/2.6.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require' /Library/Ruby/Gems/2.6.0/gems/activesupport-5.2.4.1/lib/active_support/dependencies.rb:291:in `block in require' /Library/Ruby/Gems/2.6.0/gems/activesupport-5.2.4.1/lib/active_support/dependencies.rb:257:in `load_dependency' /Library/Ruby/Gems/2.6.0/gems/activesupport-5.2.4.1/lib/active_support/dependencies.rb:291:in `require' /Library/Ruby/Gems/2.6.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:49:in `require_relative' /Users/machoair/Work/bulletinboard/Rakefile:four:in `<main>' /Library/Ruby/Gems/2.6.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:55:in `load' /Library/Ruby/Gems/2.6.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:55:in `load' /Library/Ruby/Gems/2.6.0/gems/activesupport-5.2.4.1/lib/active_support/dependencies.rb:285:in `block in load' /Library/Ruby/Gems/2.6.0/gems/activesupport-5.2.4.1/lib/active_support/dependencies.rb:257:in `load_dependency' /Library/Ruby/Gems/2.6.0/gems/activesupport-5.2.4.1/lib/active_support/dependencies.rb:285:in `load' /Library/Ruby/Gems/2.6.0/gems/railties-5.2.4.1/lib/rails/commands/rake/rake_command.rb:22:in `block in perform' /Library/Ruby/Gems/2.6.0/gems/railties-5.2.4.1/lib/rails/commands/rake/rake_command.rb:20:in `perform' /Library/Ruby/Gems/2.6.0/gems/railties-5.2.4.1/lib/rails/command.rb:48:in `invoke' /Library/Ruby/Gems/2.6.0/gems/railties-5.2.4.1/lib/rails/commands.rb:18:in `<main>' /Library/Ruby/Gems/2.6.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require' /Library/Ruby/Gems/2.6.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi' /Library/Ruby/Gems/2.6.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register' /Library/Ruby/Gems/2.6.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi' /Library/Ruby/Gems/2.6.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require' /Library/Ruby/Gems/2.6.0/gems/activesupport-5.2.4.1/lib/active_support/dependencies.rb:291:in `block in require' /Library/Ruby/Gems/2.6.0/gems/activesupport-5.2.4.1/lib/active_support/dependencies.rb:257:in `load_dependency' /Library/Ruby/Gems/2.6.0/gems/activesupport-5.2.4.1/lib/active_support/dependencies.rb:291:in `require' /Users/machoair/Work/bulletinboard/bin/rails:nine:in `<top (required)>' /Library/Ruby/Gems/2.6.0/gems/spring-2.1.0/lib/spring/client/rails.rb:28:in `load' /Library/Ruby/Gems/2.6.0/gems/spring-2.1.0/lib/spring/client/rails.rb:28:in `call' /Library/Ruby/Gems/2.6.0/gems/spring-2.1.0/lib/spring/client/command.rb:seven:in `call' /Library/Ruby/Gems/2.6.0/gems/spring-2.1.0/lib/spring/client.rb:30:in `run' /Library/Ruby/Gems/2.6.0/gems/spring-2.1.0/bin/spring:49:in `<top (required)>' /Library/Ruby/Gems/2.6.0/gems/spring-2.1.0/lib/spring/binstub.rb:11:in `load' /Library/Ruby/Gems/2.6.0/gems/spring-2.1.0/lib/spring/binstub.rb:11:in `<top (required)>' /Users/machoair/Work/bulletinboard/bin/spring:15:in `<top (required)>' bin/rails:three:in `load' bin/rails:three:in `<main>' (See full trace by running task with --trace)
③ソースコード(関連するソースコード/全ソースコード)
④問題解決するために試したこと(コードもあれば追記)
エラー内容をgoogle翻訳して見たが、意味がさっぱり分からず
まずは、/Library/Ruby/Gems/2.6.0/gems/mysql2-0.5.3/lib/mysql2/mysql2.bundleのファイルの中身を確認したが、文字化けして意味が分からない
次に、/usr/local/opt/mysql/lib/libssl.1.1.dylibのファイルを探したところ、ファイルが存在していない。。。これが原因か?
しかし、何をすればいいのか分からないので、エラー文でググって
https://qiita.com/kota-es/items/98ae6ee84fc59aaae2ea
を参考に
brew update && brew upgrade
しかし、解決できず
https://qiita.com/utsu_jimmy/items/a35437faea1c0d2f357d
を参考に
rbenv install 2.6.3
でrubyごと再インストール
しかし、解決できず
⑤問題について自分なりに考えたこと
/usr/local/opt/mysql/lib/libssl.1.1.dylibのファイルが見つからないことが原因だと思いますが、
全く検討がつきません。
回答1件
あなたの回答
tips
プレビュー