Skip to content

Improve error messages by showing more context#1433

Merged
fingolfin merged 3 commits intoJuliaLang:mainfrom
fingolfin:codex/improve-error-path-context
Apr 16, 2026
Merged

Improve error messages by showing more context#1433
fingolfin merged 3 commits intoJuliaLang:mainfrom
fingolfin:codex/improve-error-path-context

Conversation

@fingolfin
Copy link
Copy Markdown
Member

E.g. when failing to modify a file, include the path to the file.

Resolves #1430.

Co-authored-by: Codex codex@openai.com

@fingolfin
Copy link
Copy Markdown
Member Author

Tests pass. I manually went over the PR to verify the AI did not produce arbitrary garbage, it all seems sensible. Though of course I can not guarantee it is all perfect (I couldn't if I had written it myself either...). Though if this causes regressions, I offer to take care of them (in the worst case by reverting select messages to their prior state).

I also verified that it improves the error message in cases I care about. So I hope this can be merged?

@fingolfin
Copy link
Copy Markdown
Member Author

(In other words: would be great if someone could approve this, then I can merge it... ;-) )

@IanButterworth
Copy link
Copy Markdown
Member

Looks good to me, but Claude found further fixes and a correction to lump into this

diff --git a/src/command_override.rs b/src/command_override.rs
index e150c09..02c76c5 100644
--- a/src/command_override.rs
+++ b/src/command_override.rs
@@ -160,7 +160,7 @@ pub fn run_command_override_unset(
 
     save_config_db(&mut config_file).with_context(|| {
         format!(
-            "Failed to save configuration file from `override add` command at `{}`.",
+            "Failed to save configuration file from `override unset` command at `{}`.",
             paths.juliaupconfig.display()
         )
     })?;
diff --git a/src/operations.rs b/src/operations.rs
index 9c8a7b5..3191cb6 100644
--- a/src/operations.rs
+++ b/src/operations.rs
@@ -1237,9 +1237,13 @@ pub fn garbage_collect_versions(
 }
 
 fn _remove_symlink(symlink_path: &Path) -> Result<Option<PathBuf>> {
-    std::fs::create_dir_all(symlink_path.parent().unwrap()).with_context(|| {
+    let parent = symlink_path
+        .parent()
+        .ok_or_else(|| anyhow!("Symlink path `{}` has no parent directory.", symlink_path.display()))?;
+    std::fs::create_dir_all(parent).with_context(|| {
         format!(
-            "Failed to create parent directory for symlink `{}`.",
+            "Failed to create parent directory `{}` for symlink `{}`.",
+            parent.display(),
             symlink_path.display()
         )
     })?;

@fingolfin fingolfin force-pushed the codex/improve-error-path-context branch from 9410ccc to f428f99 Compare April 16, 2026 12:37
@fingolfin
Copy link
Copy Markdown
Member Author

fingolfin commented Apr 16, 2026

I've asked Codex to look for similar issues, and it found a few more, all addressed now, I hope. Let's see if your AI likes what my AI did ;-)

@fingolfin fingolfin force-pushed the codex/improve-error-path-context branch from 071501f to 73fc417 Compare April 16, 2026 13:10
Copy link
Copy Markdown
Member

@IanButterworth IanButterworth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just needs conflicts resolved

@IanButterworth IanButterworth added the merge me merge when green label Apr 16, 2026
Comment thread README.md
- `juliaup override unset --path foo/bar` removes a directory override for the path `foo/bar`.
- `juliaup override unset --nonexistent` removes all directory overrides for paths that no longer exist.
- Tab completions for `juliaup` commands and `julia +channel` selection are automatically installed for Bash and Zsh (sourced from `~/.juliaup/completions/`). For other shells you can generate them manually, e.g. `juliaup completions fish > ~/.config/fish/completions/juliaup.fish`. Supported shells: `bash`, `zsh`, `fish`, `elvish`, `powershell`, and `nushell`.
- `juliaup completions bash > ~/.local/share/bash-completion/completions/juliaup` generates Bash completions for `juliaup` and saves them to a file. To use them, simply source this file in your `~/.bashrc`. Other supported shells are `zsh`, `fish`, `elvish` and `powershell`.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Messed up merge?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I let the AI do the merge. It messed up badly. I've now redone it manually

fingolfin and others added 3 commits April 16, 2026 16:43
E.g. when failing to modify a file, include the path to the file

Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Codex <codex@openai.com>
Replace production parent unwraps with contextual errors
in symlink, install, and version-db code paths.

Co-authored-by: Codex <codex@openai.com>
@fingolfin fingolfin force-pushed the codex/improve-error-path-context branch from efbebfb to c4db25a Compare April 16, 2026 14:43
@fingolfin fingolfin merged commit d329fa2 into JuliaLang:main Apr 16, 2026
29 checks passed
@fingolfin fingolfin deleted the codex/improve-error-path-context branch April 16, 2026 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge me merge when green

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error messages involving file access issues should print a full path to the file (absolute or relative, either is fine)

2 participants