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

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

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

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

Docker

Dockerは、Docker社が開発したオープンソースのコンテナー管理ソフトウェアの1つです

AWS(Amazon Web Services)

Amazon Web Services (AWS)は、仮想空間を機軸とした、クラスター状のコンピュータ・ネットワーク・データベース・ストーレッジ・サポートツールをAWSというインフラから提供する商用サービスです。

Capistrano

Rubyで書かれたサーバオーケストレーションで、複数のサーバでスクリプトを実行する際に用いられます。主な使用用途はWebアプリケーションのデプロイメントです。 アプリケーションのバージョンアップ自動化、およびデータベースの変更などもできます。

Q&A

1回答

2681閲覧

LoadError: libmysqlclient.so.18:

divclass123

総合スコア35

Ruby on Rails

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

Docker

Dockerは、Docker社が開発したオープンソースのコンテナー管理ソフトウェアの1つです

AWS(Amazon Web Services)

Amazon Web Services (AWS)は、仮想空間を機軸とした、クラスター状のコンピュータ・ネットワーク・データベース・ストーレッジ・サポートツールをAWSというインフラから提供する商用サービスです。

Capistrano

Rubyで書かれたサーバオーケストレーションで、複数のサーバでスクリプトを実行する際に用いられます。主な使用用途はWebアプリケーションのデプロイメントです。 アプリケーションのバージョンアップ自動化、およびデータベースの変更などもできます。

0グッド

0クリップ

投稿2021/05/11 05:30

編集2021/05/11 07:00

実現したいこと前提

現在railsアプリをdocker開発環境で頑張って作成しています。

本番環境のデータベース はRDSです。

bundle exec cap production deploy

を実行したら以下のようなエラーに
なりました。

RDSのMySQLは8系でdocker開発環境は5.7なのでそこら辺も関係あるかもしれません。

[追記]

db: image: mysql:8.0.21 environment: MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD} MYSQL_HOST: db ports: - '3306:3306' volumes: - ./tmp/db:/var/lib/mysql command: --default-authentication-plugin=mysql_native_password

こんな感じでdocker-compose.ymlを編集して、buildし直したら上手く立ち上がって、その後、再度bundle exec cap production deployを実行しましたが、エラー内容変わりませんでした。

エラー内容

/Users/soichirohara/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/sshkit-1.21.2/lib/sshkit/command.rb:97:in `exit_status=': rake exit status: 1 (SSHKit::Command::Failed) rake stdout: Nothing written rake stderr: rake aborted! LoadError: libmysqlclient.so.18: cannot open shared object file: No such file or directory - /var/www/coffee_passport/shared/bundle/ruby/2.6.0/gems/mysql2-0.5.3/lib/mysql2/mysql2.so /var/www/coffee_passport/shared/bundle/ruby/2.6.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require' /var/www/coffee_passport/shared/bundle/ruby/2.6.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi' /var/www/coffee_passport/shared/bundle/ruby/2.6.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register' /var/www/coffee_passport/shared/bundle/ruby/2.6.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi' /var/www/coffee_passport/shared/bundle/ruby/2.6.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require' /var/www/coffee_passport/shared/bundle/ruby/2.6.0/gems/activesupport-6.1.3.1/lib/active_support/dependencies.rb:332:in `block in require' /var/www/coffee_passport/shared/bundle/ruby/2.6.0/gems/activesupport-6.1.3.1/lib/active_support/dependencies.rb:299:in `load_dependency' /var/www/coffee_passport/shared/bundle/ruby/2.6.0/gems/activesupport-6.1.3.1/lib/active_support/dependencies.rb:332:in `require' /var/www/coffee_passport/shared/bundle/ruby/2.6.0/gems/mysql2-0.5.3/lib/mysql2.rb:36:in `<main>' /var/www/coffee_passport/shared/bundle/ruby/2.6.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require' /var/www/coffee_passport/shared/bundle/ruby/2.6.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi' /var/www/coffee_passport/shared/bundle/ruby/2.6.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register' /var/www/coffee_passport/shared/bundle/ruby/2.6.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi' /var/www/coffee_passport/shared/bundle/ruby/2.6.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require' /var/www/coffee_passport/releases/20210511045750/config/application.rb:7:in `<top (required)>' /var/www/coffee_passport/releases/20210511045750/Rakefile:4:in `require_relative' /var/www/coffee_passport/releases/20210511045750/Rakefile:4:in `<top (required)>' /var/www/coffee_passport/shared/bundle/ruby/2.6.0/gems/rake-13.0.3/exe/rake:27:in `<top (required)>' /home/ec2-user/.rbenv/versions/2.6.5/bin/bundle:23:in `load' /home/ec2-user/.rbenv/versions/2.6.5/bin/bundle:23:in `<main>'

capistrano.log

のエラーログもこんな感じだったので、teratailは1000字以内で入力しなければならないので、必要であれば共有したいと思います。

該当のソースコード

このアプリのGithub

database.yml

default: &default adapter: mysql2 encoding: utf8 pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> username: root password: <%= ENV['MYSQL_ROOT_PASSWORD'] %> socket: /tmp/mysql.sock host: <%= ENV['MYSQL_HOST'] || 'localhost' %> development: <<: *default database: coffee_passport_development # Warning: The database defined as "test" will be erased and # re-generated from your development database when you run "rake". # Do not set this db to the same as development or production. test: <<: *default database: coffee_passport_test # As with config/credentials.yml, you never want to store sensitive information, # like your database password, in your source code. If your source code is # ever seen by anyone, they now have access to your database. # # Instead, provide the password as a unix environment variable when you boot # the app. Read https://guides.rubyonrails.org/configuring.html#configuring-a-database # for a full rundown on how to provide these environment variables in a # production deployment. # # On Heroku and other platform providers, you may have a full connection URL # available as an environment variable. For example: # # DATABASE_URL="mysql2://myuser:mypass@localhost/somedatabase" # # You can use this database configuration with: # # production: # url: <%= ENV['DATABASE_URL'] %> # production: <<: *default database: coffee_passport_production username: root password: <%= ENV['MYSQL_ROOT_PASSWORD'] %> host: cp-mysql.c3sv1rwobfad.ap-northeast-1.rds.amazonaws.com

Gemfile

source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } ruby '2.6.5' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '6.1.3.1' # Use mysql as the database for Active Record gem 'mysql2', '>= 0.4.4' # Use Puma as the app server gem 'puma', '~> 3.11' # Use SCSS for stylesheets gem 'sass-rails', '~> 5' # Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker gem 'webpacker', '~> 4.0' # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks gem 'turbolinks', '~> 5' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder gem 'jbuilder', '~> 2.7' # Use Redis adapter to run Action Cable in production # gem 'redis', '~> 4.0' # Use Active Model has_secure_password gem 'bcrypt', '~> 3.1.7' # Use Active Storage variant # gem 'image_processing', '~> 1.2' # Reduces boot times through caching; required in config/boot.rb gem 'bootsnap', '>= 1.4.2', require: false group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] gem 'rspec-rails' gem 'factory_bot_rails' gem 'faker' gem 'capistrano' gem 'capistrano-rbenv' gem 'capistrano-bundler' gem 'capistrano-rails' gem 'capistrano3-unicorn' end group :development do # Access an interactive console on exception pages or by calling 'console' anywhere in the code. gem 'web-console', '>= 3.3.0' gem 'listen', '>= 3.0.5', '< 3.2' # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' gem 'spring-watcher-listen', '~> 2.0.0' gem 'rubocop', require: false end group :test do # Adds support for Capybara system testing and selenium driver gem 'capybara', '>= 2.15' gem 'selenium-webdriver' # Easy installation and use of web drivers to run system tests with browsers gem 'webdrivers' gem 'launchy' end group :production do gem 'unicorn', '5.4.1' end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] gem 'pry-rails' gem "mimemagic" gem 'image_processing', '~> 1.2' gem 'active_hash' gem 'payjp' gem 'ransack' gem 'will_paginate', '3.1.8' gem 'bootstrap-will_paginate', '1.0.0' gem "jquery-rails" gem 'omniauth-twitter' gem 'omniauth-facebook' gem 'omniauth-google-oauth2' gem 'omniauth-rails_csrf_protection' gem 'oauth2' gem "aws-sdk-s3", require: false gem 'faker' gem 'dotenv-rails' # rack のアップデートのバグで画像が上手く開いてくれない見たいなので、グレードダウン(近々修正くるらしい) gem 'rails-i18n'

試したこと

私の行った手順は以下です。
(1)

sudo yum install libmysqlclient.so.18

を実行したら 

sudo: yum: command not found

とエラーが出たので

brew install yum

を実行。

==> Searching for similarly named formulae... Error: No similarly named formulae found. Error: No available formula or cask with the name "yum". ==> Searching for a previously deleted formula (in the last month)... Error: No previously deleted formula found. ==> Searching taps on GitHub... Error: No formulae found in taps.
docker-compose exec web apt-get install libmysqlclient.so.18

を実行したら

Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package libmysqlclient.so.18 E: Couldn't find any package by glob 'libmysqlclient.so.18' E: Couldn't find any package by regex 'libmysqlclient.so.18'

このようなエラーが返ってきました。

(2)

bundle update

を実行しましたがエラー内容は変わらずでした。

(3)

dokcer-compose exec web gem uninstall mysql2
gem uninstall mysql2
gem install

どっちも行いましたが、エラー内容は変わりませんでした。

soichirohara@SoichironoMacBook-Pro coffee_passport % docker-compose exec web apt-get install mysql-devel Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package mysql-devel

yum installができないので、このようなコマンドを実行しましたが上手く行っていないように思えます。

そもそも、本番環境のデータベース はRDSなので、自分のアプローチが何か間違ってるかもしれません。。。

環境

各環境は
このアプリのGithub
お手数ですが、こちらのreadMeをご確認お願い申し上げます。

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

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

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

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

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

yu_1985

2021/05/11 06:48

capistranoを実行している環境について追記してください。
divclass123

2021/05/11 07:16

docker開発環境ですが、 soichirohara@SoichironoMacBook-Pro coffee_passport % bundle exec cap production deploy と、ローカルのターミナルで実行しています。 言語等のバージョンは お手数ですが、readMeをご確認お願い申し上げます。
guest

回答1

0

capistranoをどこで実行しているかについてはReadmeに書いてないですね…。
もっとも、本文をよく読むとローカルのMacで実行していると思われるのでその前提で記載します。

まず、MySQLのバージョンどうこう以前のところで詰まっています。
バージョンを合わせるべきなのはそのとおりなのでそれはそれで合わせてください。というより、なぜ違うバージョンにしているかが不明です。

闇雲に色々コマンドを打っていますが、まずどこで問題が発生しているのかをきちんと切り分けてください
そうしないと何をどう対処するかを正しく判断できません。
調べて引っかかったコマンドを闇雲に打つのは危険なのでやめてください

メッセージを読むと

cannot open shared object file: No such file or directory - /var/www/coffee_passport/shared/bundle/ruby/2.6.0/gems/mysql2-0.5.3/lib/mysql2/mysql2.so

と出ています。
おそらくローカルでは/var/www/にわざわざソースを置いてないと思いますので、これはデプロイ先の環境でmysql2.soが見つからないというメッセージかと思います。

それが正しいなら、いくらローカルのMacやdocker環境上で何かを入れても意味がありません。

何となくですがデプロイ時のbundle installがうまく行っているか怪しい気がします。
参照しようとしているのはshared/bundle配下ですが、ちゃんとshared/bundle配下にbundle installしたものが配置されますでしょうか?
2.6.5を使っているにも関わらず2.6.0のディレクトリを参照しているのも気になります。
bundle_pathの設定を確認したほうがいいかもしれません。

また、本筋とは関係ないですが細かいところを以下に記載します。

brew install yum

yumはRHEL系Linux用のパッケージマネージャなのでMacでは使えません。なので当然brewでyumを入れることはできません。

docker-compose exec web apt-get install libmysqlclient.so.18

たいていのUbuntuベースのコンテナイメージではデフォルトではリポジトリ情報を持っていないのでapt updateしないとインストールに失敗します。

また、以下はこの質問と関係ないツッコミです。

  • capistranoを手動で実行しているということは単にデプロイを自動化しただけで、まだCI/CDをしているわけではありません。

参考
CI/CDとは何か?

投稿2021/05/11 07:54

yu_1985

総合スコア7443

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

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

divclass123

2021/05/14 14:18

ご丁寧なご回答本当に感謝申し上げます。 とにかく意味がわからないコマンドを実行するのは絶対やめます。 docker,ローカル、EC2の問題の切り分けができていませんでしたが、/var/ww/appとあるので、落ち着いてよく読めばEC2の問題だと推測可能でした。反省しております。 bundle installでmysqlがインストールされない問題もあるかもしれません。。。 補足事項も事細かにありがとうございます。。。
divclass123

2021/05/14 15:14

>参照しようとしているのはshared/bundle配下ですが、ちゃんとshared/bundle配下にbundle installしたものが配置されますでしょうか? とありますが、 どのファイルがshared/bundleを参照するよ。っていう風に書いてあるのでしょうか? またどのようにしたらbundle installしたものがshared/bundleに配置されてるとわかるのでしょうか。。。 ec2内で、cd /var/www/app/shared/bundle を実行して、lsを実行したら rubyだけ入ってました。
divclass123

2021/05/14 15:44

sudo yum install mysql-devel を実行後にmysql2をgem installしても結果は変わりませんでした。 何かをyum installすれば解決しそうな気がするのですが、それがなんなのかがわかりません。。。。 00:37 というか、mysqlをインストールしたのに、なぜこのエラーが起こるのかがわかりません。。。 00:38 4日くらいこのエラー解決できていないので、ご協力いただければ幸いです。 また、体系的な理解ができていないので、linuxに加えて、この書籍等を勉強したら体系的に理解できる。等の情報があればそれもご教授いただければ幸いです。
yu_1985

2021/05/15 09:39

>どのファイルがshared/bundleを参照するよ。っていう風に書いてあるのでしょうか? ログを見たら、shared/bundle配下を参照しようとしてエラーになってることが読み取れますよね? > ec2内で、cd /var/www/app/shared/bundle > を実行して、lsを実行したら > rubyだけ入ってました。 そのruby はディレクトリで、その下に色々あるのではないでしょうか。 ログを見て参照しようとしているパスに参照しようとしているファイルがあるか確認してください。 まあ、ないからエラーになってるんでしょうけれど…。 shared配下を参照しようとしているのはご自分のcapistranoの設定だと思いますよ。 まず、capistranoがどこにbundle installしようとしていて、それがうまく行っているのかを確認すべきでしょう。 そのためにはcapistranoのどの記載が何を意味してるのかを調べてみてください。 > というか、mysqlをインストールしたのに、なぜこのエラーが起こるのか 使おうとしているのはmysql2というgemで、サーバ上のMySQLクライアントではありません。 書籍がどうのといいますが、まずRails Tutorialを一通りやってみるのが一番いいのではないでしょうか。
divclass123

2021/05/15 09:53

ありがとうございます。 /var/ww/coffee_passport/shared/bundle/ruby/2.6.0/gems に色々なgemが入っていました。 capistranoの記載を見直していきます。 Rails Tutorialを一通りやってみた事があるのですが、herokuデプロイでcapistranoを用いてないように思えるのですが、どの部分を重点的に学習した方がよろしいと思われますでしょうか。ぜひ貴重なご意見をいただければと思います。
yu_1985

2021/05/15 10:00

capistranoでやっているのは所詮サーバ上での操作なので、まず手動でデプロイする際に何をやってるのか、そのデプロイをcapistranoはどのようにやっているのかを確認してみてください。
divclass123

2021/05/15 13:16

なぜshared/bundleを参照してくれないのかが、わかっていません。 何がshared/bundle/hogehogeを参照するように書いてるのかがわかりません。 Capfile ``` require 'capistrano/setup' require 'capistrano/deploy' require 'capistrano/rbenv' require 'capistrano/bundler' require 'capistrano/rails/assets' require 'capistrano/rails/migrations' require 'capistrano3/unicorn' require 'capistrano/scm/git' Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r } install_plugin Capistrano::SCM::Git ``` config/deploy.rb ``` # config valid for current version and patch releases of Capistrano lock "3.16.0" set :application, "coffee_passport" set :repo_url, "git@github.com:Harasou21/coffee_passport.git" # バージョンが変わっても共通で参照するディレクトリを指定 set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system', 'public/uploads') set :rbenv_type, :user set :rbenv_ruby, '2.6.5' #カリキュラム通りに進めた場合、’2.6.5’ です # どの公開鍵を利用してデプロイするか set :ssh_options, auth_methods: ['publickey'], keys: ['~/.ssh/coffee-passport-ssh-key.pem'] # プロセス番号を記載したファイルの場所 set :unicorn_pid, -> { "#{shared_path}/tmp/pids/unicorn.pid" } # Unicornの設定ファイルの場所 set :unicorn_config_path, -> { "#{current_path}/config/unicorn.rb" } set :keep_releases, 5 set :linked_files, fetch(:linked_files, []).push("config/master.key") # デプロイ処理が終わった後、Unicornを再起動するための記述 after 'deploy:publishing', 'deploy:restart' namespace :deploy do task :restart do invoke 'unicorn:restart' end end ``` unicorn.rb ``` app_path = File.expand_path('../../../', __FILE__) # 「../」が一つ増えている #アプリケーションサーバの性能を決定する worker_processes 1 #アプリケーションの設置されているディレクトリを指定 working_directory "#{app_path}/current" # 「current」を指定 #Unicornの起動に必要なファイルの設置場所を指定 pid "#{app_path}/shared/tmp/pids/unicorn.pid" # 「shared」の中を参照するよう変更 #ポート番号を指定 listen "#{app_path}/shared/tmp/sockets/unicorn.sock" # 「shared」の中を参照するよう変更 #エラーのログを記録するファイルを指定 stderr_path "#{app_path}/shared/log/unicorn.stderr.log" # 「shared」の中を参照するよう変更 #通常のログを記録するファイルを指定 stdout_path "#{app_path}/shared/log/unicorn.stdout.log" #Railsアプリケーションの応答を待つ上限時間を設定 timeout 60 #以下は応用的な設定なので説明は割愛 preload_app true GC.respond_to?(:copy_on_write_friendly=) && GC.copy_on_write_friendly = true check_client_connection false run_once = true before_fork do |server, worker| defined?(ActiveRecord::Base) && ActiveRecord::Base.connection.disconnect! if run_once run_once = false # prevent from firing again end old_pid = "#{server.config[:pid]}.oldbin" if File.exist?(old_pid) && server.pid != old_pid begin sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU Process.kill(sig, File.read(old_pid).to_i) rescue Errno::ENOENT, Errno::ESRCH => e logger.error e end end end after_fork do |_server, _worker| defined?(ActiveRecord::Base) && ActiveRecord::Base.establish_connection end ``` production.rb ``` server '18.179.97.156', user: 'ec2-user', roles: %w{app db web} set :ssh_options, { keys: %w(~/.ssh/coffee-passport-ssh-key.pem), forward_agent: true, # auth_methods: %w(publickey password) # password: "please use keys" auth_methods: %w(publickey), port: 22 } ``` ここら辺が、自動デプロイに関係しそうなファイルなのですが、 いったいどこの部分が問題かわかりません。 bundle_pathみたいな変数も見つかりません。。。。 丸投げになってしまって申し訳ないのですが、色々な記事を見ても自動デプロイの際にこれ以外の設定ファイルもないように思えて これ以上どうしたら良いのかわかりません。。。 よろしくお願いします。
divclass123

2021/05/15 13:24

bundler:install The Gemfile's dependencies are satisfied, skipping installation 00:17 deploy:assets:precompile 01 $HOME/.rbenv/bin/rbenv exec bundle exec rake assets:precompile 01 rake aborted! 01 LoadError: libmysqlclient.so.18: cannot open shared object file: No su… 01 /var/www/coffee_passport/shared/bundle/ruby/2.6.0/gems/bootsnap-1.7.5/… 01 /var/www/coffee_passport/shared/bundle/ruby/2.6.0/gems/bootsnap-1.7.5/… 01 /var/www/coffee_passport/shared/bundle/ruby/2.6.0/gems/bootsnap-1.7.5/… 01 /var/www/coffee_passport/shared/bundle/ruby/2.6.0/gems/bootsnap-1.7.5/… 01 /var/www/coffee_passport/shared/bundle/ruby/2.6.0/gems/bootsnap-1.7.5/… 01 /var/www/coffee_passport/shared/bundle/ruby/2.6.0/gems/activesupport-6… 01 /var/www/coffee_passport/shared/bundle/ruby/2.6.0/gems/activesupport-6… 01 /var/www/coffee_passport/shared/bundle/ruby/2.6.0/gems/activesupport-6… 01 /var/www/coffee_passport/shared/bundle/ruby/2.6.0/gems/mysql2-0.5.3/li… 01 /var/www/coffee_passport/shared/bundle/ruby/2.6.0/gems/bootsnap-1.7.5/… 01 /var/www/coffee_passport/shared/bundle/ruby/2.6.0/gems/bootsnap-1.7.5/… 01 /var/www/coffee_passport/shared/bundle/ruby/2.6.0/gems/bootsnap-1.7.5/… 01 /var/www/coffee_passport/shared/bundle/ruby/2.6.0/gems/bootsnap-1.7.5/… 01 /var/www/coffee_passport/shared/bundle/ruby/2.6.0/gems/bootsnap-1.7.5/… 01 /var/www/coffee_passport/releases/20210515132217/config/application.rb… 01 /var/www/coffee_passport/releases/20210515132217/Rakefile:4:in `requir… 01 /var/www/coffee_passport/releases/20210515132217/Rakefile:4:in `<top (… 01 /var/www/coffee_passport/shared/bundle/ruby/2.6.0/gems/rake-13.0.3/exe… 01 /home/ec2-user/.rbenv/versions/2.6.5/bin/bundle:23:in `load' 01 /home/ec2-user/.rbenv/versions/2.6.5/bin/bundle:23:in `<main>' 01 (See full trace by running task with --trace) #<Thread:0x00007fa3f9b90768@/Users/soichirohara/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/sshkit-1.21.2/lib/sshkit/runners/parallel.rb:10 run> terminated with exception (report_on_exception is true): Traceback (most recent call last): 13: from /Users/soichirohara/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/sshkit-1.21.2/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute' エラー文がこんな感じなので、 [ec2-user@ip-10-0-10-10 ~]$ yum search mysql 読み込んだプラグイン:extras_suggestions, langpacks, priorities, update-motd 43 packages excluded due to repository priority protections ============================== N/S matched: mysql ============================== MySQL-python.x86_64 : An interface to MySQL apr-util-mysql.x86_64 : APR utility library MySQL DBD driver dovecot-mysql.x86_64 : MySQL back end for dovecot freeradius-mysql.x86_64 : MySQL support for freeradius libdbi-dbd-mysql.x86_64 : MySQL plugin for libdbi mysql-community-client.i686 : MySQL database client applications and tools mysql-community-client.x86_64 : MySQL database client applications and tools mysql-community-client-plugins.i686 : Shared plugins for MySQL client : applications mysql-community-client-plugins.x86_64 : Shared plugins for MySQL client : applications mysql-community-common.i686 : MySQL database common files for server and client : libs mysql-community-common.x86_64 : MySQL database common files for server and : client libs mysql-community-devel.i686 : Development header files and libraries for MySQL : database client applications mysql-community-devel.x86_64 : Development header files and libraries for MySQL : database client applications mysql-community-embedded-compat.i686 : MySQL embedded compat library mysql-community-embedded-compat.x86_64 : MySQL embedded compat library mysql-community-libs.i686 : Shared libraries for MySQL database client : applications mysql-community-libs.x86_64 : Shared libraries for MySQL database client : applications mysql-community-libs-compat.i686 : Shared compat libraries for MySQL 5.6.37 : database client applications mysql-community-libs-compat.x86_64 : Shared compat libraries for MySQL 5.6.45 : database client applications mysql-community-release.noarch : MySQL repository configuration for yum mysql-community-test.x86_64 : Test suite for the MySQL database server mysql-connector-c++.x86_64 : MySQL database connector for C++ mysql-connector-c++-debuginfo.x86_64 : Debug information for package : mysql-connector-c++ mysql-connector-c++-devel.x86_64 : Development header files and libraries for : MySQL C++ client applications mysql-connector-c++-jdbc.x86_64 : MySQL Driver for C++ which mimics the JDBC 4.0 : API mysql-connector-java.noarch : Official JDBC driver for MySQL mysql-connector-odbc.x86_64 : ODBC driver for MySQL mysql-connector-odbc-debuginfo.x86_64 : Debug information for package : mysql-connector-odbc mysql-connector-odbc-setup.x86_64 : An ODBC 8.0 driver for MySQL - setup library mysql-connector-python.noarch : Standardized MySQL database driver for Python mysql-connector-python.x86_64 : Standardized MySQL database driver for Python mysql-connector-python-cext.x86_64 : Standardized MySQL driver for Python with C : Extension mysql-connector-python-debuginfo.x86_64 : Debug information for package : mysql-connector-python mysql-connector-python3.x86_64 : Standardized MySQL database driver for Python 3 mysql-connector-python3-cext.x86_64 : Standardized MySQL driver for Python with : C Extension mysql-ref-manual-8.0-en-html-chapter.noarch : The MySQL Reference Manual (HTML, : English) mysql-ref-manual-8.0-en-pdf.noarch : The MySQL Reference Manual (PDF, English) mysql-router.x86_64 : MySQL Router mysql-router-community.x86_64 : MySQL Router mysql-router-debuginfo.x86_64 : Debug information for package mysql-router mysql-shell.x86_64 : Command line shell and scripting environment for MySQL mysql-shell-debuginfo.x86_64 : Debug information for package mysql-shell mysql-utilities.noarch : Collection of utilities used for maintaining and : administering MySQL servers mysql-utilities-extra.noarch : Additional files for mysql-utilities mysql-workbench-community.x86_64 : A MySQL visual database modeling, ...: administration, development and migration tool mysql-workbench-community-debuginfo.x86_64 : Debug information for package : mysql-workbench-community mysql80-community-release.noarch : MySQL repository configuration for yum pcp-pmda-mysql.x86_64 : Performance Co-Pilot (PCP) metrics for MySQL perl-DBD-MySQL.x86_64 : A MySQL interface for Perl php-mysql.x86_64 : A module for PHP applications that use MySQL databases php-mysqlnd.x86_64 : A module for PHP applications that use MySQL databases qt-mysql.x86_64 : MySQL driver for Qt’s SQL classes qt-mysql.i686 : MySQL driver for Qt’s SQL classes qt3-MySQL.x86_64 : MySQL drivers for Qt 3's SQL classes qt3-MySQL.i686 : MySQL drivers for Qt 3's SQL classes qt5-qtbase-mysql.x86_64 : MySQL driver for Qt5's SQL classes qt5-qtbase-mysql.i686 : MySQL driver for Qt5's SQL classes redland-mysql.x86_64 : MySQL storage support for Redland rsyslog-mysql.x86_64 : MySQL support for rsyslog mariadb.x86_64 : A community developed branch of MySQL mariadb-devel.x86_64 : Files for development of MariaDB/MySQL applications mariadb-libs.x86_64 : The shared libraries required for MariaDB/MySQL clients mariadb-libs.i686 : The shared libraries required for MariaDB/MySQL clients mysql-community-server.x86_64 : A very fast and reliable SQL database server Name and summary matches only, use “search all” for everything. yum search mysqlで引っかかったどれかしらを yum installすれば良いんじゃないか。と思っているのですが、僕の考え方はあっているでしょうか?
yu_1985

2021/05/15 13:54

> shared/bundleを参照してくれない いや、参照した上でそこにファイルがない、と言ってるのではないでしょうか。 ログをちゃんと見てください。 gemが配置されているところを参照してても該当のファイルがないのだから何らかの理由でbundle installがうまく行ってないのでは?と言ったのです。 そもそもですが、capistranoが行っている処理を手動で行ったらどうなるのでしょうか?
yu_1985

2021/05/15 13:56

> yum search mysqlで引っかかったどれかしらをyum installすれば良いんじゃないか。と思っているのですが、僕の考え方はあっているでしょうか? 結論から言うと、それが合っている可能性は低いです。 ログを見ると、bundle installして配置されるgemの中に必要とされるファイルがない、ということが読み取れます。 なので、サーバ上に何かしらミドルウェアを入れても解決する可能性は低いでしょう。
divclass123

2021/05/15 14:02

ありがとうございます。 capistranoの手動デプロイの詳しいやり方を調べていきます。 そこで手動で実行した結果を元に調べていきます。 一応、EC2内ではbundle installはうまくいっています。 https://tackeyy.com/blog/posts/fix-libmysqlclient-r-so-16-cannot-open こういった記事を見つけたので、bundle installがうまくいってるのでキャッシュが悪さしているのでは。と思ったのですがどうでしょうか。
yu_1985

2021/05/15 14:11

> capistranoの手動デプロイの そういうことではなくて、capistranoにやらせているデプロイの流れを実際に手動で行ったらどうなりますか、ということなのですが…。 capistranoは基本的に手動でデプロイするときにやることを単に一連の処理としてやってくれているだけで、やっていることが手動でデプロイするときとそう大きく変わるわけではありません。 CircleCIを使っているわけではないのでキャッシュは登場しませんね。 ただ、古いgemが原因の可能性があるので消して入れ直すのは試してもいいと思います。
divclass123

2021/05/15 14:28

あ、はい。僕の伝え方が悪かったです。 1.git push 2. ssh接続 3.git pull (謎のコンフリクトが起きてますが) 4.unicornの再起動 5.アセットのコンパイル といった処理を手動で行うといった認識で大丈夫でしょうか? ちなみにgemは入れ直しました。 キャッシュは関係ないのですね、ありがとうございます。
divclass123

2021/05/15 15:15

SyntaxError: /var/www/coffee_passport/app/controllers/application_controller.rb:7: syntax error, unexpected <<, expecting end <<<<<<< HEAD ^~ /var/www/coffee_passport/app/controllers/application_controller.rb:9: syntax error, unexpected ===, expecting end ======= ^~~ /var/www/coffee_passport/app/controllers/application_controller.rb:11: syntax error, unexpected >>, expecting end >>>>>>> f494c0c665d30025e8c196e... ^~ 大量のコンフリクトが発生しているので、少々お待ちください。
yu_1985

2021/05/15 16:59

それは正しくないです。 capistranoでgit pullはしていないでしょう。 自分で書いたdeploy.rbの内容をきちんと理解しましょう。 コンフリクトしているのはcapistranoく関係がありません。 まずはcapistranoを忘れて手動でデプロイしてみてはどうですか?
divclass123

2021/05/16 05:59

> まずはcapistranoを忘れて手動でデプロイしてみてはどうですか? https://qiita.com/gyu_outputs/items/a8d225dd0716ae54bcf1 先ほど自分が申しあげたような手順だとだめなんですよね? 「capistranoがやってる手順を手動でやる」 といった認識で大丈夫でしょうか?
divclass123

2021/05/16 06:06

問題を切り分けるために、一旦capistranoを用いずに手動でデプロイしてみます。
divclass123

2021/05/16 07:09

手動デプロイはうまくいきました。 capistranoを見直してみます。 本当にアドバイスありがとうございます!
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問