Skip to content

Commit

Permalink
include symlink error context in error message
Browse files Browse the repository at this point in the history
this change updates this error message

```bash
mise tracking config: Permission denied (os error 13)
```

to this:

```bash
mise tracking config: failed to ln -sf .../mise/.mise.local.toml ~/pule/.local/state/mise/tracked-configs/35d795b4e6c9a289: Permission denied (os error 13)
```

in my case there was a permission error on the destination link, which
triggered an error for each 5 config files it was trying to link on every command.
I was seeing this in my terminal, which on its own provides no context for debugging
and is very noisy:

```bash
$ mise --version
2024.4.8 macos-arm64 (2024-04-23)
mise tracking config: Permission denied (os error 13)
mise tracking config: Permission denied (os error 13)
mise tracking config: Permission denied (os error 13)
mise tracking config: Permission denied (os error 13)
mise tracking config: Permission denied (os error 13)
```

the permission error on its own is an easy fix, I just needed to run
mise with this debug info to figure out where the problem was
  • Loading branch information
KlotzAndrew committed May 7, 2024
1 parent 23d8531 commit ddd58fc
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ pub fn make_symlink(target: &Path, link: &Path) -> Result<()> {
if link.is_file() || link.is_symlink() {
fs::remove_file(link)?;
}
symlink(target, link)?;
symlink(target, link)
.wrap_err_with(|| format!("failed to ln -sf {} {}", target.display(), link.display()))?;
Ok(())
}

Expand Down

0 comments on commit ddd58fc

Please sign in to comment.