Search code examples
ruby-on-railsruby-on-rails-7render.com

Rails 7 deploy failing on Render.com during assets:precompile - ActionView::Template::Error (The asset __ is not present in the asset pipeline.)


This bug is suddenly affecting all of our 3 Rails applications on Render.com. The codebase wasn't changed but the deployment suddenly stopped being successful.

During the build on Render.com, specifically during the asset precompilation, we now see these loglines:

INFO** Execute assets:precompile
INFOrake aborted!
INFOJSON::ParserError: 859: unexpected token at '==> Using Node version 14.17.0 (default)
INFO==> Docs on specifying a Node version: https://render.com/docs/node-version
INFO==> Using Bun version  (default)
INFO==> Docs on specifying a bun version: https://render.com/docs/bun-version
INFO["ok"]'
INFO/opt/render/project/rubies/ruby-3.1.1/lib/ruby/3.1.0/json/common.rb:216:in `parse'
INFO/opt/render/project/rubies/ruby-3.1.1/lib/ruby/3.1.0/json/common.rb:216:in `parse'
[...]
INFO==> Uploading build...
INFO==> Build uploaded in 12s
INFO==> Build successful 🎉
INFO==> Deploying...
INFO==> Using Node version 14.17.0 (default)

Then the Build seems successful but, after the go-live:

[104] Puma starting in cluster mode...
INFO[104] * Puma version: 5.6.8 (ruby 3.1.1-p18) ("Birdie's Version")
INFO[104] *  Min threads: 2
INFO[104] *  Max threads: 2
INFO[104] *  Environment: production
INFO[104] *   Master PID: 104
INFO[104] *      Workers: 2
INFO[104] *     Restarts: (✔) hot (✖) phased
INFO[104] * Preloading application
INFO[104] * Listening on http://0.0.0.0:10000
INFO[104] Use Ctrl-C to stop
INFO[104] - Worker 0 (PID: 109) booted in 0.0s, phase: 0
INFO[104] - Worker 1 (PID: 113) booted in 0.0s, phase: 0
INFO==> Your service is live 🎉

Every request fails with some variant of the following error:

CRITICALF, [2024-05-31T08:10:58.076796 #109] FATAL -- : [da58ff63-3c0c-4f42-bfe3-a3a243352908]   
ERROR[da58ff63-3c0c-4f42-bfe3-a3a243352908] ActionView::Template::Error (The asset "searches/show.css" is not present in the asset pipeline.
INFO):
INFO[da58ff63-3c0c-4f42-bfe3-a3a243352908]     1: <% content_for :head do %>
INFO[da58ff63-3c0c-4f42-bfe3-a3a243352908]     2:   <%= stylesheet_link_tag 'searches/show' -%>
INFO[da58ff63-3c0c-4f42-bfe3-a3a243352908]     3:   <%= stylesheet_link_tag 'elements/filters' -%>
INFO[da58ff63-3c0c-4f42-bfe3-a3a243352908]     4: <% end %>

This started happening on May 30, simultaneously for all of our Rails applications that run on Render.com.

When assets are precompiled locally, the issue doesn't present itself. So the only solution we found, so far, is to precompile assets locally and then upload them. But this is not ideal, nor long-term.

Chances are this is affecting a lot of Rails applications on Render. Any help would be greatly appreciated!


Solution

  • We solved this issue by adding node --version; to our build command under Settings > Build & Deploy. Our complete build command is now the following:

    node --version; bundle install; bundle exec rake assets:clean assets:precompile; bundle exec rake db:migrate;
    

    Render.com settings build

    The Render support recently clarified why this happened, here's what they wrote me:

    Adding node --version forces Node to be loaded into the environment, whereas before it was loaded automatically all the time. We've made this change to dynamically load languages now, so if we don't detect Node, we don't load it into the environment.