fix(linux): use home cache dir to avoid tmpfs→ext4 EINVAL on SDK install#211
Merged
kabiroberai merged 3 commits intoApr 18, 2026
Merged
Conversation
On Linux systems where /tmp is a tmpfs mount (common on Ubuntu/Mint), FileManager.copyItem fails with POSIX EINVAL (22) when swift sdk install copies the Darwin SDK from /tmp to ~/.swiftpm on an ext4 filesystem. Fix by defaulting to ~/.cache/xtool (respecting \$XDG_CACHE_HOME) on Linux, keeping the build and install destination on the same filesystem. Fixes xtool-org#181
kabiroberai
reviewed
Apr 18, 2026
Member
kabiroberai
left a comment
There was a problem hiding this comment.
thanks! looks good for the most part, just one nit
| #endif | ||
| } | ||
|
|
||
| let url = base.appendingPathComponent("sh.xtool") |
Member
There was a problem hiding this comment.
can we avoid doing this in the branch you added, since the directory is already ~/.cache/xtool? we can instead append sh.xtool specifically in the (XTL_)TMPDIR and macOS-temporaryDirectory branches.
Contributor
Author
There was a problem hiding this comment.
Good catch, fixed! Moved the sh.xtool append into the TMPDIR and macOS branches so the Linux path stays at ~/.cache/xtool directly.
Per review feedback: the Linux XDG cache branch already lands at ~/.cache/xtool so it should not have sh.xtool appended again. Move the appendPathComponent into the other two branches instead.
kabiroberai
reviewed
Apr 18, 2026
| } | ||
|
|
||
| let url = base.appendingPathComponent("sh.xtool") | ||
| let url = base |
Member
There was a problem hiding this comment.
last nit, can we drop this and just rename base to url?
Contributor
Author
There was a problem hiding this comment.
Done, renamed base to url directly.
kabiroberai
approved these changes
Apr 18, 2026
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.
Problem
xtool setupfails on Linux Mint (and other distros) with:Root Cause
On Linux Mint (and Ubuntu-based distros),
/tmpis mounted as tmpfs while the home directory is on ext4. Foundation'sFileManager.copyItemusessendfile(2)internally, which returnsEINVAL (22)when copying between different filesystem types.TemporaryDirectoryRootdefaults toFileManager.default.temporaryDirectory→/tmpon Linux. Whenswift sdk installcopies the built SDK from/tmp/sh.xtool/...to~/.swiftpm/swift-sdks/, it crosses filesystem boundaries and fails.Fix
On Linux, default the temp directory root to
$XDG_CACHE_HOME/xtool(falling back to~/.cache/xtool) instead of/tmp. This keeps the build directory and install destination on the same filesystem, so the copy always succeeds.$XTL_TMPDIRand$TMPDIRoverrides continue to work as beforeChanges
One file,
Sources/XUtils/TemporaryDirectory.swift— 11 lines added inside a#if os(Linux)block.Fixes #181