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

feat(config): Add option for env_path #8346

Closed
wants to merge 1 commit into from

Conversation

altugbakan
Copy link

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.

Copy link
Member

@mattsse mattsse left a 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>) {
Copy link
Member

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

Comment on lines +22 to +23
let config = utils::load_config();
utils::load_dotenv(&config.env_path);
Copy link
Member

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

@altugbakan
Copy link
Author

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?

Makes sense, I agree that this is kind of hard to implement with this structure. I will try and see how it goes.

@altugbakan
Copy link
Author

@mattsse where do you think would be a good place in code for checking if env_root exists and create the symlink?

@altugbakan altugbakan closed this Jul 10, 2024
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

Successfully merging this pull request may close these issues.

None yet

2 participants