Capistrano не будет развертывать приложение Rails с Bundler - PullRequest
0 голосов
/ 09 апреля 2019

Я пытаюсь настроить мое приложение rails на сервере DigitalOcean с postgres, следуя Это руководство . Я нахожусь в точке, где я пытаюсь развернуть мое приложение с Capistrano, но когда я запускаю $cap production deploy, оно всегда терпит неудачу с этим сообщением об ошибке:

** DEPLOY FAILED
** Refer to log/capistrano.log for details. Here are the last 20 lines:


 DEBUG [1c7e325c]       )

 DEBUG [1c7e325c]       

 DEBUG [1c7e325c]       To update to the latest version installed on your system, run `bundle update --bundler`.

To install the missing version, run `gem install bundler:2.0.1`

 DEBUG [1c7e325c]               from /home/deploy/.rbenv/versions/2.6.1/lib/ruby/2.6.0/rubygems.rb:302:in `activate_bin_path'

 DEBUG [1c7e325c]               from /home/deploy/.rbenv/versions/2.6.1/bin/bundle:23:in `<main>'

 DEBUG [1c7e325c] Finished in 0.408 seconds with exit status 1 (failed).

  INFO [5d18f10c] Running $HOME/.rbenv/bin/rbenv exec bundle install --path /home/deploy/myapp/shared/bundle --jobs 4 --without development test --deployment --quiet as deploy@1.2.3.4

 DEBUG [5d18f10c] Command: cd /home/deploy/myapp/releases/20190408225913 && ( export RBENV_ROOT="$HOME/.rbenv" RBENV_VERSION="2.6.1" ; $HOME/.rbenv/bin/rbenv exec bundle install --path /home/deploy/myapp/shared/bundle --jobs 4 --without development test --deployment --quiet )

 DEBUG [969718b0]       /home/deploy/.rbenv/versions/2.6.1/lib/ruby/2.6.0/rubygems.rb:283:in `find_spec_for_exe'

 DEBUG [969718b0]       : 

 DEBUG [969718b0]       Could not find 'bundler' (2.0.1) required by your /home/deploy/myapp/releases/20190408225913/Gemfile.lock.

 DEBUG [969718b0]        (

 DEBUG [969718b0]       Gem::GemNotFoundException

 DEBUG [969718b0]       )

 DEBUG [969718b0]       

 DEBUG [969718b0]       To update to the latest version installed on your system, run `bundle update --bundler`.

To install the missing version, run `gem install bundler:2.0.1`

 DEBUG [969718b0]               from /home/deploy/.rbenv/versions/2.6.1/lib/ruby/2.6.0/rubygems.rb:302:in `activate_bin_path'

 DEBUG [969718b0]               from /home/deploy/.rbenv/versions/2.6.1/bin/bundle:23:in `<main>'

Это мой файл развертывания:

set :application, "myapp"
set :repo_url, "git@github.com:user/myapp.git"
append :rbenv_map_bins, 'puma', 'pumactl'
# Deploy to the user's home directory
set :deploy_to, "/home/deploy/#{fetch :application}"


set :default_environment, {
    'PATH' => "$HOME/.rbenv/shims:$HOME/.rbenv/bin:$PATH"
}


append :linked_dirs, 'log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', '.bundle', 'public/system', 'public/uploads'

# Only keep the last 5 releases to save disk space
set :keep_releases, 5

# Optionally, you can symlink your database.yml and/or secrets.yml file from the shared directory during deploy
# This is useful if you don't want to use ENV variables
# append :linked_files, 'config/database.yml', 'config/secrets.yml'

Gemfile:

source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '2.4.1'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.2.3'
# Use postgresql as the database for Active Record
gem 'pg', '>= 0.18', '< 2.0'
# Use Puma as the app server
gem 'puma', '~> 3.11'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'mini_racer', platforms: :ruby

# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# 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.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use ActiveStorage variant
# gem 'mini_magick', '~> 4.8'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.1.0', 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]
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'
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 chromedriver to run system tests with Chrome
  gem 'chromedriver-helper'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

gem 'capistrano', '~> 3.11'
gem 'capistrano-passenger', '~> 0.2.0'
gem 'capistrano-rails', '~> 1.4'
gem 'capistrano-rbenv', '~> 2.1', '>= 2.1.4'

Я уже пытался запустить gem install bundler:2.0.1 и gem install bundler на deploy @ myapp и на моем локальном компьютере. Любые предложения о том, как я могу решить эту проблему и исправить ошибку, которая возникает, когда я пытаюсь развернуть свое приложение в рабочей среде с помощью capistrano rbenv?

EDIT 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"

# Load custom tasks from `lib/capistrano/tasks` if you have any defined
Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r }

require 'capistrano/rails'
require 'capistrano/passenger'
require 'capistrano/rbenv'

set :rbenv_type, :user
set :rbenv_ruby, '2.6.1'

1 Ответ

0 голосов
/ 09 апреля 2019

Сначала проверьте, установлен ли у вас в качестве пользователя развертывания пакет после переключения на правильный rbenv:

rbenv global 2.6.1
bundler --version

Если не установить его: gem install bundler:2.0.1.

В противном случае убедитесь, что на вашем Capfile есть упомянутая метка rbenv (см. Учебник).

set :rbenv_type, :user
set :rbenv_ruby, '2.6.1'
...