{"record":{"id":"180d90e08738c53d","repo":"jdx/mise","slug":"kind-returned-an-unsafe-absolute-path-path","errorCode":null,"errorMessage":"{kind} returned an unsafe absolute path: {path:?}","messagePattern":"(.+?) returned an unsafe absolute path: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/remote.rs","lineNumber":2208,"sourceCode":"    }\n    Ok(())\n}\n\nfn validated_remote_command(command: &str) -> Result<String> {\n    if !command.starts_with('/') || command.contains(['\\0', '\\n', '\\r']) {\n        bail!(\"bootstrap_command returned an unsafe mise path: {command:?}\");\n    }\n    Ok(command.to_string())\n}\n\nfn validated_remote_command_output(output: &str) -> Result<String> {\n    validated_remote_command(output.strip_suffix('\\n').unwrap_or(output))\n}\n\nfn validated_absolute_remote_path_output(output: &str, kind: &str) -> Result<String> {\n    let path = output.strip_suffix('\\n').unwrap_or(output);\n    if !path.starts_with('/') || path.contains(['\\0', '\\n', '\\r']) {\n        bail!(\"{kind} returned an unsafe absolute path: {path:?}\");\n    }\n    Ok(path.to_string())\n}\n\nfn validate_install_mise_path(path: &str) -> Result<()> {\n    validate_value(\"mise install path\", path)?;\n    if path.contains(['\\n', '\\r']) {\n        bail!(\"install_mise must not contain a newline: {path:?}\");\n    }\n    if !path.starts_with('/') && !path.starts_with(\"~/\") {\n        bail!(\"install_mise must be an absolute path or start with ~/: {path:?}\");\n    }\n    if path.split('/').any(|component| component == \"..\") {\n        bail!(\"install_mise must not contain '..': {path:?}\");\n    }\n    if matches!(\n        path.rsplit('/').next(),\n        None | Some(\"\") | Some(\".\") | Some(\"~\")","sourceCodeStart":2190,"sourceCodeEnd":2226,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/remote.rs#L2190-L2226","documentation":"After running a remote helper command that must yield an absolute filesystem path (kind names which, e.g. install path or mise path), mise strips the trailing newline and validates it: it must start with '/', and contain no NUL, newline, or carriage-return bytes. Any other output means the remote command misbehaved, so mise rejects it with this error instead of using an unsafe path.","triggerScenarios":"A remote command whose stdout is expected to be a single absolute path returns a relative path, an empty/blank line, extra output lines, or text containing CR/LF/NUL (e.g. a script that logs progress to stdout).","commonSituations":"Remote install scripts printing progress to stdout alongside the final path; Windows/MSYS output with CRLF line endings after an incomplete newline strip; helper aliases resolving to relative paths.","solutions":["Make the remote command print only the absolute path to stdout (send diagnostics to stderr)","Verify the remote filesystem layout so the command resolves a real absolute path","Fix or remove ssh wrappers/rc-files that inject CR characters or extra lines into output"],"exampleFix":"// before\necho \"installing...\"; echo \"$PREFIX/bin/mise\"  // two lines -> rejected\n// after\necho \"installing...\" >&2; printf '%s\\n' \"$PREFIX/bin/mise\"","handlingStrategy":"validation","validationCode":"function isValidAbsoluteRemotePathOutput(s) {\n  const p = s.endsWith('\\n') ? s.slice(0, -1) : s;\n  return p.startsWith('/') && !/[\\0\\n\\r]/.test(p);\n}","typeGuard":"const isAbsolutePath = (s: unknown): s is string =>\n  typeof s === 'string' && s.startsWith('/') && !/[\\0\\n\\r]/.test(s);","tryCatchPattern":"match validated_absolute_remote_path_output(out, kind) {\n  Ok(path) => use(path),\n  Err(e) => { log_raw_output(out); return Err(e); }\n}","preventionTips":["Remote path-emitting commands must write only the final path to stdout","Strip ANSI codes and banners from remote scripts' stdout","Beware CRLF-producing remotes; normalize line endings upstream","Test helpers with `set -e` and clean environments"],"tags":["remote","shell","path","validation"],"backgroundTag":"invalid-argument-format","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}