Skip to content
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

Function to get the path for the env file, if one is used #2559

Open
Zambito1 opened this issue Jan 3, 2025 · 4 comments
Open

Function to get the path for the env file, if one is used #2559

Zambito1 opened this issue Jan 3, 2025 · 4 comments

Comments

@Zambito1
Copy link

Zambito1 commented Jan 3, 2025

I think it would be useful to have a function that would return the path of the current dotenv file, if one is currently being used. My use case is to pass the currently loaded dotenv file to docker run --env-file <dotenv path>. This seems nicer than specifying the dotenv path as an argument to the target, because it will load the expected dotenv file by default, and allow you to override it with just --dotenv-filename or just --dotenv-path, and the use of docker would be fully abstracted from the just user.

@laniakea64
Copy link
Contributor

laniakea64 commented Jan 3, 2025

related to #1724 ?

Edit: never mind - realized using the setting() function proposed in that issue as solution to this feature request would leave it up to the justfile to account for interactions between --dotenv-filename and --dotenv-path, which makes that solution look incomplete for this use case. Sorry for the noise.

@Zambito1
Copy link
Author

Zambito1 commented Jan 3, 2025

@laniakea64 maybe, that's kind of the opposite of what I'm looking for though. They want to specify the dotenv path as a variable, whereas I want to access the dotenv path (which may be specified by arguments to the just cli) to pass to other things.

@casey
Copy link
Owner

casey commented Jan 3, 2025

I think this is probably reasonable to add. I do worry about what happens if we add support for loading multiple dotenv files, in which case the function would only return the first one, but we can cross that bridge when we get to it.

@Zambito1
Copy link
Author

Zambito1 commented Jan 6, 2025

It is probably also worth considering a generic "get value of setting" function, which would solve my specific use-case, as well as any other use-case where the justfile author wants to change some behavior based on a just setting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants