Conversation
The NLog file target was hardcoded to %AppData%/StabilityMatrix/Logs, while the Settings "Logs" shortcut and the exception dialog's log zip read from Compat.AppDataHome/Logs. With --home-dir set, those diverged and the log folder never existed, throwing DirectoryNotFoundException. Also resolve a relative --home-dir to a full path so folder-browser calls and file:// URIs don't receive relative paths. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mohnjiles
left a comment
There was a problem hiding this comment.
Two path-handling edge cases on the current head. The NLog layout case was reproduced on Windows with the pinned NLog 5.3.2; the Unix backslash case is based on static path analysis.
| { | ||
| Layout = "${longdate}|${level:uppercase=true}|${logger}|${message:withexception=true}", | ||
| FileName = "${specialfolder:folder=ApplicationData}/StabilityMatrix/Logs/app.log", | ||
| FileName = $"{logDir}/app.log", |
There was a problem hiding this comment.
Could we escape the literal filesystem path before assigning it to both FileName and ArchiveFileName? These properties parse NLog layout syntax. I reproduced this with the pinned NLog 5.3.2 on Windows: a home directory literally named ${shortdate} wrote app.log and its startup archive under 2026-10-04/Logs, while the literal ${shortdate}/Logs directory was absent. Settings and CreateLogFolderZip() still use the literal path, so this recreates the missing-folder issue for those directory names. SimpleLayout.Escape preserved the literal path in the same probe.
| // File logging | ||
| // Use Compat.AppDataHome so logs follow --home-dir overrides | ||
| // (forward slashes to avoid NLog layout escape parsing of backslashes) | ||
| var logDir = Compat.AppDataHome.JoinDir("Logs").FullPath.Replace('\\', '/'); |
There was a problem hiding this comment.
Could we preserve backslashes on Unix, or limit this separator conversion to Windows? A backslash is a valid literal filename character on Linux/macOS, so a home path such as /tmp/home\name becomes /tmp/home/name here. Settings and log ZIP export retain the original path, leaving them pointed at a different directory from the file target. This is a static path finding, not a native Unix runtime repro. Escaping the literal path for NLog would also avoid the need to rewrite its characters.
When launched with
--home-dir, the NLog file target still wrote to%AppData%/StabilityMatrix/Logs(~/.config/StabilityMatrix/Logson Linux), but Settings → App Folders → Logs and the exception dialog's "open log zip" read fromCompat.AppDataHome/Logs. That folder never got created, so both threw:Changes:
App.axaml.cs: build the log file path fromCompat.AppDataHome, so logs follow--home-dir. Forward slashes avoid NLog interpreting Windows backslashes inside the layout string. Without an override the location is unchanged.Program.cs: resolve a relative--home-dirwithPath.GetFullPath. OtherwiseAppDataHomestays relative (e.g.StabilityMatrix/Logs), which then gets passed to the file browser and intofile://URIs.🤖 Generated with Claude Code