[BUG] Working Directory Mismatch — uses user's home directory instead of the current working directory
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Bug Description
Does not understand in which working directory it actually operates. Tries to create files in the user's home directory. Repeatedly. Feels utterly broken.
Observed behavior
Claude Code was launched from D:\Source\FortiCleaner, but the assistant repeatedly attempted to write files to `C:\Users\OndřejTučný (user home directory). Required 3 rounds of user correction before the correct path was provided manually.
Root causes (in order of severity)
1. System prompt reports wrong working directory
The environment block injected into the conversation states:
Primary working directory: C:\Users\OndřejTučný
This was wrong — the actual launch directory was D:\Source\FortiCleaner. This is the primary source of truth I rely on, so everything downstream was poisoned.
2. Bash shell CWD initialized to home directory, not launch directory
When I ran pwd to verify, bash returned /c/Users/OndřejTučný — confirming the wrong directory. The shell session was initialized from the user profile rather than inheriting the CWD where claude.exe` was invoked. This eliminated my only independent way to cross-check.
3. Two authoritative signals agreed, so I dismissed contradictory user input
When the user said "It's empty and purpose-created for this micro-project", I noticed this contradicted the home directory (which clearly has Desktop, Documents, Downloads, etc.), but I rationalized the discrepancy away instead of treating it as a signal that my two data sources were both wrong. I should have flagged: "you said it's empty, but I see many files here — are we in the right place?"
4. Unnecessary directory creation compounded the problem
My first action was mkdir -p ~/FortinetConfigCleaner — inventing a subdirectory the user never asked for. Even if the CWD had been correct, this was wrong. The user said "current directory." This added an extra failure before we even got to the real path issue.
<img width="1720" height="1392" alt="Image" src="https://github.com/user-attachments/assets/f12c379b-e094-4255-808b-12059a9b885d" />
What Should Happen?
Expected behavior
- The "Primary working directory" in the system prompt should reflect the directory where
claude.exewas launched pwdin the Bash tool should return that same directory- These two values should always agree with each other and with the user's actual shell
Error Messages/Logs
[{"error":"Error: 1P event logging: 34 events failed to export (code=ECONNABORTED, timeout of 10000ms exceeded)\n at queueFailedEvents (B:/~BUN/root/src/entrypoints/cli.js:441:2574)\n at async doExport (B:/~BUN/root/src/entrypoints/cli.js:441:1516)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-04-03T09:19:58.650Z"},{"error":"Error: {\"message\":\"Failed to export 34 events (code=ECONNABORTED, timeout of 10000ms exceeded)\",\"originalLine\":\"441\",\"originalColumn\":\"1668\",\"line\":\"441\",\"column\":\"1668\",\"sourceURL\":\"B:/~BUN/root/src/entrypoints/cli.js\",\"stack\":\"Error: Failed to export 34 events (code=ECONNABORTED, timeout of 10000ms exceeded)\\n at doExport (B:/~BUN/root/src/entrypoints/cli.js:441:1668)\\n at processTicksAndRejections (native:7:39)\",\"name\":\"Error\"}\n at error (B:/~BUN/root/src/entrypoints/cli.js:1893:4366)\n at <anonymous> (B:/~BUN/root/src/entrypoints/cli.js:414:36565)\n at CJ7 (B:/~BUN/root/src/entrypoints/cli.js:414:37109)\n at <anonymous> (B:/~BUN/root/src/entrypoints/cli.js:415:19103)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-04-03T09:19:58.651Z"},{"error":"AxiosError: timeout of 5000ms exceeded\n at <anonymous> (B:/~BUN/root/src/entrypoints/cli.js:113:13337)\n at emit (node:events:92:22)\n at <anonymous> (B:/~BUN/root/src/entrypoints/cli.js:112:3321)\n at request (B:/~BUN/root/src/entrypoints/cli.js:115:2467)\n at async Mj4 (B:/~BUN/root/src/entrypoints/cli.js:1893:528)\n at async Li (B:/~BUN/root/src/entrypoints/cli.js:414:3538)\n at async Oj4 (B:/~BUN/root/src/entrypoints/cli.js:1893:641)\n at async <anonymous> (B:/~BUN/root/src/entrypoints/cli.js:124:18603)\n at async FhK (B:/~BUN/root/src/entrypoints/cli.js:1893:932)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-04-03T09:19:59.017Z"},{"error":"AxiosError: timeout of 5000ms exceeded\n at <anonymous> (B:/~BUN/root/src/entrypoints/cli.js:113:13337)\n at emit (node:events:92:22)\n at <anonymous> (B:/~BUN/root/src/entrypoints/cli.js:112:3321)\n at request (B:/~BUN/root/src/entrypoints/cli.js:115:2467)\n at async doExport (B:/~BUN/root/src/entrypoints/cli.js:1893:2430)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-04-03T09:19:59.017Z"},{"error":"Error: {\"message\":\"PeriodicExportingMetricReader: metrics export failed (error AxiosError: timeout of 5000ms exceeded)\",\"originalLine\":\"1865\",\"originalColumn\":\"60611\",\"line\":\"1865\",\"column\":\"60611\",\"sourceURL\":\"B:/~BUN/root/src/entrypoints/cli.js\",\"stack\":\"Error: PeriodicExportingMetricReader: metrics export failed (error AxiosError: timeout of 5000ms exceeded)\\n at _doRun (B:/~BUN/root/src/entrypoints/cli.js:1865:60611)\\n at processTicksAndRejections (native:7:39)\",\"name\":\"Error\"}\n at error (B:/~BUN/root/src/entrypoints/cli.js:1893:4366)\n at <anonymous> (B:/~BUN/root/src/entrypoints/cli.js:414:36565)\n at CJ7 (B:/~BUN/root/src/entrypoints/cli.js:414:37109)\n at _runOnce (B:/~BUN/root/src/entrypoints/cli.js:1865:60076)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-04-03T09:19:59.018Z"},{"error":"AxiosError: timeout of 5000ms exceeded\n at <anonymous> (B:/~BUN/root/src/entrypoints/cli.js:113:13337)\n at emit (node:events:92:22)\n at <anonymous> (B:/~BUN/root/src/entrypoints/cli.js:112:3321)\n at request (B:/~BUN/root/src/entrypoints/cli.js:115:2467)\n at async VN$ (B:/~BUN/root/src/entrypoints/cli.js:454:3807)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-04-03T09:38:09.152Z"}]
Steps to Reproduce
- Start claude in an empty directory, not in the user's home
- Type a prompt to e.g. create a simple script
- Let it execute, looking for where to place the script
Claude Model
Opus
Is this a regression?
Yes, this worked in a previous version
Last Working Version
2.1.89 (Claude Code)
Claude Code Version
2.1.91 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Windows Terminal
Additional Information
Environment
- Platform: Windows 11 Pro, bash shell (Git Bash / MSYS2)
- Likely relevant: Windows path (
D:\Source\FortiCleaner) vs. MSYS-style path translation — the launch directory may have been lost during the Win32-to-bash path mapping, falling back to$HOME
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗