-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
feat(config): Add option for env_path #8346
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not entirely opposed to this because I can see how this is useful.
but this has the same effect as doing a source
call, which I guess is cumbersome if you need to change env vars often?
would it be possible to symlink the env file in the foundry root dir?
@@ -185,11 +185,17 @@ macro_rules! p_println { | |||
/// | |||
/// Similarly, we could just use `eprintln!`, but colors are off limits otherwise dotenv is implied | |||
/// to not be able to configure the colors. It would also mess up the JSON output. | |||
pub fn load_dotenv() { | |||
pub fn load_dotenv(path: &Option<PathBuf>) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to keep this function as is
let config = utils::load_config(); | ||
utils::load_dotenv(&config.env_path); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this complicates things a lot, because is an additional config lookup, which isn't super cheap.
I also don't want to automatically load env vars when loading the config.
so not quite sure yet where to apply this
Makes sense, I agree that this is kind of hard to implement with this structure. I will try and see how it goes. |
@mattsse where do you think would be a good place in code for checking if |
Implements #5723
Motivation
Now, the .env file is only loaded from the project root. A config option can be added to load the .env file from another directory. This will be helpful if Foundry is used within a monorepo that uses a single .env file.
Solution
I have added an option for the config to allow adding the env_file location. Since it will not change often, I thought making it a config item instead of a CLI flag would make more sense.