-
Notifications
You must be signed in to change notification settings - Fork 21
with_env
clearing the environment is jarring
#58
Comments
I agree that the choice might not be obvious. I can't find where in #46 we made the decision. Some random thoughts on my part
|
What about |
When we put After looking into how to implement a fix, I did have an idea for a name. fn extend_env<I: IntoIterator<Item = (T, Z)>>(mut self, iter: I) -> self {
self.env.extend(iter);
self
} See also https://github.com/Freyskeyd/environment/blob/master/src/lib.rs#L394 |
A question to ask is how many of these helpers should we implement. Unlike In this case, I think the problem is confusion over the API. Documentation is one way to help this. I think why we don't have the docs is that we are combining multiple pieces here and the code assumes you are familiar with all of them when you might not be. Proposal We update Sometimes offering an alternative route helps call out the behavior of the original one. So there might be value in creating a second function for this specific purpose and not as a convenience. |
I think - to be fair - that once the Cargo issue is resolved (which I believe was giving me the "[cargo binary] file not found" errors as discussed in #51), I wouldn't have noticed this as an issue as I typically don't rely on inherited env vars. However the point stands that the |
@epage I like I feel comfortable on keeping |
So I feel like we have a good idea on how we plan to handle this
Moving this from |
@epage are you working on fixing this bug? |
Not yet but if someone needs me to prioritize this I can. |
Quoting @sevagh:
Just to confirm that I expected the with_env(&vec[("MY_ENV_VAR", "MY_VAL")] to Just Work(TM) and it didn't - I had to use Environment::inherit().insert("MY_ENV_VAR", "MY_VAL").
Previously, I used to use https://doc.rust-lang.org/1.1.0/std/process/struct.Command.html#method.env - where:
let mut cmd = std::process::Command();
cmd.env("MY_ENV_VAR", "MY_VAL");
The usage there is just to append to the inherited environment variables, not to totally clear them.
I find the fact that with_env erases all the inherited env vars to be jarring. Any opinions?
The text was updated successfully, but these errors were encountered: