Skip to content

fix(config): fall back to copy+unlink on EXDEV when writing config (#61)#171

Closed
TumCucTom wants to merge 1 commit into
MiniMax-AI:mainfrom
TumCucTom:fix/cli-61-exdev-rename
Closed

fix(config): fall back to copy+unlink on EXDEV when writing config (#61)#171
TumCucTom wants to merge 1 commit into
MiniMax-AI:mainfrom
TumCucTom:fix/cli-61-exdev-rename

Conversation

@TumCucTom
Copy link
Copy Markdown

Summary

  • writeConfigFile() in src/config/loader.ts now catches EXDEV from fs.renameSync() and falls back to copyFileSync() + unlinkSync() so config writes succeed across filesystems (Windows: different drive; *nix: tmp dir on a different mount).
  • New test test/config/loader-exdev.test.ts mocks fs.renameSync to throw EXDEV and asserts the fallback path works and the temp file is cleaned up.
  • Sanity test for the happy path (rename succeeds → no copy/unlink).

Why

Issue #61: on Windows, mmx config set and mmx auth login failed with EXDEV: cross-device link not permitted when the temp directory was on a different drive than the config dir. Same can happen on macOS/Linux if $TMPDIR is on a different mount than $HOME.

Test plan

  • New test mocks rename to throw EXDEV; asserts fallback succeeds
  • 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 — clean

Fixes #61.

🤖 Generated with Claude Code

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>
@TumCucTom
Copy link
Copy Markdown
Author

TumCucTom commented Jun 2, 2026

closing in favor of #162 — yours is earlier (May 26 vs my June 1) and the design is better (exported renameWithCrossDeviceFallback as a generic helper with DI, much cleaner than what I did in #171). no point in two competing PRs for the same issue.

@TumCucTom TumCucTom closed this Jun 2, 2026
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