-
-
Notifications
You must be signed in to change notification settings - Fork 424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The .env injection for the run
command need a fix
#1285
Comments
Which is the correct behavior depends on how you think about it. |
The standard generally is, load the [tool.pdm.scripts.env] # or [tool.pdm.env]
env_file = ".env"
prefer = "dotenv" # or "system" The configuration section should be Also, The new aproach question to the user what prefer, and keep the behavior of What do you think? 🤔, the last way to set the |
Also if a developer use |
dotenv does provide an override open (defaulting to False) to allow this to be customized. The same could be used here as a solution to both assumptions. I still believe an env file should not override an environment variable by default, see also "By default, load_dotenv doesn't override existing environment variables." |
Which should be the approach related to set override in the config file? I think also this depends if the command is being executed in Maybe a good option should be considering this is implemented # The way 1, choice the environment using the same style than `test = {cmd = "pytest", env_file=".env"}`
[tool.pdm.scripts]
test1 = {cmd = "pytest", environment="prod"}
test2 = {cmd = "pytest", environment="dev"}
[tool.pdm.environments]
prod = {override=true, env_file=".env"}
dev = {override=false, env_file=".env"} # The way 2, read first the environments and infer the configuration
[tool.pdm.scripts.prod]
test1 = "pytest"
[tool.pdm.scripts.dev]
test2 = "pytest"
[tool.pdm.environments]
prod = {override="true", env_file=".env"}
dev = {override="false", env_file=".env"} With this approach |
I think it is unnecessary for multiple environment files and that by definition the variables in the environment that the code runs in should take precedence - to me this is the point of environment variables. In other words the environment variables exist in the environment the code runs in and thereby configure the code. I would recommend,
as a compromise with the default staying as it is now. |
This is not clear what Taking advantage of the TOML syntax, I would recommend: [tool.pdm.scripts]
script_cmd = {cmd = "...", env_file.override="..."} |
Makes sense, I'll open a PR |
See #1299 |
Closed by #1299 |
Files to reproduce
Current behavior
Expected behavior
PR #1284
The text was updated successfully, but these errors were encountered: