fix(src/paths.zig): fall back when XDG_RUNTIME_DIR is unusable#44
Merged
Conversation
The XDG runtime directory is created by the login session, never by applications, but socketDir makePath'd it together with its parents. With a Linux-style XDG_RUNTIME_DIR=/run/user/<uid> exported from dotfiles shared with Linux, mkdir /run on the sealed read-only macOS system volume fails and 'boo new' dies with error.ReadOnlyFileSystem. Honor XDG_RUNTIME_DIR only when the directory already exists and the boo subdirectory is creatable inside it; otherwise fall back to /tmp/boo-<uid>. BOO_DIR stays an explicit, fail-loud override.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the
error: ReadOnlyFileSystemreported on Hacker News forboo newon macOS Sequoia after a curl-to-bash install.Problem
socketDirtrusted$XDG_RUNTIME_DIRblindly andmakePath'd it, parents included. macOS never sets that variable, but dotfiles shared with Linux commonly exportXDG_RUNTIME_DIR=/run/user/$UID./rundoes not exist on macOS, somakePathwalks up and ends atmkdir /runon the sealed read-only system volume, which fails withEROFS. The error escapesmainand Zig prints exactlyerror: ReadOnlyFileSystem.Fix
The XDG runtime directory is owned by the login session; applications must not create it.
socketDirnow honors$XDG_RUNTIME_DIRonly when the directory already exists and theboo/subdirectory is creatable inside it, and otherwise falls back to/tmp/boo-<uid>.$BOO_DIRremains an explicit, fail-loud override.Verification
Reproduced on Linux with a read-only tmpfs standing in for the sealed volume (
XDG_RUNTIME_DIR=/mnt/sealed/run/user/501):boo new -d test→error: ReadOnlyFileSystem, exit 1/tmp/boo-<uid>(0700); a validXDG_RUNTIME_DIRis still preferredzig build test-all: 131/131 tests pass, including new unit tests for the resolution order and fallbackInvestigation notes
boo newpath aresocketDir(makePath) and the socketbind(2); both can returnEROFS, but/tmp/boo-<uid>is writable on a stock Mac, which pointed at theXDG_RUNTIME_DIRbranch.Dir.makePathretries parent components onFileNotFound, so a missing/run/user/501/booends inmkdir /runagainst the sealed volume.socketDirFrom(alloc, boo_dir, runtime_dir)so unit tests can drive it without mutating the process environment (std.c.setenvis not exposed in Zig 0.15.2).boo helpalready documents the resolution order as$BOO_DIR, else$XDG_RUNTIME_DIR/boo, else/tmp/boo-<uid>, which remains accurate./tmpfallback), so no warning is printed when falling back.This PR was generated by Coder Agents on behalf of @kylecarbs, prompted by a Hacker News bug report.