Railway should .trim() the names of environment variables
alexpareto
PROOP

a year ago

Wow this one was tricky to catch! So here's the issue: basically Railway lets you add whitespace around the names of env vars, and it won't trim() that automatically. Now, this might be fine (though, I've never heard of an env var with whitespace) but with how Nixpacks handles formatting ENV vars, it breaks things.

In particular, this line: https://github.com/railwayapp/nixpacks/blob/87aeabb09d61b693389a2e8d0d4b560014ce259a/src/nixpacks/builder/docker/dockerfile_generation.rs#L143-L161

That said, the above code looks and runs fine with normal env vars.

The issue is that because there's no trim() around the whitespace, the env vars will also have a space between them. What this leads to is instead of this: ENV=$ENV you get this: ENV =$ENV. This then results in all env vars having an = appending to them.

This is confirmed in the build logs:
```
LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format (line 18)
```

I can't really think of a reason we wouldn't .trim() env vars, so that'd be my vote. But if we can't do that, then we need to update the above code in nixpacks to handle that somehow.

Solved

3 Replies

alexpareto
PROOP

a year ago

Here's a sample of the code. I was able to fix this on my end by adding a new env var without the whitespace

Attachments


david
EMPLOYEE

a year ago

Thank you for the report! I've added the report to triage, we'll take a look.

Appreciate it.


Status changed to Awaiting User Response Railway over 1 year ago


jr
EMPLOYEE

a year ago

We just fixed this https://github.com/railwayapp/nixpacks/pull/1166

Thanks for the detailed bug report :D


Status changed to Solved jr over 1 year ago


Loading...