{"record":{"id":"ae2245f85564e3a1","repo":"jdx/mise","slug":"trimsuffix-requires-exactly-2-arguments","errorCode":null,"errorMessage":"trimSuffix requires exactly 2 arguments","messagePattern":"trimSuffix requires exactly 2 arguments","errorType":"validation","errorClass":"eyre::Report","httpStatus":null,"severity":"error","filePath":"crates/aqua-registry/src/template.rs","lineNumber":378,"sourceCode":"        Ok(Box::new(StringValue(\n            args[0].as_string().trim_start_matches('v').to_string(),\n        )) as Box<dyn Value>)\n    });\n\n    registry.insert(\"trimPrefix\", |args| {\n        if args.len() != 2 {\n            bail!(\"trimPrefix requires exactly 2 arguments\");\n        }\n        let prefix = args[0].as_string();\n        let text = args[1].as_string();\n        Ok(Box::new(StringValue(\n            text.strip_prefix(&prefix).unwrap_or(&text).to_string(),\n        )) as Box<dyn Value>)\n    });\n\n    registry.insert(\"trimSuffix\", |args| {\n        if args.len() != 2 {\n            bail!(\"trimSuffix requires exactly 2 arguments\");\n        }\n        let suffix = args[0].as_string();\n        let text = args[1].as_string();\n        Ok(Box::new(StringValue(\n            text.strip_suffix(&suffix).unwrap_or(&text).to_string(),\n        )) as Box<dyn Value>)\n    });\n\n    registry.insert(\"replace\", |args| {\n        if args.len() != 3 {\n            bail!(\"replace requires exactly 3 arguments\");\n        }\n        let from = args[0].as_string();\n        let to = args[1].as_string();\n        let text = args[2].as_string();\n        Ok(Box::new(StringValue(text.replace(&from, &to))) as Box<dyn Value>)\n    });\n","sourceCodeStart":360,"sourceCodeEnd":396,"githubUrl":"https://github.com/jdx/mise/blob/6f52dcdf99e282ef7a7db68c81301fa4618d0f79/crates/aqua-registry/src/template.rs#L360-L396","documentation":"`path:` tool specifiers name a local tool directory. On Windows, backslashes are normally rewritten to `/` before validation, so the only backslash that survives `validate_path_string` (src/toolset/tool_request.rs) is a `\\\\?\\` extended-length or `\\\\.\\` device prefix — mise reports that specifically: `invalid tool path {s}: extended-length and device paths (\\\\?\\, \\\\.\\) are not supported`. These prefixes would corrupt `ctx.rootPath`/`installPath` and shell interpolation in plugin hooks.","triggerScenarios":"`mise use node@path:\\\\\\\\?\\\\C:\\\\dev\\\\node` or `path:\\\\.\\\\C:\\\\dev\\\\node` on Windows — paths copied from PowerShell (`Convert-Path` on long paths), Explorer properties, or tools that emit verbatim paths for paths over 260 characters.","commonSituations":"Long repository paths exceeding MAX_PATH causing tools to return `\\\\?\\`-prefixed paths that get pasted into mise.toml; automation scripts passing `\\?\\` device paths; users assuming verbatim paths are the 'safe' form for Windows.","solutions":["Drop the prefix and use a normal path with forward slashes: `path:C:/dev/node`.","Use a relative path from the config file: `path:../tools/node`.","Shorten or move the project so tooling stops emitting extended-length paths.","If a tool itself only prints `\\\\?\\` paths, strip the prefix in the script that writes mise.toml."],"exampleFix":"# before\n$ mise use node@path:'\\\\\\\\?\\\\C:\\\\dev\\\\node22'\n\n# after\n$ mise use node@path:C:/dev/node22","handlingStrategy":"validation","validationCode":"# reject verbatim/device prefixes in path: specs before mise sees them\npython3 -c '\nimport sys\np = sys.argv[1].split(\":\", 1)[1] if \":\" in sys.argv[1] else \"\"\nsys.exit(\"verbatim path\" if p.startswith(\"\\\\\\\\\\\\\\\\?\\\\\\\\\") or p.startswith(\"\\\\\\\\\\\\\\\\.\\\\\\\\\") else 0)\n' -- 'path:\\\\\\\\?\\\\C:\\\\dev\\\\node' || echo REJECT","typeGuard":"function isSupportedToolPath(p: string): boolean {\n  return !(p.startsWith(\"\\\\\\\\?\\\\\") || p.startsWith(\"\\\\\\\\.\\\\\"));\n}","tryCatchPattern":null,"preventionTips":["Normalize paths to forward slashes before writing them into mise config on Windows.","Prefer relative path: values (path:../tools/x) for portability.","When scripting config generation on Windows, strip \\\\?\\ prefixes from resolved paths."],"tags":["tools","path","windows","extended-length-path","validation","mise"],"backgroundTag":"invalid-path-specifier","analyzedSha":"6f52dcdf99e282ef7a7db68c81301fa4618d0f79","analyzedAt":"2026-08-22T10:14:23.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}