{"record":{"id":"befd664e7e1095aa","repo":"jdx/mise","slug":"bootstrap-command-returned-an-unsafe-mise-path-c","errorCode":null,"errorMessage":"bootstrap_command returned an unsafe mise path: {command:?}","messagePattern":"bootstrap_command returned an unsafe mise path: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/remote.rs","lineNumber":2196,"sourceCode":"    if value.is_empty() || value.contains('\\0') {\n        bail!(\"remote {kind} cannot be empty or contain NUL\");\n    }\n    Ok(())\n}\n\nfn validate_staging_path(path: &str) -> Result<()> {\n    if !path.starts_with(\"/tmp/mise-bootstrap.\")\n        || path[\"/tmp/mise-bootstrap.\".len()..].is_empty()\n        || path.chars().any(char::is_whitespace)\n    {\n        bail!(\"remote mktemp returned an unsafe staging path: {path:?}\");\n    }\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)?;","sourceCodeStart":2178,"sourceCodeEnd":2214,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/remote.rs#L2178-L2214","documentation":"mise runs a bootstrap command on a remote host to locate where mise was installed. Before using the returned string, `validated_remote_command` requires it to be an absolute path containing no NUL, newline, or carriage-return bytes; otherwise this error is thrown to prevent injecting arbitrary shell content or relative/truncated paths into remote shell commands.","triggerScenarios":"The remote `bootstrap_command` (e.g. `which mise`, `command -v mise`, or a custom script) prints a relative path, a multiline/annotated string (shell init output, MOTD text, aliases), or a path containing NUL/CR/LF.","commonSituations":"Custom bootstrap_command in remote.toml that echoes extra lines; remote shell rc-files printing banners before `which`; mise installed via an alias rather than a real path; NUL-corrupted output from a broken remote helper.","solutions":["Fix the remote bootstrap_command so it prints exactly one absolute path and nothing else (e.g. suppress rc-file output, use `command -v mise` with stderr redirected)","Ensure mise is installed on the remote at a real absolute path (not an alias or shell function)","Check for a broken remote helper/ssh wrapper emitting CR/LF or NUL bytes and fix its output encoding"],"exampleFix":"// before\nbootstrap_command = \"mise which mise\"  // prints relative or extra lines\n// after\nbootstrap_command = \"command -v mise 2>/dev/null\"  // single absolute path, stderr silenced","handlingStrategy":"validation","validationCode":"function isSafeRemotePath(s) {\n  return typeof s === 'string' && s.startsWith('/') && !/[\\0\\n\\r]/.test(s);\n}\nif (!isSafeRemotePath(output)) throw new Error('bootstrap output is not a safe absolute path');","typeGuard":"const isSafeRemotePath = (s: unknown): s is string =>\n  typeof s === 'string' && s.startsWith('/') && !/[\\0\\n\\r]/.test(s);","tryCatchPattern":"try {\n  let path = validated_remote_command(output);\n} catch (e) {\n  if (String(e).includes('unsafe mise path')) {\n    // inspect raw remote output, fix bootstrap_command, then retry\n  } else throw e;\n}","preventionTips":["Make bootstrap_command print exactly one absolute path to stdout and nothing else","Send all diagnostics to stderr, never stdout","Test the bootstrap command over plain ssh before wiring it into config","Avoid relying on shell aliases/functions; use `command -v mise`"],"tags":["remote","shell","validation","path"],"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"}