openclaw - 💡(How to fix) Fix Windows: resolvePreferredOpenClawTmpDir uses C:\tmp instead of proper temp directory [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#60713Fetched 2026-04-08 02:48:04
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Author
Participants

On Windows, resolvePreferredOpenClawTmpDir() resolves to C:\tmp\openclaw instead of the proper Windows temp directory (C:\Users\<user>\AppData\Local\Temp\openclaw).

The gateway log line confirms this:

[gateway] log file: \tmp\openclaw\openclaw-2026-04-04.log

Root Cause

In src/infra/tmp-openclaw-dir.ts, the function first checks if POSIX_OPENCLAW_TMP_DIR (/tmp/openclaw) is accessible:

const existingPreferredState = resolveDirState(POSIX_OPENCLAW_TMP_DIR);
if (existingPreferredState === "available") return POSIX_OPENCLAW_TMP_DIR;

On Windows, Node.js resolves /tmp to C:\tmp (relative to the current drive root). If C:\tmp happens to exist (which it does on many Windows machines — Git, MSYS2, and other Unix-compat tools create it), then:

  1. fs.accessSync('/tmp', W_OK | X_OK) succeeds (because C:\tmp exists and is writable)
  2. fs.mkdirSync('/tmp/openclaw') creates C:\tmp\openclaw
  3. The function returns /tmp/openclaw — a POSIX path that Node resolves to C:\tmp\openclaw

This bypasses the intended fallback path which correctly uses os.tmpdir() to get C:\Users\<user>\AppData\Local\Temp.

Code Example

[gateway] log file: \tmp\openclaw\openclaw-2026-04-04.log

---

const existingPreferredState = resolveDirState(POSIX_OPENCLAW_TMP_DIR);
if (existingPreferredState === "available") return POSIX_OPENCLAW_TMP_DIR;

---

if (process.platform !== 'win32') {
    const existingPreferredState = resolveDirState(POSIX_OPENCLAW_TMP_DIR);
    if (existingPreferredState === "available") return POSIX_OPENCLAW_TMP_DIR;
    // ... rest of POSIX /tmp logic
}
return ensureTrustedFallbackDir();
RAW_BUFFERClick to expand / collapse

Description

On Windows, resolvePreferredOpenClawTmpDir() resolves to C:\tmp\openclaw instead of the proper Windows temp directory (C:\Users\<user>\AppData\Local\Temp\openclaw).

The gateway log line confirms this:

[gateway] log file: \tmp\openclaw\openclaw-2026-04-04.log

Root Cause

In src/infra/tmp-openclaw-dir.ts, the function first checks if POSIX_OPENCLAW_TMP_DIR (/tmp/openclaw) is accessible:

const existingPreferredState = resolveDirState(POSIX_OPENCLAW_TMP_DIR);
if (existingPreferredState === "available") return POSIX_OPENCLAW_TMP_DIR;

On Windows, Node.js resolves /tmp to C:\tmp (relative to the current drive root). If C:\tmp happens to exist (which it does on many Windows machines — Git, MSYS2, and other Unix-compat tools create it), then:

  1. fs.accessSync('/tmp', W_OK | X_OK) succeeds (because C:\tmp exists and is writable)
  2. fs.mkdirSync('/tmp/openclaw') creates C:\tmp\openclaw
  3. The function returns /tmp/openclaw — a POSIX path that Node resolves to C:\tmp\openclaw

This bypasses the intended fallback path which correctly uses os.tmpdir() to get C:\Users\<user>\AppData\Local\Temp.

Impact

  • Log files written to wrong location: C:\tmp\openclaw\openclaw-*.log instead of %TEMP%\openclaw\
  • TTS temp files accumulate in C:\tmp\openclaw\ instead of proper temp
  • Users looking in %TEMP%\openclaw\ find nothing — only the lock file exists there (written by a different code path)
  • Split state: lock file is at %TEMP%\openclaw\gateway.*.lock, logs are at C:\tmp\openclaw\ — two different locations for the same logical directory

Expected Behavior

On Windows, the function should skip the POSIX /tmp/openclaw path entirely and go straight to the os.tmpdir() fallback, producing C:\Users\<user>\AppData\Local\Temp\openclaw.

Suggested Fix

Add a platform check before trying the POSIX path:

if (process.platform !== 'win32') {
    const existingPreferredState = resolveDirState(POSIX_OPENCLAW_TMP_DIR);
    if (existingPreferredState === "available") return POSIX_OPENCLAW_TMP_DIR;
    // ... rest of POSIX /tmp logic
}
return ensureTrustedFallbackDir();

Environment

  • Windows 11 Pro (10.0.26200)
  • Node.js 22.x
  • OpenClaw 2026.4.2
  • C:\tmp exists on the system (created by Git for Windows)

extent analysis

TL;DR

The issue can be fixed by adding a platform check to skip the POSIX /tmp/openclaw path on Windows and use the os.tmpdir() fallback instead.

Guidance

  • Check if the C:\tmp directory exists on the system and consider removing it if it's not needed, as its presence causes the issue.
  • Verify that the os.tmpdir() function returns the correct temporary directory path on Windows, which should be C:\Users\<user>\AppData\Local\Temp.
  • Implement the suggested fix by adding a platform check before trying the POSIX path, as shown in the provided code snippet.
  • Test the fix by running the application on Windows and checking that log files and temporary files are written to the correct location, which should be C:\Users\<user>\AppData\Local\Temp\openclaw.

Example

if (process.platform !== 'win32') {
    const existingPreferredState = resolveDirState(POSIX_OPENCLAW_TMP_DIR);
    if (existingPreferredState === "available") return POSIX_OPENCLAW_TMP_DIR;
}
return ensureTrustedFallbackDir();

Notes

This fix assumes that the ensureTrustedFallbackDir() function correctly returns the os.tmpdir() path on Windows. If this function is not implemented correctly, additional changes may be needed.

Recommendation

Apply the suggested workaround by adding a platform check to skip the POSIX /tmp/openclaw path on Windows, as this will ensure that the application uses the correct temporary directory on Windows.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING