{"record":{"id":"dd96a072e10d0ea6","repo":"jdx/mise","slug":"symlink-target","errorCode":null,"errorMessage":"symlink target","messagePattern":"symlink target","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/shims.rs","lineNumber":891,"sourceCode":"        target\n            .file_name()\n            .and_then(|name| name.to_str())\n            .is_some_and(is_mise_dispatcher_name)\n    }))\n}\n\nfn is_mise_shim(path: &Path, mise_bin: &Path) -> Result<bool> {\n    if path\n        .file_name()\n        .and_then(|name| name.to_str())\n        .is_some_and(is_mise_dispatcher_name)\n    {\n        // A package manager may install mise itself as a symlink in the shared\n        // directory. It is the dispatcher, not one of its shims.\n        return Ok(false);\n    }\n    if path.is_symlink() {\n        let target = resolved_symlink_target(path)?.expect(\"symlink target\");\n        return Ok(file::paths_eq(\n            &file::canonicalize_or_self(&target),\n            &file::canonicalize_or_self(mise_bin),\n        ));\n    }\n\n    #[cfg(windows)]\n    {\n        if !path.is_file() {\n            return Ok(false);\n        }\n        let parent = path.parent().unwrap_or_else(|| Path::new(\".\"));\n        if is_dedicated_shims_dir(parent) {\n            // Preserve the existing upgrade behavior in mise's dedicated\n            // farms. Native copies from an older mise cannot be identified by\n            // their contents after mise-shim.exe changes. Use the same\n            // unredirected check as pruning so a junction to a shared bin\n            // directory never grants ownership of every regular file there.","sourceCodeStart":873,"sourceCodeEnd":909,"githubUrl":"https://github.com/jdx/mise/blob/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/shims.rs#L873-L909","documentation":"Panic in src/shims.rs is_mise_shim: a path is known to be a symlink (is_symlink() returned true), so resolved_symlink_target is expected to always return Some. An None target means the symlink metadata vanished or could not be resolved between the check and the read — a race or filesystem inconsistency rather than normal usage.","triggerScenarios":"Another process deletes or replaces the shim symlink concurrently while publish_staged_shim_farm or get_actual_shims scans the shims directory; exotic filesystems returning inconsistent symlink metadata.","commonSituations":"Parallel mise invocations or package managers mutating the shared shims directory; network/overlay filesystems (NFS, Docker volumes) with racy symlink resolution.","solutions":["Re-run the mise command — transient races usually resolve once the directory is stable.","Ensure no concurrent process (another mise, sync tool, antivirus) is deleting shims while mise runs.","Recreate the shims directory contents: mise reshard / re-run `mise reshim` to rebuild consistent symlinks.","Report a bug if reproducible on a local filesystem — the expect assumes readlink succeeds right after is_symlink()."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"match resolved_symlink_target(path) {\n    Ok(Some(t)) => /* compare t to mise_bin */,\n    Ok(None) | Err(_) => /* treat as not-a-shim or retry the scan */,\n}","preventionTips":["Avoid running concurrent mise mutations (reshim/install) in the same shims directory.","Keep shims on a local filesystem, not NFS/overlay mounts.","Re-run `mise reshim` if shims ever appear inconsistent."],"tags":["filesystem","symlink","race","panic"],"backgroundTag":"internal-invariant-violation","analyzedSha":"afd2eddd3a50c16190efc1c7e94404b48f72af57","analyzedAt":"2026-09-09T01:38:25.179Z","contentChangedAt":"2026-09-09T01:38:25.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}