build keeps failing
mickymooch1
PROOP

2 months ago

"Railway Runtime V2 is not injecting user-defined environment variables into my container. ANTHROPIC_API_KEY is set in service variables but never appears in os.environ at runtime. Railway's own system variables like RAILWAY_ENVIRONMENT do appear. How do I fix this?"

$10 Bounty

7 Replies

Status changed to Awaiting Railway Response Railway about 2 months ago


Railway
BOT

2 months ago

This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.

Status changed to Open Railway about 2 months ago


Are you using a Dockerfile? If so, you'll need to add ENV and ARG into the Dockerfile such that it absorbs the variables during build.


domehane
FREE

2 months ago

Hello mickymooch1,

after adding your variables in the dashboard railway uses a staged changes system. if you didnt click apply changes after setting them, the container never actually receives them. check if there is a pending apply changes banner in your service, apply it, then redeploy


domehane
FREE

2 months ago

and if you are using a dockerfile, note that ARG is only needed for build time variables. runtime variables are injected automatically by railway without any ARG declaration needed


domehane

and if you are using a dockerfile, note that ARG is only needed for build time variables. runtime variables are injected automatically by railway without any ARG declaration needed

You need to add ARG <VARIABLE_NAME> for the Dockerfile to "eat" the variables during build time.


domehane
FREE

2 months ago

hy 0x5b62656e5d , please don’t copy my information and present it as your own. That’s not a professional approach

Attachments


domehane

hy [0x5b62656e5d](https://railway.com/u/0x5b62656e5d) , please don’t copy my information and present it as your own. That’s not a professional approach ![](https://station-server.railway.com/attachments/att_01kng5bbrsfevah2kg73sh2rd1)

You edited your message right before I sent it lol... You previously mentioned only adding ENV into the Dockerfile.


0x5b62656e5d

You edited your message right before I sent it lol... You previously mentioned only adding `ENV` into the Dockerfile.

domehane
FREE

2 months ago

that’s not professional at all, and it’s misleading


Welcome!

Sign in to your Railway account to join the conversation.

Loading...