Not picking up updated env.example file from GitHub repo
svanteromero
HOBBYOP

a month ago

I'm setting up a service, having made sure I have the latest version of the env.example file for railway to pick up in the respective root directory. But it keeps picking up from an earlier commit, why?

$10 Bounty

3 Replies

Railway
BOT

a month ago

This thread has been opened as a bounty so the community can help solve it.

Status changed to Open Railway • about 1 month ago


Is Railway not deploying the latest commit?

Also, you can try setting NO_CACHE=1 in your variables and redeploy.

You should be updating variables through the Variables tab of your service btw, not through an .env type file.


angerchris
PRO

a month ago

Railway treats these as two separate things:

  1. The connected GitHub branch determines which commit is deployed.
  2. Files such as .env.example are scanned only to suggest variables for import. They are not a live source of truth for variables already stored in the Railway service.

So updating .env.example in GitHub will not automatically overwrite existing Railway variables. Check the following:

  • The filename is exactly .env.example, including the leading dot.
  • The file is inside the service's configured root directory.
  • The service is connected to the expected repository and branch.
  • The latest deployment shows the expected commit SHA.
  • Existing values in the service's Variables tab are updated manually (or through the Raw Editor), and the resulting staged changes are deployed.

If the deployment itself is using an older commit, use Deploy Latest Commit and verify the branch/watch-path configuration. NO_CACHE=1 can help only when the correct commit is being built with stale build layers; it will not re-sync variables that were previously imported from the env file.

Railway documents the env files as a source of suggested variables, not continuous synchronization:

https://docs.railway.com/variables#suggested-variables


paudelsudip
FREE

a month ago

Railway has two things:

  1. The GitHub commit being deployed

First check the deployment's commit SHA and branch. If it's not the latest commit, use CMD + K → Deploy Latest Commit and verify the service is connected to the correct GitHub branch. Railway says this deploys the latest commit from the connected branch.

  1. .env.example is not a live sync source

Railway scans .env.example to suggest environment variables for import. Updating .env.example in GitHub does not automatically overwrite variables that already exist in the Railway service.

So, if the deployment is already using the correct commit, go to Service → Variables, import/update the variables there (the Raw Editor can be used for bulk values), then deploy the staged changes.

If the correct commit is being deployed but the build still contains old environment-variable values, check whether the build is being reused from cache. Railway notes that environment-variable changes are not considered when deciding whether a build can be skipped; Deploy Latest Commit always rebuilds.


Welcome!

Sign in to your Railway account to join the conversation.

Loading...