Enviroment variable

Hello everyone,

I am having a problem. I need to create an environment variable and use (or consume) it, but I'm not sure how to do it. Could someone explain how to use it?

What things have you tried?

I create server web use framework actix-web, I need consume enviroment variables for deploy.

We need more information about exactly what you're trying to do. Are you trying to set an envvar from within a Rust program you're writing, or are you trying to set one of the envvars that Cargo reads so that it can be recognized by Cargo? Is the envvar supposed to be set just for the purposes of spawning a subprocess from within Rust, or does it need to be read by the same process that set it? Are you even aware of std::env::set_var()?

have a look at dotenvy and study their examples.

while. dotenvy is not the only crate that offers this, its documentation and examples should help you move forward.

@rsn @jwodder I created application server use framework actix-web, i need cosume enviroment variables to can deploy.

Yes, you stated this in your initial post.

People are asking you for more information because they don't understand you yet. Nobody can look into your brain, nobody knows what you are working on. So your job is to explain this as clearly and in as much detail as possible, so anybody can grasp your problem.

There might be a language barrier for non-native speakers, and that's understandable, but today there are plenty of translators available. So it's worth the extra step: first express your questions and thoughts in your native mother tongue, then use a translator app to translate your posting and post the English translation here.

It's on you to phrase your questions in an easily accessible way, so people can actually help you. People here are willing to put in effort for you, but they shouldn't have to work hard just to decipher what you're asking.

Sorry, I’m building a backend for my personal blog using the Actix-Web framework. There’s a section where I need to send and receive emails, so I need to be able to retrieve those environment variables so as not to leave them public. In JavaScript, I can use a .env file to store them there and avoid having to upload them to GitHub. I’m not sure if this applies to Rust or how it would be done. Many thanks.

Translated with DeepL (https://dee.pl/apps)

Loading a .env file is exactly what the dotenvy library does, which was linked above:

Thank you very much