nixpacks
nixpacks copied to clipboard
Rails assets not loading with Nixpacks
Is there an existing issue for this?
- [X] I have searched the existing issues
Describe the bug
I tried to deploy a Rails app on Railway using the default compilation method - Nixpacks. The app is a vanilla rails app, with minimal config. All the secret keys are check into the repo as encrypted credentials. Following are the only env vars apart from Rails defaults
NIXPACKS_BUILD_CMD
bundle exec rake assets:precompile && bundle exec rails db:migrate
NIXPACKS_START_CMD
bundle exec rails s -b 0.0.0.0
With nixpacks, my build step works fine but fails to load any of the assets as shown in the screenshots below. Heroku buildpack works just fine. The issue happens even when I remove the above env vars.



To reproduce
Steps to reproduce the bug:
- Deploy a rails app with standalone tailwind CSS -
rails new testapp --css tailwind
. - Set up some basic styles.
- Push to trailway.
- Navigate to the railway url.
Expected behavior
The styles must load like so, when nixpacks are selected -

Environment
- Rails 7
- Latest Nixpacks ( default )
Can you please provide an example repo. I am seeing build errors on a new rails app generated with that command (outside of nixpacks and railway).
@coffee-cup this is the repo i'm trying to deploy - https://github.com/safewlabs/comix-mono. That's odd because i don't get any build errors while deploying.
It uses a standalone version of Tailwindcss - https://github.com/rails/tailwindcss-rails / https://tailwindcss.com/blog/standalone-cli
I'm seeing the same behavior in my repo.
Additional info:
- Nixpacks builder + RAILS_ENV variable not set = assets pipeline works
- Nixpacks builder + RAILS_ENV=production variable = assets do not load
- Heroku builder + RAILS_ENV=production variable = assets pipeline works
This is currently deployed to: https://web-production-61e7.up.railway.app/
As of October 12 @ 11:30p PST, I've switched back to the failing scenario above (Nixpacks builder + RAILS_ENV=production variable, assets do not load). Hopefully the logs linked to that deployment are helpful to diagnose.
Is there anything else I can do to help investigate?
When I compare the deployment logs, searching for "rake assets", I notice one difference that may be directly relevant:
Heroku builder + RAILS_ENV=production variable = assets pipeline works
Running: rake assets:precompile
Running: rake assets:clean
Nixpacks builder + RAILS_ENV=production variable = assets do not load
║ build │ bundle exec rake assets:precompile ║
#20 [stage-0 16/18] RUN bundle exec rake assets:precompile
It appears that the Nixbuilds are missing the "rake assets:clean" invocation.
Not sure if there are other meaningful distinctions too -- I focused on the word "assets" in my comparison, but there may be other subtleties.
@coffee-cup fyi ^ there's an additional repro now, if that helps.
I split my issue to a separate ticket (https://github.com/railwayapp/nixpacks/issues/672) and will delete my previous comments, to keep this original issue cleaner.