{"record":{"id":"657dbad60b010c15","repo":"uutils/coreutils","slug":"too-many-levels-of-symbolic-links","errorCode":null,"errorMessage":"Too many levels of symbolic links","messagePattern":"Too many levels of symbolic links","errorType":"error_code","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"src/uu/du/src/du.rs","lineNumber":664,"sourceCode":"        'file_loop: for f in read {\n            match f {\n                Ok(entry) => {\n                    let entry_path = entry.path();\n\n                    // Check if this is a symlink when using -L\n                    let mut current_symlink_depth = symlink_depth;\n                    let is_symlink = match entry.file_type() {\n                        Ok(ft) => ft.is_symlink(),\n                        Err(_) => false,\n                    };\n\n                    if is_symlink && options.dereference == Deref::All {\n                        // Increment symlink depth\n                        current_symlink_depth += 1;\n\n                        // Check symlink depth limit\n                        if current_symlink_depth > MAX_SYMLINK_DEPTH {\n                            print_tx.send(Err(io::Error::new(\n                                io::ErrorKind::InvalidData,\n                                \"Too many levels of symbolic links\",\n                            ).map_err_context(\n                                || translate!(\"du-error-cannot-access\", \"path\" => entry_path.quote()),\n                            )))?;\n                            continue 'file_loop;\n                        }\n                    }\n\n                    match Stat::new(&entry_path, Some(&entry), options) {\n                        Ok(this_stat) => {\n                            // Check if symlink with -L points to an ancestor (cycle detection)\n                            if is_symlink\n                                && options.dereference == Deref::All\n                                && this_stat.metadata.is_dir()\n                                && let Some(inode) = this_stat.inode\n                                && ancestors.contains(&inode)\n                            {","sourceCodeStart":646,"sourceCodeEnd":682,"githubUrl":"https://github.com/uutils/coreutils/blob/85295bbf788bfd7a6926ba692031563504b304b7/src/uu/du/src/du.rs#L646-L682","documentation":"When du is asked to fully dereference symlinks (--dereference / -L) it follows them, and to avoid infinite loops it enforces MAX_SYMLINK_DEPTH. Exceeding the limit yields this InvalidData error wrapped with a 'cannot access' context for the offending path. It corresponds to the classic ELOOP condition, implemented manually for symlink chains.","triggerScenarios":"du -L encounters a chain of more than MAX_SYMLINK_DEPTH nested symlinks, typically a symlink loop (a -> b -> a) or a very deep symlink hierarchy.","commonSituations":"Cyclic symlinks created by misconfigured deployments (current -> current), symlink loops in build outputs, bind-mounted or synced directories (Dropbox/rsync) containing cycles.","solutions":["Find and remove the symlink loop: `namei -l <path>` or `find -L <dir> -type l` to locate the cycle","Run du without -L (default -P behavior) so symlinks are not followed","Increase your tolerance by resolving deep chains into direct paths before du","Exclude loop-containing directories from the du invocation"],"exampleFix":"// before\ndu -L -sh suspicious-dir/\n// after\nfind -L suspicious-dir/ -type l  # locate the loop, fix it\ndu -sh suspicious-dir/","handlingStrategy":"validation","validationCode":"// detect symlink cycles before du -L\nfind -L /path -type l 2>/dev/null   # lists paths where traversal looped\nnamei -l /path/to/entry              # shows each symlink hop","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Avoid -L/--dereference when directory trees may contain symlinks","Set up CI checks that flag cyclic symlinks in repos/artifacts","Create symlinks carefully (current -> current is a classic mistake)"],"tags":["du","symlink","loop","eloop"],"backgroundTag":"symlink-loop","analyzedSha":"85295bbf788bfd7a6926ba692031563504b304b7","analyzedAt":"2026-08-31T11:11:36.175Z","contentChangedAt":"2026-08-31T11:11:36.175Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}