{"record":{"id":"65c40f72eeced93a","repo":"wasmerio/wasmer","slug":"invalid-map-command-flag-host-path-cannot-be-e","errorCode":null,"errorMessage":"Invalid --map-command flag - host path cannot be empty: '{item}'","messagePattern":"Invalid --map-command flag - host path cannot be empty: '(.+?)'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/cli/src/commands/run/wasi.rs","lineNumber":559,"sourceCode":"    pub fn build_mapped_commands(&self) -> Result<Vec<MappedCommand>, anyhow::Error> {\n        self.map_commands\n            .iter()\n            .map(|item| {\n                let (a, b) = item.split_once('=').with_context(|| {\n                    format!(\n                        \"Invalid --map-command flag: expected <ALIAS>=<HOST_PATH>, got '{item}'\"\n                    )\n                })?;\n\n                let a = a.trim();\n                let b = b.trim();\n\n                if a.is_empty() {\n                    bail!(\"Invalid --map-command flag - alias cannot be empty: '{item}'\");\n                }\n                // TODO(theduke): check if host command exists, and canonicalize PathBuf.\n                if b.is_empty() {\n                    bail!(\"Invalid --map-command flag - host path cannot be empty: '{item}'\");\n                }\n\n                Ok(MappedCommand {\n                    alias: a.to_string(),\n                    target: b.to_string(),\n                })\n            })\n            .collect::<Result<Vec<_>, anyhow::Error>>()\n    }\n\n    pub fn capabilities(&self) -> Capabilities {\n        let mut caps = Capabilities::default();\n\n        if self.http_client {\n            caps.http_client = wasmer_wasix::http::HttpClientCapabilityV1::new_allow_all();\n        }\n\n        if let Some(enable_async_threads) = self.enable_async_threads {","sourceCodeStart":541,"sourceCodeEnd":577,"githubUrl":"https://github.com/wasmerio/wasmer/blob/8c4b9ee9d33fb2068863fbb3d328683e7e6ff7f5/lib/cli/src/commands/run/wasi.rs#L541-L577","documentation":"The counterpart to the alias check in build_mapped_commands: after parsing ALIAS=HOST_PATH and trimming, if the host path side (after '=') is empty the mapping cannot resolve to any host command, so it is rejected. The raw item is included in the message for debugging.","triggerScenarios":"Passing a --map-command item like `ls=` or `ls= ` where the text after '=' trims to empty during prepare().","commonSituations":"Truncated flag value in a script (empty variable interpolation, e.g. --map-command ls=$CMD where CMD is unset); trailing '=' typo; list splitting producing a dangling '=' segment.","solutions":["Provide a non-empty host path after the '=', e.g. --map-command ls=/bin/ls","Check shell variables used to build the flag are set and non-empty (${CMD:?} guards)","Verify the host binary path exists (it is not canonicalized yet per the TODO)"],"exampleFix":"// before\nCMD=  # unset\nwasmer run app.wasm --map-command ls=$CMD\n// after\nwasmer run app.wasm --map-command ls=/bin/ls","handlingStrategy":"validation","validationCode":"fn validate_map_command_host(item: &str) -> Result<(), String> {\n    let (a, b) = item.split_once('=')\n        .ok_or_else(|| format!(\"--map-command must be ALIAS=HOST_PATH, got {item:?}\"))?;\n    if b.trim().is_empty() { Err(format!(\"empty host path in {item:?}\")) } else { Ok(()) }\n}","typeGuard":"fn has_nonempty_host_path(item: &str) -> bool {\n    item.split_once('=').map(|(_, b)| !b.trim().is_empty()).unwrap_or(false)\n}","tryCatchPattern":"match wasmer_run_with_map_commands(&items) {\n    Err(e) if e.to_string().contains(\"host path cannot be empty\") => {\n        eprintln!(\"fix or drop mapping: {items:?}\");\n        Err(e)\n    }\n    other => other,\n}","preventionTips":["Use ${VAR:?} shell guards so unset variables fail before building the flag","Check host binaries exist (e.g. command -v) since wasmer does not canonicalize them yet","Validate ALIAS=HOST_PATH shape before invoking the CLI"],"tags":["cli","wasi","argument-validation","map-command"],"backgroundTag":"invalid-flag-argument","analyzedSha":"8c4b9ee9d33fb2068863fbb3d328683e7e6ff7f5","analyzedAt":"2026-09-01T23:06:31.009Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}