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

fix: correct check for required attribute #132

Merged
merged 1 commit into from
Oct 5, 2024

Conversation

augustoccesar
Copy link
Contributor

Description

Currently, in the current code, the required attribute does not work as expected. On the code path where it should "continue if not required" actually just fallback into the error printing and process exiting.

Small reproducible example:

#[dotenvy::load(required = false)]
#[tokio::main]
async fn main() {
    let _ = env::var("SOME_VAR").unwrap();
}

Which errors out with:

Failed to load env file from path './.env': error reading './.env':, No such file or directory (os error 2)

### Description
Currently, in the current code, the `required` attribute does not work as expected.
On the code path where it should "continue if not required" actually just fallback into the error printing and process exiting.

Small reproducible example:
```rust
#[dotenvy::load(required = false)]
#[tokio::main]
async fn main() {
    let _ = env::var("SOME_VAR").unwrap();
}
```

Which errors out with:
```
Failed to load env file from path './.env': error reading './.env':, No such file or directory (os error 2)
```
Copy link

github-actions bot commented Oct 5, 2024

Code Coverage

@allan2 allan2 merged commit d697971 into allan2:master Oct 5, 2024
13 checks passed
@allan2
Copy link
Owner

allan2 commented Oct 5, 2024

Thanks!

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.

2 participants