These are my software versions:
This is my Capfile:
require "capistrano/setup"
require "capistrano/deploy"
require "capistrano/scm/git"
install_plugin Capistrano::SCM::Git
require "capistrano/rvm"
require "capistrano/bundler"
require "capistrano/rails/assets"
require "capistrano/rails/migrations"
require "capistrano/puma"
install_plugin Capistrano::Puma
config/deploy.rb:
server '192.168.0.1', port: 22, roles: [:web, :app, :db], primary: true
set :application, "testapp"
set :repo_url, "git@github.com:username/testapp.git"
set :user, 'deploy'
set :puma_threads, [4, 16]
set :puma_workers, 0
set :pty, true
set :use_sudo, false
set :stage, :production
set :deploy_via, :remote_cache
set :deploy_to, "/home/#{fetch(:user)}/apps/#{fetch(:application)}"
set :puma_bind, "unix://#{shared_path}/tmp/sockets/#{fetch(:application)}-puma.sock"
set :puma_state, "#{shared_path}/tmp/pids/puma.state"
set :puma_pid, "#{shared_path}/tmp/pids/puma.pid"
set :puma_access_log, "#{release_path}/log/puma.error.log"
set :puma_error_log, "#{release_path}/log/puma.access.log"
set :ssh_options, { forward_agent: true, user: fetch(:user), keys: %w(~/.ssh/id_rsa.pub) }
set :puma_preload_app, true
set :puma_worker_timeout, nil
set :puma_init_active_record, true # Change to false when not using ActiveRecord
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
desc "Make sure local git is in sync with remote."
task :check_revision do
on roles(:app) do
unless `git rev-parse HEAD` == `git rev-parse origin/master`
puts "WARNING: HEAD is not the same as origin/master"
puts "Run `git push` to sync changes."
exit
end
end
end
desc 'Initial Deploy'
task :initial do
on roles(:app) do
before 'deploy:restart', 'puma:start'
invoke 'deploy'
end
end
desc 'Restart application'
task :restart do
on roles(:app), in: :sequence, wait: 5 do
invoke 'puma:restart'
end
end
When I ran cap production deploy:initial
, I got these errors:
Results logged to
/home/deploy/apps/testapp/shared/bundle/ruby/2.2.0/extensions/x86_64-linux/2.2.0/nokogiri-1.8.0/gem_make.out
An error occurred while installing nokogiri (1.8.0), and Bundler cannot
continue.
Make sure that `gem install nokogiri -v '1.8.0'` succeeds before bundling.
In Gemfile:
rails was resolved to 4.2.0, which depends on
actionmailer was resolved to 4.2.0, which depends on
actionpack was resolved to 4.2.0, which depends on
actionview was resolved to 4.2.0, which depends on
rails-dom-testing was resolved to 1.0.8, which depends on
nokogiri
bundle stderr: Nothing written
** DEPLOY FAILED
** Refer to log/capistrano.log for details. Here are the last 20 lines:
extconf failed, exit code 1
Gem files will remain installed in
/home/deploy/apps/testapp/shared/bundle/ruby/2.2.0/gems/nokogiri-1.8.0 for
inspection.
Results logged to
/home/deploy/apps/testapp/shared/bundle/ruby/2.2.0/extensions/x86_64-linux/2.2.0/nokogiri-1.8.0/gem_make.out
An error occurred while installing nokogiri (1.8.0), and Bundler cannot
continue.
Make sure that `gem install nokogiri -v '1.8.0'` succeeds before bundling.
In Gemfile:
rails was resolved to 4.2.0, which depends on
actionmailer was resolved to 4.2.0, which depends on
DEBUG [419bf769] actionpack was resolved to 4.2.0, which depends on
actionview was resolved to 4.2.0, which depends on
rails-dom-testing was resolved to 1.0.8, which depends on
nokogiri
I installed ruby 2.2.1 on my remote server. Why does it use 2.2.0
here?
I also removed the Gemfile.lock
file and ran bundle
again. The file is like:
...
loofah (2.0.3)
nokogiri (>= 1.5.9)
mail (2.6.6)
mime-types (>= 1.16, < 4)
mime-types (3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mini_portile2 (2.2.0)
minitest (5.10.2)
multi_json (1.12.1)
net-scp (1.2.1)
net-ssh (>= 2.6.5)
net-ssh (4.1.0)
nokogiri (1.8.0)
mini_portile2 (~> 2.2.0)
puma (3.9.1)
rack (1.6.8)
rack-test (0.6.3)
rack (>= 1.0)
rails (4.2.0)
actionmailer (= 4.2.0)
actionpack (= 4.2.0)
actionview (= 4.2.0)
activejob (= 4.2.0)
activemodel (= 4.2.0)
activerecord (= 4.2.0)
activesupport (= 4.2.0)
bundler (>= 1.3.0, < 2.0)
railties (= 4.2.0)
sprockets-rails
rails-deprecated_sanitizer (1.0.3)
activesupport (>= 4.2.0.alpha)
rails-dom-testing (1.0.8)
activesupport (>= 4.2.0.beta, < 5.0)
nokogiri (~> 1.6)
rails-deprecated_sanitizer (>= 1.0.1)
...
PLATFORMS
ruby
DEPENDENCIES
byebug
capistrano
capistrano-bundler
capistrano-rails
capistrano-rvm
capistrano3-puma
coffee-rails (~> 4.1.0)
jbuilder (~> 2.0)
jquery-rails
puma
rails (= 4.2.0)
sass-rails (~> 5.0)
sdoc (~> 0.4.0)
spring
sqlite3
turbolinks
uglifier (>= 1.3.0)
web-console (~> 2.0)
After trying sometimes again and again, I found the reason finally.
It's only why can't install nokogiri
.
On the target server, there should install these necessary packages first:
sudo apt-get install zlib1g-dev libssl-dev libreadline-dev libyaml-dev libxml2-dev libxslt-dev
The nokogiri
gem depend on these libraries: libxml2-dev
, libxslt-dev
(maybe).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.