Set environment variable in config as code with
railway.toml

lmmx
HOBBY

3 months ago

I'm finding it harder than expected to work out how to set an environment variable in the config from the docs - I tried [env] and [build.env] as the railway.toml section titles

I am trying to set the NIXPACKS_POETRY_VERSION = "2.1.2" so that my poetry installation will not error out (its default version is sufficiently old that it doesn't recognise the pyproject.toml config as valid)

I figured this would be trivial but there are docs on env vars and docs on config as code, and neither seem to refer to the other

edit - I read the docs and am getting the impression it's actually not possible despite the examples I saw on GitHub, and that I should probably use a nixpacks.toml file

Solved

2 Replies

lmmx
HOBBY

3 months ago

To answer my own question (well, not quite, I don't know about railway.toml) - in nixpacks.toml you can set them with [variables]`


2 months ago

Hello,

Yep this functionality is limited to nixpacks.toml files, we don't let you set variables in a railway.json file since setting variables in CaC is generally poor practice, but makes more sense to set them in config files for builders.

Best,
Brody


Status changed to Awaiting User Response railway[bot] 2 months ago


Status changed to Solved brody 2 months ago


Set environment variable in config as code with `railway.toml` - Railway Help Station