运行后是否有人遇到此错误:
cap production deploy
我使用capistrano:Capistrano版本:3.6.1(耙子版本:11.3.0)
这是日志:
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as deploy@54.169.99.36: rake exit status: 1
rake stdout: rake aborted!
Don't know how to build task 'assets:precompile' (see --tasks)
/home/deploy/microwave-api/shared/bundle/ruby/2.3.0/gems/rake-11.3.0/exe/rake:27:in `<top (required)>'
.
.
.
/home/deploy/.rvm/gems/ruby-2.3.0/gems/bundler-1.13.6/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/home/deploy/.rvm/gems/ruby-2.3.0/gems/bundler-1.13.6/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/home/deploy/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `<main>'
(See full trace by running task with --trace)
rake stderr: Nothing written
SSHKit::Command::Failed: rake exit status: 1
rake stdout: rake aborted!
Don't know how to build task 'assets:precompile' (see --tasks)enter code here
答案 0 :(得分:22)
听起来您可能没有设置Sprockets(仅限API的应用程序?)。
在你的Capfile中,你可能有类似的东西:
require 'capistrano/rails'
该行实际上是requires a file,如下所示:
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
所以你可以用以下代码替换前一行:
require 'capistrano/rails/migrations'
,将不再运行资产预编译。
如上所述,这假设您实际上并不想使用资产管道。如果不是这种情况,问题是您不包括Sprockets,您需要研究它。我会生成一个新的rails应用并比较您的Gemfile
和config/application.rb
。
答案 1 :(得分:3)
如果您的rails应用程序仅限API,请不要添加require 'capistrano/rails/assets'
或require "capistrano/rails"
。
添加以下内容:
require 'capistrano/bundler'
require 'capistrano/rails/migrations'
最后,您的Capfile将如下所示:
require "capistrano/setup"
require "capistrano/deploy"
require "capistrano/scm/git"
install_plugin Capistrano::SCM::Git
require "capistrano/rbenv"
set :rbenv_type, :user
set :rbenv_ruby, "2.5.1"
require 'capistrano/bundler'
require 'capistrano/rails/migrations'
# Load custom tasks from `lib/capistrano/tasks` if you have any defined
Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r }