jdx/mise · error
too many symlinks while resolving atomic write target
Error message
too many symlinks while resolving atomic write target: {} What it means
Before an atomic write, mise resolves the final target path by following symlinks (bounded loop). If the chain of symlinks does not terminate within the loop limit — a symlink cycle or extremely deep chain — it aborts with this error rather than looping forever or writing through an unexpected path.
Solutions
- Find and remove the symlink cycle on the path (e.g. with `find -L . -type l` or `namei` on the displayed path)
- Recreate the affected symlinks pointing to real directories
- Reinstall the affected tool (`mise install -f <tool>`) to rebuild its directory layout
Example fix
// before ln -s b a && ln -s a b # cycle; mise write fails // after rm a b && mkdir -p realdir && ln -s realdir a
Defensive patterns
Strategy: validation
Validate before calling
function hasSymlinkLoop(path) {
const seen = new Set();
let cur = require('fs').realpathSync.native(path, undefined, () => null); // or walk manually
let p = path;
for (let i = 0; i < 40 && require('fs').lstatSync(p).isSymbolicLink(); i++) {
if (seen.has(p)) return true;
seen.add(p);
p = require('path').resolve(require('path').dirname(p), require('fs').readlinkSync(p));
}
return false;
}
// check with: find -L ~/.local/share/mise -type l 2>/dev/null Prevention
- Audit symlink trees under mise directories with `find -L ... -type l`
- Avoid symlink managers (stow, dfm) inside mise data dirs
- Reinstall tools after filesystem crashes or interrupted syncs
When it happens
Trigger: Calling `atomic_write_target` (via `prepare_atomic_write`) on a path whose parent chain contains a symlink loop, e.g. `ln -s a b; ln -s b a`, or more symlink hops than the internal limit.
Common situations: Corrupted tool-install symlink trees; dotfile managers (GNU stow etc.) creating cyclic links; a symlink loop inside a mise data/config directory after a crashed sync.
Understand the failure class
Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.
Related errors
- a parent directory is now a symlink; left untouched
- binary target is not an owned Caskroom symlink
- . Creating directory symlinks on Windows may require…
- failed to create file symlink
- global configuration directory must not be a symlink
AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17).
Data as JSON: /api/errors/e4ecbd2b4400f19c.
Report an issue: GitHub.
Appendix: source
Thrown at src/file.rs:581
let mut target = path.to_path_buf();
for followed in 0..=MAX_SYMLINKS {
if !target.is_symlink() {
return Ok(desymlink_path(&target));
}
if followed == MAX_SYMLINKS {
break;
}
let link = fs::read_link(&target)
.wrap_err_with(|| format!("failed to read symlink: {}", display_path(&target)))?;
target = if link.is_absolute() {
link
} else {
target.parent().unwrap_or_else(|| Path::new("")).join(link)
};
}
bail!(
"too many symlinks while resolving atomic write target: {}",
display_path(path)
)
}
pub(crate) fn persist_atomic(mut temporary: tempfile::NamedTempFile, path: &Path) -> Result<()> {
const RETRIES: u32 = 20;
for attempt in 0..=RETRIES {
match temporary.persist(path) {
Ok(_) => return Ok(()),
Err(err) if should_retry_atomic_persist(&err.error) && attempt < RETRIES => {
temporary = err.file;
std::thread::sleep(Duration::from_millis(5 * u64::from(attempt + 1)));
}
Err(err) => return Err(err.error.into()),
}
}View on GitHub (pinned to 533346cc37)