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

Macro alternative to fallback to regular env #76

Open
ShayBox opened this issue May 30, 2023 · 1 comment
Open

Macro alternative to fallback to regular env #76

ShayBox opened this issue May 30, 2023 · 1 comment

Comments

@ShayBox
Copy link

ShayBox commented May 30, 2023

I use dotenvy! for development to load from .env and env! in production to load from regular env (GitHub Workflows), now I have a feature flag to switch between the two but it's very inconvenient and repetitive.

#[cfg(feature = "production")]
const EXAMPLE_ENV: &str = dotenv!("EXAMPLE_ENV");
#[cfg(not(feature = "production"))]
const EXAMPLE_ENV: &str = env!("EXAMPLE_ENV");

Having a macro that falls back to the regular env would be nice.

@DaXcess
Copy link

DaXcess commented Jul 5, 2024

+1

I was initially under the impression that this was already how dotenvy operated, but unfortunately had to find out the hard way that environment variables in the build pipeline were not accepted by the dotenv! macro, as it throws a compiler error when no .env file is found, even when the environment variable is present.

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

2 participants