繁体   English   中英

Capistrano不会使用Bundler部署Rails应用程序

[英]Capistrano Wont Deploy Rails App With Bundler

我正在尝试使用postgres将我的rails应用程序设置到DigitalOcean服务器上,遵循本教程 我正在尝试使用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'

我已经尝试在deploy @ myapp和我的本地计算机上运行gem install bundler:2.0.1gem install bundler 有关如何解决此问题的任何建议,并修复当我尝试使用capistrano rbenv将我的应用部署到生产时发生的错误?

编辑 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'

切换到正确的rbenv 之后,首先检查是否已将Bundler安装为部署用户:

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'

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM