Skip to content

fix: mkdir and rm report backend errors instead of crashing the exec#48

Merged
ivarvong merged 1 commit into
mainfrom
fix/mkdir-backend-errors
Jul 2, 2026
Merged

fix: mkdir and rm report backend errors instead of crashing the exec#48
ivarvong merged 1 commit into
mainfrom
fix/mkdir-backend-errors

Conversation

@ivarvong

@ivarvong ivarvong commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Running mkdir or rm on a mount whose backend rejects the mutation crashed the entire JustBash.exec/2 with a CaseClauseError instead of failing the command:

bash = JustBash.new() |> JustBash.mount("/work", Exgit.Workspace.open(repo))
JustBash.exec(bash, "mkdir -p /work/data")   # ** (CaseClauseError) — git trees cannot store empty directories

Both commands matched only the error kinds the in-memory backend can produce (:eexist/:enoent for mkdir, :enoent/:enotempty for rm). Any other backend error — :enotsup from a git-tree-backed workspace, :erofs from a read-only archive — now reports through FS.strerror/1 with exit code 1, matching how ln already degrades on backends without symlink support.

Adds a NoEmptyDirsBackend fixture in test/support: a writable backend that rejects directory creation (the shape of any git-tree-backed mount), with a read_only mode for :erofs paths. The other mutation commands (cp, mv, tee, touch, ln, chmod, chown) already have catch-all error clauses.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FpxHS5iGm9ktgpnL9QZu9x

Both commands matched only the error kinds the in-memory backend can
produce (:eexist/:enoent for mkdir, :enoent/:enotempty for rm); a mount
whose backend rejects the mutation with anything else — :enotsup from a
git-tree-backed workspace, :erofs from a read-only archive — crashed
the whole exec with a CaseClauseError. Any other backend error now
reports through FS.strerror/1 with exit code 1, matching how ln
already degrades on backends without symlink support.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FpxHS5iGm9ktgpnL9QZu9x
@ivarvong ivarvong changed the title fix: mkdir reports backend errors instead of crashing the exec fix: mkdir and rm report backend errors instead of crashing the exec Jul 2, 2026
@ivarvong
ivarvong force-pushed the fix/mkdir-backend-errors branch from 59a050c to f2080cd Compare July 2, 2026 20:57
@ivarvong
ivarvong merged commit dffd5dd into main Jul 2, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant