MiMo-Code icon indicating copy to clipboard operation
MiMo-Code copied to clipboard

[Bug] Windows: EEXIST mkdir on .git/info when target directory contains .git/ (still broken in 0.1.1)

Open Amer-CN opened this issue 5 months ago • 2 comments

Bug Summary

On Windows, any mimo command that loads a project (e.g. mimo run, mimo serve, mimo acp, mimo agent list) crashes with EEXIST: file already exists, mkdir '<dir>/.git/info' whenever the target directory contains .git/ (real directory or a .git gitlink file as in a worktree).

Confirmed in v0.1.1 (changelog shows claude-import, no Windows fix). v0.1.0 also affected.

Environment

  • OS: Windows 10/11 (PowerShell 5.1)
  • Mimo Code: @mimo-ai/[email protected], binary @mimo-ai/[email protected]
  • Runtime: bun 1.3.13 (bundled)
  • Install method: npm install -g @mimo-ai/cli (official docs script also installs this)

Reproduction

# Set up a normal git repo
mkdir E:\test-repo; cd E:\test-repo
git init

# From ANY working directory, point mimo at the repo
cd C:\Users\Admin
mimo run --dir "E:\test-repo" --print-logs --dangerously-skip-permissions `
  --format json -m deepseek/deepseek-chat "PONG"

Actual Output (v0.1.1)

INFO  service=server-proxy version=0.1.1 args=["run","--dir","E:\\test-repo",...]
INFO  service=server-proxy directory=E:\test-repo creating instance
INFO  service=project directory=E:\test-repo fromDirectory
ERROR service=server-proxy name=Error message=EEXIST: file already exists,
      mkdir 'E:\test-repo\.git\info'
      stack=Error: EEXIST: file already exists, mkdir 'E:\test-repo\.git\info'
    at async EN (B:/~BUN/root/chunk-vb4jhgk4.js:15:9958) fatal
Error: Unexpected error, check log file at  for more details
EEXIST: file already exists, mkdir 'E:\test-repo\.git\info'

The crash happens 6 ms after service=project fromDirectory, before any plugin/LSP/file-watcher init.

Expected Behavior

Session bootstraps successfully, file watcher starts, model call proceeds.

Workarounds Tested (all FAIL)

Attempt Result
--pure (skip external plugins) Same crash
--dir from a different cwd Same crash
Calling mimo.exe directly (bypass mimo.ps1 shim) Same crash
--log-level DEBUG Same crash, no extra context
git worktree add then mimo run --dir <worktree> Same crash — Mimo Code follows the .git gitlink file back to the main repo's .git/

Workaround That DOES Work

Target a directory with no .git at all (no directory, no file):

mkdir E:\mimo-clean; "hi" | Out-File E:\mimo-clean\test.txt
mimo run --dir "E:\mimo-clean" --print-logs --dangerously-skip-permissions `
  --format json -m deepseek/deepseek-chat "PONG"
# -> Session created: id=ses_... slug=neon-river, file.watcher up, server OK

This proves the bug is specifically in code paths triggered by .git/ being present at or resolvable from the target directory.

Root Cause Hypothesis

.git/info/ is a standard git directory that always exists in any initialized repo (holds exclude and refs). On Windows, bun's mkdir apparently reports EEXIST (instead of succeeding silently) when the path already exists as a directory. Mimo Code's project-loading code (service=project fromDirectory) likely calls mkdir without recursive: true (or with O_EXCL) on .git/info for some metadata/state file, which fails on every real git repo.

Stack frame is in a bun-internal chunk (B:/~BUN/root/chunk-vb4jhgk4.js:15:9958), so the offending mkdir is either:

  • in mimocode itself (missing recursive: true flag), or
  • in bun's fs.mkdir Windows path (regression vs Linux/macOS where it would succeed).

Suggested Fix

Either:

  1. Pass recursive: true (or equivalent) to the mkdir call for .git/info/.
  2. Use mkdirSync(..., { recursive: true }) so existing dirs are no-ops.
  3. Or replace with fs.ensureDir semantics (no-op when path exists).

A minimal repro patch in fromDirectory would likely fix most Windows users in one PR.

Impact

  • Severity: High — mimo run/serve/acp cannot operate on any normal git repo on Windows.
  • Affects: All Windows users (Mimo Code's only supported Windows install path).
  • Workaround cost: Must copy project without .git each session; cannot use git worktree (gitlink still resolves back); cannot use --pure/server flags.

Additional Context

  • Issue encountered while integrating Mimo Code as a worker agent (dispatcher pattern) on the engineering-manager project (~1,300 files, normal git repo).
  • All commands tested were run from C:\Users\Admin cwd with --dir pointing at the repo (not from the repo directory).
  • DeepSeek API key validation passes through to a separate 401 Authentication Fails error once the bug is bypassed — unrelated to this issue.

Amer-CN avatar Jun 19 '26 08:06 Amer-CN

Additional finding 2026-06-19: the trigger is non-ASCII (CJK) path

After more testing, the bug only fires when the project path contains non-ASCII characters (CJK etc). Pure-ASCII paths are unaffected.

Evidence

Two repos on the same machine:

Repo Path .git/info/exclude mtime .git/mimocode-project-id exists?
A F:\AIXM\gc-website (pure ASCII) 2026-06-19 17:14 (just now, written by mimo) yes (just created)
B E:\测试 (contains 测试 CJK) 2026-05-11 02:11 (untouched, original git) no (never loaded)

When mimo is run from F:\AIXM\gc-website, it successfully writes .git/info/exclude and .git/mimocode-project-id. When run against E:\测试 (any cwd, with --dir or without), it crashes 6ms in with EEXIST mkdir '<dir>/.git/info'.

Updated root cause hypothesis

Bun on Windows has a bug in fs.mkdir (or in Mimo Code's call to it) where non-ASCII characters in the path cause it to report EEXIST on a path that already exists as a directory. Pure-ASCII paths work fine.

The error stack frame B:/~BUN/root/chunk-vb4jhgk4.js:15:9958 is bun-internal. The path E:\测试\.git/info is rendered correctly in the error message (CJK preserved), so it's not a path-encoding display issue — the syscall itself fails when the resolved path contains non-ASCII bytes.

Workarounds (confirmed working)

  1. Use a pure-ASCII path for any project you want mimo to operate on (or for cwd).
  2. Rename .git → .git.mimo-bak before invoking mimo, rename back after (this is what we do in our dispatch.ps1 wrapper; works for any path encoding).
  3. Pass --dir <ascii-path-repo> from any cwd (cwd doesn't matter, only --dir target).

Option 2 is what most users hitting this will need — non-ASCII project paths are common (中文用户名, 项目名含中文 etc) and re-locating the project is not always feasible.

Suggested fix (refined)

In service=project fromDirectory, before any .git/info mkdir, ensure recursive: true is passed. The current bun path likely uses mkdir(path, { recursive: false }) or O_EXCL, which fails on existing directories when the path contains non-ASCII characters (Windows-specific encoding issue in bun's path resolution).

If recursive-true is already set, the bug is in bun itself and should be filed at https://github.com/oven-sh/bun with a minimal repro.

Amer-CN avatar Jun 19 '26 09:06 Amer-CN

Confirmed on Windows (0.1.1). The native binary (Bun-compiled) tries to mkdir .git/info without {recursive: true}, so it throws EEXIST on any repo initialized with git init. Temporary workaround: a PowerShell wrapper that renames .git/info away before calling mimo and restores it after.

henriquegeremia avatar Jun 19 '26 22:06 henriquegeremia