{"record":{"id":"646f235d128df753","repo":"jdx/mise","slug":"refusing-to-resolve-managed-directory-to-the-fi","errorCode":null,"errorMessage":"refusing to resolve managed directory {} to the filesystem root","messagePattern":"refusing to resolve managed directory (.+?) to the filesystem root","errorType":"error_code","errorClass":"eyre::Report","httpStatus":null,"severity":"critical","filePath":"src/system/managed_files.rs","lineNumber":1694,"sourceCode":"                    SFlag::from_bits_truncate(metadata.st_mode).contains(SFlag::S_IFLNK)\n                }) {\n                    let parent = fstat(&directory)?;\n                    if parent.st_uid != 0 || parent.st_mode & 0o022 != 0 {\n                        bail!(\n                            \"refusing to follow symlink {} from an untrusted parent directory\",\n                            component_path.display()\n                        );\n                    }\n                    let target = nix::fcntl::readlinkat(&directory, name.as_os_str())?;\n                    let mut resolved = if Path::new(&target).is_absolute() {\n                        PathBuf::from(target)\n                    } else {\n                        current.join(target)\n                    };\n                    resolved.extend(components.iter().skip(index + 1));\n                    let resolved = resolved.absolutize()?.to_path_buf();\n                    if resolved == Path::new(\"/\") {\n                        bail!(\n                            \"refusing to resolve managed directory {} to the filesystem root\",\n                            path.display()\n                        );\n                    }\n                    return open_or_create_directory_tree_inner(&resolved, followed_symlinks + 1);\n                }\n                if open_error != nix::errno::Errno::ENOENT {\n                    return Err(open_error).wrap_err_with(|| {\n                        format!(\n                            \"failed to open path component {} without following symlinks\",\n                            component_path.display()\n                        )\n                    });\n                }\n                let created_by_us = match mkdirat(\n                    &directory,\n                    name.as_os_str(),\n                    Mode::from_bits_truncate(0o777),","sourceCodeStart":1676,"sourceCodeEnd":1712,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/managed_files.rs#L1676-L1712","documentation":"When following a symlink during managed-directory resolution, mise computes the fully resolved absolute path and refuses to continue if it lands on the filesystem root '/'. Following a chain of symlinks to '/' would make mise operate on the entire root filesystem, so it aborts instead of opening or creating directories there.","triggerScenarios":"A relative symlink target inside a managed path (or accumulation of resolved components via absolutize()) resolves to '/' exactly, causing open_or_create_directory_tree_inner to bail after the resolved == Path::new(\"/\") check.","commonSituations":"A symlink like lib -> / or a symlink chain that walks up past the managed root; misconfigured dotfile symlinks pointing at /; recovering from a botched rm that replaced a directory with a link to /.","solutions":["Inspect the symlink chain (readlink -f <path>) and fix the final target so it does not point at /","Replace the offending symlink with a real directory","Remove and recreate the managed path correctly"],"exampleFix":"// before\nln -s / ~/.local/share/mise/data  # resolves to root\n// after\nln -s /data/mise ~/.local/share/mise/data","handlingStrategy":"validation","validationCode":"import os\ndef resolves_to_root(p):\n    return os.path.realpath(p) == \"/\"","typeGuard":null,"tryCatchPattern":"if let Err(e) = open(path) {\n    if e.to_string().contains(\"filesystem root\") {\n        // inspect readlink -f path and fix the symlink chain before retrying\n    }\n}","preventionTips":["Never create symlinks pointing at / inside managed paths","Check symlink chains with readlink -f before wiring up data directories","Keep symlink targets inside the managed tree","Verify directory layout after partial restores or rsync operations"],"tags":["filesystem","symlink","path-resolution","safety"],"backgroundTag":"path-traversal-blocked","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"}