Nixpacks Build Fails with "Empty App Directory" on redeploy / Manual Redeploy, but Works on Commit-Triggered Deploy
colinbdesign
PROOP

7 months ago

Hello

I'm new to contemporary web dev but have been using Cursor to explore web dev in an effort to move away from using Squarespace.

My project has ghost updates trigger a build of my static astro site with content from ghost. I implemented this over on vercel as they have a feature to just easily do that and it worked perfectly.

Railway doesn't have that feature so I'm having to build by own workflow.

The workflow is almost working but Nixpacks is failing to build, reporting an empty app directory, but only when the deployment is triggered via railway redeploy (from a GitHub Action)

I initially experienced problems with Railway tokens that led me to understand that the prescribed way to do this is to use the CLI so that's what I've been trying.

PROJECT OVERVIEW

A Ghost blog in a different railway project sending webhooks.

A Node.js server that receives these webhooks. (https://railway.com/new/template/WJuLbj?referralCode=alphasec)

This server then triggers a GitHub Action (via workflow_dispatch). The Action's YAML file resides on our main branch (as required for workflow_dispatch), though its goal is to initiate a deployment based on my staging-verc-to-rail-static branch.

The GitHub Action is currently configured to use the Railway CLI (railway redeploy --service <your-service-name>) to tell our Railway service to pull the latest from its connected branch (staging-verc-to-rail-static) and redeploy.

Railway is then supposed to use Nixpacks to build and deploy the Astro site.

I've got Gemini AI in Cursor to provide a detailed description of the problem.

THE PROBLEM

I'm encountering a consistent issue with one of my services where Nixpacks fails to build, reporting an empty app directory, but only when the deployment is triggered via railway redeploy (from a GitHub Action) or the manual "Redeploy" button in the Railway UI. Deployments triggered by a direct git push to the connected branch work perfectly.

SERVICE DETAILS

Project Type: Astro static site (builds with npm run build to a dist/ directory, started with npx serve dist)

Railway Build Settings:

* Builder: Nixpacks (default)

* Root Directory: Not set (Astro project is at the root of the branch)

* Build Command: npm run build (as specified in package.json, Nixpacks usually picks this up)

* Start Command: npx serve dist (as specified in package.json or Nixpacks default for static sites often works)

THE PROBLEM

1. Successful Deployments (via git push):

When I make a commit and git push directly to the staging-verc-to-rail-static branch, Railway detects the new commit.

Nixpacks correctly identifies the project, installs dependencies, runs npm run build, and the site deploys successfully. The build logs show Nixpacks receiving the application files.

2. Failed Deployments (via railway redeploy or Manual UI Redeploy):

When I trigger a deployment using the Railway CLI from a GitHub Action (`railway redeploy --service service-name-here --detach`) or by clicking the "Redeploy" button for this service in the Railway dashboard:

The deployment process *starts* on Railway. However, it quickly fails during the "Build" phase.

The Nixpacks build log consistently shows the following error:

```

Nixpacks build failed

Nixpacks was unable to generate a build plan for this app.

Please check the documentation for supported languages: https://nixpacks.com

The contents of the app directory are: [empty]

```

The key issue is The contents of the app directory are: [empty]. Nixpacks is not receiving the application files from the staging-verc-to-rail-static branch in these scenarios.

What I've Verified:

The staging-verc-to-rail-static branch on GitHub definitely contains all the Astro project source files (`package.json`, astro.config.mjs, src/, etc.) at its root.

The GitHub Action uses a project-scoped RAILWAY_PROJECT_TOKEN_FOR_CLI, and the railway redeploy command *is* successfully initiating a deployment attempt on Railway (it's not an auth issue with the CLI itself).

The issue is specifically that for redeploy commands, Nixpacks isn't getting the source files it needs, despite the linked branch containing them.

QUESTION:

Could there be an issue with how Railway provisions or accesses the source code from the linked branch specifically for redeploy or manual redeploy commands for this service?

It seems like the source code isn't being correctly passed to the Nixpacks build environment in these instances, leading to the "empty app directory" error. This behavior is puzzling because commit-triggered deployments on the same branch and service work flawlessly.

Any insights or suggestions on how to resolve this would be greatly appreciated! I'd prefer to use the railway redeploy command for my CI automation if possible.

thanks

$10 Bounty

1 Replies

sim
FREE

6 months ago

What if you push a commit to the branch at least once to sync then the redeploy will work like you want till cache is cleared?


Loading...