mirror of
https://github.com/instructkr/claw-code.git
synced 2026-11-18 00:00:00 +08:00
fix(runtime): skip non-UTF-8 environment variables instead of panicking (#3356)
std::env::vars() panics on any non-UTF-8 value. zsh exports a metafied $_ when the command path contains non-ASCII characters (e.g. 下載), so claw panicked on startup. Use vars_os() and skip entries that are not valid UTF-8.
This commit is contained in:
1 parent
917a9e28ee
commit
c55c7e4710
3 files changed
+45
-3
No files matched your search
@@ -109,7 +109,11 @@ impl SandboxConfig {
|
||||
pub fn detect_container_environment() -> ContainerEnvironment {
|
||||
let proc_1_cgroup = fs::read_to_string("/proc/1/cgroup").ok();
|
||||
detect_container_environment_from(SandboxDetectionInputs {
|
||||
env_pairs: env::vars().collect(),
|
||||
// `env::vars()` panics on non-UTF-8 values (e.g. zsh exports a
|
||||
// metafied `$_` for non-ASCII paths); skip those entries instead.
|
||||
env_pairs: env::vars_os()
|
||||
.filter_map(|(key, value)| Some((key.into_string().ok()?, value.into_string().ok()?)))
|
||||
.collect(),
|
||||
dockerenv_exists: Path::new("/.dockerenv").exists(),
|
||||
containerenv_exists: Path::new("/run/.containerenv").exists(),
|
||||
proc_1_cgroup: proc_1_cgroup.as_deref(),
|
||||
|
||||
Reference in new issue
Block a user