環境
ruby 2.6.3 Rails 6.0.0 mysql Ver 15.1
前提・実現したいこと
ローカルで開発したrailsアプリをec2を使用してデプロイする為、
[こちらのガイド](※有料記事)(https://zenn.dev/naoki_mochizuki/books/1471ce20222227)を参考に設定を進めてきました。最後の段階でpumaを起動するために下記のコードを実行したところ、
まずこちらのエラーが発生しました。
remote
1bundle exec pumactl start
発生している問題・エラーメッセージ
Puma starting in single mode... * Version 4.3.10 (ruby 2.6.3-p62), codename: Mysterious Traveller * Min threads: 5, max threads: 5 * Environment: development ! Unable to load application: LoadError: libmysqlclient.so.21: cannot open shared object file: No such file or directory - /var/www/project-app/vendor/bundle/ruby/2.6.0/gems/mysql2-0.5.3/lib/mysql2/mysql2.so Traceback (most recent call last): ・・・ require' 7: from /home/test/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-1.17.3/lib/bundler/runtime.rb:76:in `each' 6: from /home/test/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-1.17.3/lib/bundler/runtime.rb:81:in `block (2 levels) in require' 5: from /home/test/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-1.17.3/lib/bundler/runtime.rb:81:in `require' 4: from /var/www/project-app/vendor/bundle/ruby/2.6.0/gems/mysql2-0.5.3/lib/mysql2.rb:36:in `<top (required)>' 3: from /var/www/project-app/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.0/lib/active_support/dependencies.rb:325:in `require' 2: from /var/www/project-app/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.0/lib/active_support/dependencies.rb:291:in `load_dependency' 1: from /var/www/project-app/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.0/lib/active_support/dependencies.rb:325:in `block in require' /var/www/project-app/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.0/lib/active_support/dependencies.rb:325:in `require': libmysqlclient.so.21: cannot open shared object file: No such file or directory - /var/www/project-app/vendor/bundle/ruby/2.6.0/gems/mysql2-0.5.3/lib/mysql2/mysql2.so (LoadError)
エラー文を読んだところやっぱりこの部分が怪しいと感じました。
`require': libmysqlclient.so.21: cannot open shared object file: No such file or directory - /var/www/project-app/vendor/bundle/ruby/2.6.0/gems/mysql2-0.5.3/lib/mysql2/mysql2.so (LoadError)
エラー文で調べてみたところ「mysql2をアンインストールし、もう一度インストールしなおすと直る」という記事をいくつか見つけたため、
下記を実行しました。
gem uninstall mysql2 gem install mysql2
そして再度pumaを起動する為最初のコードを実行しました。
remote
1bundle exec pumactl start
すると今度は下記のエラーにぶつかりました。
・・・ require' 21: from /home/test/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-1.17.3/lib/bundler/runtime.rb:76:in `each' 20: from /home/test/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-1.17.3/lib/bundler/runtime.rb:81:in `block (2 levels) in require' 19: from /home/test/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-1.17.3/lib/bundler/runtime.rb:81:in `require' 18: from /var/www/project-app/vendor/bundle/ruby/2.6.0/gems/sass-rails-6.0.0/lib/sass-rails.rb:1:in `<top (required)>' 17: from /var/www/project-app/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.0/lib/active_support/dependencies.rb:325:in `require' 16: from /var/www/project-app/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.0/lib/active_support/dependencies.rb:291:in `load_dependency' 15: from /var/www/project-app/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.0/lib/active_support/dependencies.rb:325:in `block in require' 14: from /var/www/project-app/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.0/lib/active_support/dependencies.rb:325:in `require' 13: from /var/www/project-app/vendor/bundle/ruby/2.6.0/gems/sassc-rails-2.1.2/lib/sassc/rails.rb:5:in `<top (required)>' 12: from /var/www/project-app/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.0/lib/active_support/dependencies.rb:325:in `require' 11: from /var/www/project-app/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.0/lib/active_support/dependencies.rb:291:in `load_dependency' 10: from /var/www/project-app/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.0/lib/active_support/dependencies.rb:325:in `block in require' 9: from /var/www/project-app/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.0/lib/active_support/dependencies.rb:325:in `require' 8: from /var/www/project-app/vendor/bundle/ruby/2.6.0/gems/sassc-2.4.0/lib/sassc.rb:31:in `<top (required)>' 7: from /var/www/project-app/vendor/bundle/ruby/2.6.0/gems/sassc-2.4.0/lib/sassc.rb:31:in `require_relative' 6: from /var/www/project-app/vendor/bundle/ruby/2.6.0/gems/sassc-2.4.0/lib/sassc/native.rb:5:in `<top (required)>' 5: from /var/www/project-app/vendor/bundle/ruby/2.6.0/gems/sassc-2.4.0/lib/sassc/native.rb:6:in `<module:SassC>' 4: from /var/www/project-app/vendor/bundle/ruby/2.6.0/gems/sassc-2.4.0/lib/sassc/native.rb:10:in `<module:Native>' 3: from /var/www/project-app/vendor/bundle/ruby/2.6.0/gems/sassc-2.4.0/lib/sassc/native.rb:13:in `rescue in <module:Native>' 2: from /var/www/project-app/vendor/bundle/ruby/2.6.0/gems/ffi-1.15.4/lib/ffi/library.rb:99:in `ffi_lib' 1: from /var/www/project-app/vendor/bundle/ruby/2.6.0/gems/ffi-1.15.4/lib/ffi/library.rb:99:in `map' /var/www/project-app/vendor/bundle/ruby/2.6.0/gems/ffi-1.15.4/lib/ffi/library.rb:145:in `block in ffi_lib': Could not open library '/var/www/project-app/vendor/bundle/ruby/2.6.0/gems/sassc-2.4.0/ext/libsass.so': /var/www/project-app/vendor/bundle/ruby/2.6.0/gems/sassc-2.4.0/ext/libsass.so: cannot open shared object file: No such file or directory (LoadError)
こちらのエラーについては現在も調べていますがあまり原因が分からずこちらに質問しました。
原因や同じエラーに遭遇した方で解決策が分かる方がおりましたら是非教えてください。
どうぞよろしくお願いいたします。
あなたの回答
tips
プレビュー