From 5cf100205e5bb87f55e65de1bba86baf9ba034bd Mon Sep 17 00:00:00 2001 From: Folkert Date: Mon, 23 May 2022 19:35:56 +0200 Subject: [PATCH] pass the environment along to the execve calls --- cli/src/lib.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/cli/src/lib.rs b/cli/src/lib.rs index 20faef1fb6..83dba34e3c 100644 --- a/cli/src/lib.rs +++ b/cli/src/lib.rs @@ -589,7 +589,20 @@ fn roc_run_unix, S: AsRef>( // envp is an array of pointers to strings, conventionally of the // form key=value, which are passed as the environment of the new // program. The envp array must be terminated by a NULL pointer. - let envp = &[std::ptr::null()]; + let envp_cstrings: bumpalo::collections::Vec = std::env::vars_os() + .flat_map(|(k, v)| { + [ + CString::new(k.as_bytes()).unwrap(), + CString::new(v.as_bytes()).unwrap(), + ] + }) + .collect_in(&arena); + + let envp: bumpalo::collections::Vec<*const libc::c_char> = envp_cstrings + .iter() + .map(|s| s.as_ptr()) + .chain([std::ptr::null()]) + .collect_in(&arena); match executable { ExecutableFile::MemFd(fd, _) => {