尝试在Digitalocean上部署,接收Capistrano错误

时间:2017-09-20 17:31:16

标签: ruby-on-rails ruby deployment capistrano capistrano3

我一直在关注Gorail的教程,以便在DigitalOcean上进行部署。 See HereHere also

我已经到达了我在命令行中使用cap生产部署的部分,但是我在下面收到以下错误,我不明白这个错误是如何发生的:

luis@luis-Inspiron-7559:~/Desktop/mls2$ cap production deploy --trace
cap aborted!
LoadError: cannot load such file -- capistrano/rbenv
/usr/local/lib/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/usr/local/lib/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/home/luis/Desktop/mls2/Capfile:31:in `<top (required)>'
/usr/lib/ruby/vendor_ruby/rake/rake_module.rb:28:in `load'
/usr/lib/ruby/vendor_ruby/rake/rake_module.rb:28:in `load_rakefile'
/usr/lib/ruby/vendor_ruby/rake/application.rb:689:in `raw_load_rakefile'
/usr/lib/ruby/vendor_ruby/rake/application.rb:94:in `block in load_rakefile'
/usr/lib/ruby/vendor_ruby/rake/application.rb:176:in `standard_exception_handling'
/usr/lib/ruby/vendor_ruby/rake/application.rb:93:in `load_rakefile'
/usr/lib/ruby/vendor_ruby/rake/application.rb:77:in `block in run'
/usr/lib/ruby/vendor_ruby/rake/application.rb:176:in `standard_exception_handling'
/usr/lib/ruby/vendor_ruby/rake/application.rb:75:in `run'
/usr/lib/ruby/vendor_ruby/capistrano/application.rb:15:in `run'
/usr/bin/cap:3:in `<main>'

这是我的上限文件:

# 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"
set :rbenv_type, :user
set :rbenv_ruby, '2.4.1'

require "capistrano/bundler"
require 'capistrano/rails'

# require "capistrano/chruby"
# 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 }

和我的production.rb:

set :production
server 'xxx.xxx.xxx.xxx', user: 'USER', roles: %w{app db web}

和我的gemfile,我已经按照视频中的建议在开发组中添加了capistrano gems:

...    
group :development do
      # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
      gem 'web-console', '>= 3.3.0'
      gem 'listen', '~> 3.0.5'
      # 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 'capistrano', '~> 3.9', '>= 3.9.1'
      gem 'capistrano-rails', '~> 1.3'
      gem 'capistrano-passenger', '~> 0.2.0'
      gem 'capistrano-rbenv', '~> 2.1', '>= 2.1.1'
    end
...

4 个答案:

答案 0 :(得分:1)

您需要通过将其添加到Gemfile

来安装that dependency
gem 'capistrano-rbenv'

然后bundle install

Capistrano最近开始将一些较少使用的功能分流到可选模块中。

答案 1 :(得分:1)

您忘了在Capfile中要求使用capistrano / passenger。

答案 2 :(得分:1)

首先,这不会直接导致您的问题,但您的Capfile中有错误。如果您查看the official documentation for capistrano-rbenvset命令应该放在deploy.rb中,而不是放在Capfile中。我建议删除这些行并将它们移动到deploy.rb。

# Move to deploy.rb
set :rbenv_type, :user
set :rbenv_ruby, '2.4.1'

在任何情况下,您获得的错误可能是由于无法加载gem capistrano-rbenv这一事实。这是我会尝试的:

  1. 运行bundle exec cap production deploy。所有上限命令必须以bundle exec为前缀。否则无法保证将使用Gemfile。
  2. 如果这不起作用,请运行bundle config without以查看您的Gemfile的development组是否被捆绑程序排除。如果是,请运行bundle config --delete without
  3. 删除该设置

答案 3 :(得分:0)

使用bundle exec cap production deploy运行Capistrano,此外还要确保{Geufile中有capistrano-rbenv gem,并且capistrano/rbenv位于Capfile中,如其他答案中所述。