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

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

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

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

Capistrano

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

Q&A

解決済

1回答

2667閲覧

rails/capistoranoでデプロイ実行でpumaが起動しない

TomM

総合スコア11

Ruby on Rails 5

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

Capistrano

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

0グッド

0クリップ

投稿2018/01/07 01:33

ローカルのVagrantからcapistoranoでさくらVPSにデプロイをしようとしています。
LoadError: libmysqlclient.so.18が出てきてpumaが起動しません。
参考ファイルは以下に添付します。ご教授お願いします。

deploy.rb

# config valid for current version and patch releases of Capistrano lock "~> 3.10.1" set :application, "rails_api" set :repo_url, "https://github.com/tomoyoshi-de/rails_api.git" # Default branch is :master ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp # Default deploy_to directory is /var/www/my_app_name set :deploy_to, "/var/www/rails_api" # Default value for :format is :airbrussh. # set :format, :airbrussh # You can configure the Airbrussh format using :format_options. # These are the defaults. # set :format_options, command_output: true, log_file: "log/capistrano.log", color: :auto, truncate: :auto # Default value for :pty is false # set :pty, true # Default value for :linked_files is [] append :linked_files, "config/database.yml", "config/secrets.yml", 'config/cable.yml' # Default value for linked_dirs is [] append :linked_dirs, "log", "tmp/pids", "tmp/cache", "tmp/sockets", "public/system" set :rbenv_ruby, '2.5.0' set :puma_pid, "#{shared_path}/tmp/pids/puma.pid" namespace :puma do desc 'Create Directories for Puma Pids and Socket' task :make_dirs do on roles(:app) do execute "mkdir #{shared_path}/tmp/sockets -p" execute "mkdir #{shared_path}/tmp/pids -p" end end before :start, :make_dirs end namespace :deploy do after :restart, :clear_cache do on roles(:web), in: :groups, limit: 3, wait: 10 do # Here we can do anything such as: # within release_path do # execute :rake, 'cache:clear' # end end end end namespace :upload do %w(database secrets cable).each do |name| desc "upload config/#{name}.yml" task :"#{name}" do on roles(:app), in: :sequence do |host| execute :mkdir, '-p', "#{shared_path}/config" upload!("config/#{name}.yml","#{shared_path}/config/#{name}.yml") end end end end # Default value for default_env is {} # set :default_env, { path: "/opt/ruby/bin:$PATH" } # Default value for local_user is ENV['USER'] # set :local_user, -> { `git config user.name`.chomp } # Default value for keep_releases is 5 # set :keep_releases, 5 # Uncomment the following to require manually verifying the host key before first deploy. # set :ssh_options, verify_host_key: :secure

Capfile

# Load DSL and set up stages require "capistrano/setup" # Include default deployment tasks require "capistrano/deploy" # Load the SCM plugin appropriate to your project: # # require "capistrano/scm/hg" # install_plugin Capistrano::SCM::Hg # or # require "capistrano/scm/svn" # install_plugin Capistrano::SCM::Svn # or require "capistrano/scm/git" install_plugin Capistrano::SCM::Git # Include tasks from other gems included in your Gemfile # # For documentation on these, see for example: # # https://github.com/capistrano/rvm # https://github.com/capistrano/rbenv # https://github.com/capistrano/chruby # https://github.com/capistrano/bundler # https://github.com/capistrano/rails # https://github.com/capistrano/passenger # # require "capistrano/rvm" require "capistrano/rbenv" # require "capistrano/chruby" require "capistrano/bundler" #require "capistrano/rails/assets" require "capistrano/rails/migrations" # require "capistrano/passenger" require 'capistrano/puma' install_plugin Capistrano::Puma # Load custom tasks from `lib/capistrano/tasks` if you have any defined Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r }

エラーメッセージは以下です。
=== puma startup: 2018-01-07 10:13:10 +0900 ===
LoadError: libmysqlclient.so.18: cannot open shared object file: No such file or directory - /var/www/rails_api/shared/bundle/ruby/2.5.0/gems/mysql2-0.4.10/lib/mysql2/mysql2.so
/var/www/rails_api/shared/bundle/ruby/2.5.0/gems/mysql2-0.4.10/lib/mysql2.rb:31:in require' /var/www/rails_api/shared/bundle/ruby/2.5.0/gems/mysql2-0.4.10/lib/mysql2.rb:31:in <top (required)>'
/home/tomoyoshi/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/runtime.rb:81:in require' /home/tomoyoshi/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/runtime.rb:81:in block (2 levels) in require'
/home/tomoyoshi/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/runtime.rb:76:in each' /home/tomoyoshi/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/runtime.rb:76:in block in require'
/home/tomoyoshi/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/runtime.rb:65:in each' /home/tomoyoshi/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/runtime.rb:65:in require'
/home/tomoyoshi/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler.rb:114:in require' /var/www/rails_api/releases/20180107005503/config/application.rb:17:in <top (required)>'
/var/www/rails_api/current/config/environment.rb:2:in require_relative' /var/www/rails_api/current/config/environment.rb:2:in <top (required)>'
/var/www/rails_api/current/config.ru:3:in require_relative' /var/www/rails_api/current/config.ru:3:in block in <main>'
/var/www/rails_api/shared/bundle/ruby/2.5.0/gems/rack-2.0.3/lib/rack/builder.rb:55:in instance_eval' /var/www/rails_api/shared/bundle/ruby/2.5.0/gems/rack-2.0.3/lib/rack/builder.rb:55:in initialize'
/var/www/rails_api/current/config.ru:in new' /var/www/rails_api/current/config.ru:in <main>'
/var/www/rails_api/shared/bundle/ruby/2.5.0/gems/rack-2.0.3/lib/rack/builder.rb:49:in eval' /var/www/rails_api/shared/bundle/ruby/2.5.0/gems/rack-2.0.3/lib/rack/builder.rb:49:in new_from_string'
/var/www/rails_api/shared/bundle/ruby/2.5.0/gems/rack-2.0.3/lib/rack/builder.rb:40:in parse_file' /var/www/rails_api/shared/bundle/ruby/2.5.0/gems/puma-3.11.0/lib/puma/configuration.rb:318:in load_rackup'
/var/www/rails_api/shared/bundle/ruby/2.5.0/gems/puma-3.11.0/lib/puma/configuration.rb:243:in app' /var/www/rails_api/shared/bundle/ruby/2.5.0/gems/puma-3.11.0/lib/puma/runner.rb:138:in load_and_bind'
/var/www/rails_api/shared/bundle/ruby/2.5.0/gems/puma-3.11.0/lib/puma/single.rb:87:in run' /var/www/rails_api/shared/bundle/ruby/2.5.0/gems/puma-3.11.0/lib/puma/launcher.rb:183:in run'
/var/www/rails_api/shared/bundle/ruby/2.5.0/gems/puma-3.11.0/lib/puma/cli.rb:77:in run' /var/www/rails_api/shared/bundle/ruby/2.5.0/gems/puma-3.11.0/bin/puma:10:in <top (required)>'
/var/www/rails_api/shared/bundle/ruby/2.5.0/bin/puma:23:in load' /var/www/rails_api/shared/bundle/ruby/2.5.0/bin/puma:23:in <top (required)>'

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

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

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

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

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

guest

回答1

0

ベストアンサー

おそらく,puma の問題ではなく,mysql2 gem が正しくインストールできていない,という問題なので,そういう質問に変えたほうがよさそうです。

試しに

ruby -r mysql2 -e "puts Mysql2::VERSION"

とかやってみて,この gem が require できるかどうか確かめてみられては。

mysql2 のインストールはそれなりにハードルが高いです。

投稿2018/01/07 02:18

scivola

総合スコア2108

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

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

TomM

2018/01/07 09:05

ご回答ありがとうございます。 実際にコマンドを打ってみました。ダメでしたので、mysql2のインストールなのでしょうね。。 /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- mysql2 (LoadError) from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
scivola

2018/01/08 11:22

同じ LoadError ですが,当初の質問のは mysql2.so が見つからない,というもので,今回試していただいたほうは gem 自体が見つけられていないようです。つまり現象としてはまったく違います。 同じ環境ですか? gem list mysql2 では出てきますか?
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問