{"record":{"id":"caf61bcc2011e352","repo":"slint-ui/slint","slug":"exists-but-is-not-a-symlink","errorCode":null,"errorMessage":"{:?} exists but is not a symlink","messagePattern":"(.+?) exists but is not a symlink","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xtask/src/license_headers_check.rs","lineNumber":1111,"sourceCode":"                    .context(\"Failed to create LICENSES directory\")?;\n            } else {\n                return Err(anyhow!(\n                    \"Missing LICENSES directory for published crate {:?}\",\n                    crate_dir\n                ));\n            }\n        }\n\n        // Compute relative path after directory exists so canonicalize works\n        let rel_prefix = diff_paths(&root_licenses, &licenses_dir);\n\n        for filename in &expected_filenames {\n            let symlink_path = licenses_dir.join(filename);\n            let expected_target = rel_prefix.join(filename);\n\n            if let Ok(meta) = std::fs::symlink_metadata(&symlink_path) {\n                if !meta.file_type().is_symlink() {\n                    return Err(anyhow!(\"{:?} exists but is not a symlink\", symlink_path));\n                }\n                let target = std::fs::read_link(&symlink_path)\n                    .context(\"Cannot read LICENSE symlink target\")?;\n                if target == expected_target {\n                    continue;\n                }\n                if self.fix_it {\n                    eprintln!(\n                        \"Fixing up {:?} as instructed. Symlink points to wrong target.\",\n                        symlink_path\n                    );\n                    std::fs::remove_file(&symlink_path)\n                        .context(\"Failed to remove incorrect symlink\")?;\n                } else {\n                    return Err(anyhow!(\n                        \"{:?} points to {:?}, expected {:?}\",\n                        symlink_path,\n                        target,","sourceCodeStart":1093,"sourceCodeEnd":1129,"githubUrl":"https://github.com/slint-ui/slint/blob/3a7e700487dc74d404cad0726378053ab763d4e0/xtask/src/license_headers_check.rs#L1093-L1129","documentation":"check_licenses_dir expects each required file inside the crate's LICENSES/ directory to be a symlink pointing at the root LICENSES/ file. If a regular file (or other non-symlink) exists at that path, this error is thrown because duplicates would drift from the canonical license text.","triggerScenarios":"Someone replaced the symlink with a regular copy of the license file (e.g. by copying the crate directory without preserving symlinks, on Windows, or via a tool that dereferences symlinks).","commonSituations":"Cloning/archiving crates through tools or filesystems that don't support symlinks; `cp -rL`; tar extraction without symlink preservation; Windows checkouts without developer-mode symlinks.","solutions":["Delete the regular file and recreate it as a relative symlink to the root LICENSES file (e.g. `ln -s ../../LICENSES/MIT.txt LICENSES/MIT.txt`)","Re-checkout the repository with symlink support enabled (git config core.symlinks true; enable Windows developer mode)","Check the symlink target matches the expected relative path, as the check also validates read_link()"],"exampleFix":"# before\nLICENSES/MIT.txt   (regular file copy)\n# after\nrm LICENSES/MIT.txt\nln -s ../../LICENSES/MIT.txt LICENSES/MIT.txt","handlingStrategy":"validation","validationCode":"for f in [\"MIT.txt\", \"Apache-2.0.txt\"] {\n    let p = std::path::Path::new(\"my-crate/LICENSES\").join(f);\n    let meta = std::fs::symlink_metadata(&p)?;\n    assert!(meta.file_type().is_symlink(), \"{p:?} must be a symlink\");\n}","typeGuard":"fn is_symlink_pointing_to(p: &std::path::Path, target: &std::path::Path) -> bool {\n    std::fs::symlink_metadata(p).map_or(false, |m| m.file_type().is_symlink())\n        && std::fs::read_link(p).map_or(false, |l| l == target)\n}","tryCatchPattern":null,"preventionTips":["Never copy license files into crate LICENSES/ dirs — always symlink","Use symlink-preserving tools (cp -a, git clone) and enable developer mode on Windows","Verify after archive extraction (zip/tar) that symlinks survived","Add a script that validates LICENSES symlinks before packaging"],"tags":["symlink","license","filesystem","ci"],"backgroundTag":"file-already-exists","analyzedSha":"3a7e700487dc74d404cad0726378053ab763d4e0","analyzedAt":"2026-09-16T01:37:20.251Z","contentChangedAt":"2026-09-16T01:37:20.251Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}