fix(config): fall back to copy+unlink on EXDEV when writing config (#61)#171
Closed
TumCucTom wants to merge 1 commit into
Closed
fix(config): fall back to copy+unlink on EXDEV when writing config (#61)#171TumCucTom wants to merge 1 commit into
TumCucTom wants to merge 1 commit into
Conversation
On Windows and on systems where the temp directory is on a different mount than the user's home directory, fs.renameSync() throws EXDEV: cross-device link not permitted when the CLI tries to atomically swap the config file's .tmp into place. This made mmx config set / mmx auth login fail outright for those users. Catch EXDEV and fall back to copyFileSync + unlinkSync. The fallback is not atomic, but a concurrent reader will see either the old file or the fully-written new file — never a partial write — because the destination only gets replaced after the copy completes. Fixes MiniMax-AI#61. Co-authored-by: Zippy AI <tomkinsbale@icloud.com> Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Author
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.
Summary
writeConfigFile()insrc/config/loader.tsnow catchesEXDEVfromfs.renameSync()and falls back tocopyFileSync() + unlinkSync()so config writes succeed across filesystems (Windows: different drive; *nix: tmp dir on a different mount).test/config/loader-exdev.test.tsmocksfs.renameSyncto throw EXDEV and asserts the fallback path works and the temp file is cleaned up.Why
Issue #61: on Windows,
mmx config setandmmx auth loginfailed withEXDEV: cross-device link not permittedwhen the temp directory was on a different drive than the config dir. Same can happen on macOS/Linux if$TMPDIRis on a different mount than$HOME.Test plan
bun test— 358 pass, 0 fail (355 baseline + 3 new)bun run lint— no new errors (2 pre-existing errors in unrelated test files)bun run typecheck— cleanFixes #61.
🤖 Generated with Claude Code