-
Unlike doteny, doteny_macro works both with cargo run and cargo build. |
Beta Was this translation helpful? Give feedback.
Answered by
allan2
Jan 31, 2024
Replies: 2 comments 1 reply
-
Can you provide more details? I'm not sure I understand. |
Beta Was this translation helpful? Give feedback.
0 replies
-
fn main() {
dotenvy::dotenv().ok();
let secret = dotenvy::var("SECRET").expect("SECRET must be set");
println!("{}", secret);
} ./target/debug/env
hello cd ..
./env/target/debug/env
thread 'main' panicked at src/main.rs:3:41:
SECRET must be set: EnvVar(NotPresent)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace If I replaced dotenvy with dotenvy_macro, I can run the program anywhere and package it for another system. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There is a discussion on this here on the Tauri repo.
dotenvy_macro loads at compile-time whilst dotenv loads at runtime. If you make a minimal reproducible example, perhaps in a new repo, I can take a closer look.