Skip to content
This repository was archived by the owner on Dec 15, 2025. It is now read-only.

Commit 6edf2c5

Browse files
authored
print an info about /etc/environment if it does not exist (#51)
1 parent 82e1345 commit 6edf2c5

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/manager/mod.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,12 +217,20 @@ impl Environ {
217217
Environ(env)
218218
}
219219

220-
fn parse<P>(p: P) -> Result<HashMap<String, String>>
220+
fn parse<P>(p: P) -> Result<HashMap<String, String>, std::io::Error>
221221
where
222222
P: AsRef<std::path::Path>,
223223
{
224224
let mut m = HashMap::new();
225-
let txt = std::fs::read_to_string(p)?;
225+
let txt = match std::fs::read_to_string(p) {
226+
Ok(txt) => txt,
227+
Err(err) if err.kind() == std::io::ErrorKind::NotFound => {
228+
info!("skipping /etc/environment file because it does not exist");
229+
"".into()
230+
}
231+
Err(err) => return Err(err),
232+
};
233+
226234
for line in txt.lines() {
227235
let line = line.trim();
228236
if line.starts_with('#') {

0 commit comments

Comments
 (0)