When running a build of an SST app in Seed, it app...
# seed
r
When running a build of an SST app in Seed, it appears to be loading a dotenv file named
.env.local
despite that not being the stage name. I can see in the logs lines such as:
Copy code
[dotenv][DEBUG] "CUSTOMER" is already defined in `process.env` and will not be overwritten
I have the env vars set in Seed so it’s correctly not overwriting, however, my understanding is that, when in Seed, the dotenv plugin shouldn’t load a
.env.local
file.
f
.env.local
is a special env file with local overrides that’s normally not git commited.
For a given stage, the env files SST looks for are:
.env.STAGE.local
.env.STAGE
.env.local
.env
Files on the left have more priority than files on the right.
It’s recommended to commit
.env.STAGE
and
.env
, and git ignore
.env.STAGE.local
and
.env.local
j
r
Right, we typically have it the other way around where stage based env files aren't committed but the local version is as it's a way for any developer to pick up a project and be able to run it locally. It's not a big deal though, we can share that file in other ways
Having said that, it feels counter intuitive to me for Seed which is never responsible for a 'local' build to process an env file that is only ever meant for local builds
j
Yeah AFAIK it's a convention that dotenv uses. Their interpretation is that the
.local
files get their values from the machine they are running in. Or in the case of a CI, the build machine is going to be setting those environment variables. I'm personally still used to not committing these files in Git. But either way works as long as no sensitive info is getting committed 😬
r
OK, well as long as we know. Maybe we have this backwards!