platformatic: `.env` files in services/* directory breaks runtime start
In a Platformatic Runtime, if thre is a .env file inside a service directory, seems like it is loaded in place of the root .env one.
This happens only if the service’s platformatic.json file contains a reference to an env variable like
{
"plugins": {
"typescript": "{PLT_MY_SERVICE_TYPESCRIPT}"
}
}
Repro:
$ node packages/create-platformatic/create-platformatic.mjs
Select Application and create the first (and only service)
Once finished ensure that the runtime starts correctly and stop it. Then
$ cd $RUNTIME_ROOT_DIR
$ touch services/YOUR_SERVICE_NAME/.env
Start again and you’ll see that an error occurs, complaining that an env variable is missing.
The .env file inside the service should be either ignored or loaded together with the root one
About this issue
- Original URL
- State: open
- Created 4 months ago
- Reactions: 1
- Comments: 26 (26 by maintainers)
@bobss24 take a look at https://github.com/leorossi/dotenv-tool it’s already imported in
runtimepackageUnfortunately we have no time to give you step-by-step instructions.
I agree with not loading those.
Or, since the worker thread runs only in runtimes, the
.envfile search should ignore the service’s directory, so only the runtime root’s one will be loaded. I like also the idea of combining the envs, but it might be confusing for the user? WDYT @mcollina ?You can run https://github.com/platformatic/platformatic/blob/main/packages/cli/cli.js with
--inspect --inspect-brkand then open chrome dev tools