Search code examples
ruby-on-railsrubyruby-on-rails-5capistranoruby-on-rails-6

Rails 6 Capistrano error "assets:precompile"


Please, I have the same problem: Deploy error ruby on rails Don't know how to build task 'assets:precompile'?

If it's possible, helpme and help this guy too.

Thanks in advance for your attention

Update:

With @Anuj help, I find the solution: Precisely because my project is API by default, I don't have the precompile assets (@Anuj said the same, I didn't know). The solution to me is:

-> remove inside my Capfile: require 'capistrano/rails/assets'

-> remove inside my deploy.rb after :finishing, :compile_assets


Solution

  • assets:precompile is a task provided by Sprockets, which does not get included by default in an API only app (because APIs don't need assets).

    In your Capfile, when you write

    require 'capistrano/rails'
    

    it basically includes both the below lines automatically

    require 'capistrano/rails/assets'
    require 'capistrano/rails/migrations'
    

    If you replace the capistrano/rails with just capistrano/rails/migrations in your Capfile, that should solve your problem.