a month ago
I'm trying to deploy a rails app, and the build is failing. I have a custom assets:precompile task that runs system "npm run build:js && npm run build:css" and my build:js script in the package.json uses esbuild. When the build runs assets:precompile, I get the error below, even though I can see npm ci runs successfully beforehand, and esbuild is in my package.json dependencies list. It's as if none of the dependencies are available for the npm command.
bundle exec rake assets:precompile
> build:js
> esbuild app/javascript/*.* --bundle --splitting --chunk-names=[name][hash]-[hash].digested --sourcemap --outdir=app/assets/builds --format=esm --minify
sh: 1: esbuild: not found
rake aborted!2 Replies
a month ago
Hey! Railpack runs npm ci and bundle exec rake assets:precompile as separate build steps, so node_modules/.bin (where esbuild lives) isn't available when your rake task runs. Your app setup is correct.
As a workaround, I think you could set a custom build command in your service settings:
npm ci && bundle exec rake assets:precompileThis ensures your npm dependencies are installed in the same context where your rake task needs them.
Let us know if this doesn't solve things for you.
Status changed to Awaiting User Response Railway • 28 days ago
sam-a
Hey! Railpack runs npm ci and bundle exec rake assets:precompile as separate build steps, so node_modules/.bin (where esbuild lives) isn't available when your rake task runs. Your app setup is correct.As a workaround, I think you could set a custom build command in your service settings:npm ci && bundle exec rake assets:precompileThis ensures your npm dependencies are installed in the same context where your rake task needs them. Let us know if this doesn't solve things for you.
a month ago
Thanks. Yes that worked. I am surprised though because I deployed another rails app about 1-2 months ago and didn't need a custom build command. I redeployed this other rails service to inspect the build output (I used NO_CACHE=1 variable to force a full rebuild), but strangely I can't see any build logs, all I see is:
You reached the start of the range
Feb 7, 2026 at 8:35 AM
scheduling build on Metal builder "builder-hdvmmv"
scheduling build on Metal builder "builder-hdvmmv"
You reached the end of the range
Feb 7, 2026 at 8:50 AMStatus changed to Awaiting Railway Response Railway • 27 days ago