[英]Deploy raise error “Don't know how to build task 'assets:precompile'” (Capistrano)
Does anyone ever got this error after run : 有人在运行后遇到此错误:
cap production deploy
I'm Using capistrano : Capistrano Version: 3.6.1 (Rake Version: 11.3.0) 我正在使用capistrano:Capistrano版本:3.6.1(耙子版本:11.3.0)
Here is the log : 这是日志:
(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
Sounds like you probably don't have Sprockets set up (an API only application?). 听起来你可能没有设置Sprockets(一个只有API的应用程序?)。
In your Capfile, you probably have something like: 在你的Capfile中,你可能有类似的东西:
require 'capistrano/rails'
That line actually requires a file which looks like: 该行实际上需要一个看起来像这样的文件 :
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
So you can replace the former line with just: 所以你可以用以下代替前一行:
require 'capistrano/rails/migrations'
and the asset precompilation will no longer be run. 并且将不再运行资产预编译。
As mentioned above, this assumes that you don't actually want to use the asset pipeline. 如上所述,这假设您实际上并不想使用资产管道。 If this isn't the case, the issue is that you aren't including Sprockets and you need to look into that. 如果不是这种情况,问题是您不包括Sprockets,您需要研究它。 I'd generate a new rails app and compare your Gemfile
and config/application.rb
. 我将生成一个新的rails应用程序并比较你的Gemfile
和config/application.rb
。
If you rails application is API only, do not add require 'capistrano/rails/assets'
or require "capistrano/rails"
. 如果rails应用程序仅是API,请不要添加require 'capistrano/rails/assets'
或者require "capistrano/rails"
。
Add following: 添加以下:
require 'capistrano/bundler'
require 'capistrano/rails/migrations'
At the end your Capfile will look something like this: 最后你的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 }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.