openclaw - ✅(Solved) Fix [Bug]: 看起来有人把工作路径hardcode进代码里而且居然被合并发布了 [1 pull requests, 10 comments, 4 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#51429Fetched 2026-04-08 01:11:22
View on GitHub
Comments
10
Participants
4
Timeline
18
Reactions
0
Timeline (top)
commented ×10cross-referenced ×2labeled ×2mentioned ×2

20260321,今天刚安装的,最新版,结果openclaw建了一个/Users/wangtao的文件夹,并且把工作区设成了这个目录。 这位wangtao是谁?

Apparently some wangtao hardcode his working space path into the code and somebody merged his code and published, now openclaw just mkdir /Users/wangtao then works there.

Really UGLY Code.

<img width="897" height="1280" alt="Image" src="https://github.com/user-attachments/assets/0d1fe208-0253-456e-9760-b918419e74d7" /> <img width="897" height="1280" alt="Image" src="https://github.com/user-attachments/assets/16ab8ebd-7b3e-4763-8a09-f3f6d90bc0d0" />

Root Cause

20260321,今天刚安装的,最新版,结果openclaw建了一个/Users/wangtao的文件夹,并且把工作区设成了这个目录。 这位wangtao是谁?

Apparently some wangtao hardcode his working space path into the code and somebody merged his code and published, now openclaw just mkdir /Users/wangtao then works there.

Really UGLY Code.

<img width="897" height="1280" alt="Image" src="https://github.com/user-attachments/assets/0d1fe208-0253-456e-9760-b918419e74d7" /> <img width="897" height="1280" alt="Image" src="https://github.com/user-attachments/assets/16ab8ebd-7b3e-4763-8a09-f3f6d90bc0d0" />

PR fix notes

PR #56810: Onboard: persist default workspace as portable ~/.openclaw path

Description (problem / solution / changelog)

Summary

Describe the problem and fix in 2–5 bullets:

  • Problem: onboarding/setup could persist resolved absolute default workspace paths in config, which can look like hardcoded host-specific paths when config is migrated/synced across machines.
  • Why it matters: config portability suffers and users can see confusing foreign absolute paths.
  • What changed: when workspace matches canonical default, config now stores portable ~/.openclaw/workspace (profile-aware) instead of absolute home path.
  • What did NOT change (scope boundary): runtime filesystem operations still resolve to absolute paths at execution time.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

  • Closes #51429
  • Related #
  • This PR fixes a bug or regression

Root Cause / Regression History (if applicable)

  • Root cause: onboarding/configure/setup resolved default workspace to absolute path and wrote it directly to agents.defaults.workspace.
  • Missing detection / guardrail: no canonical mapping back to portable default string for persisted config.
  • Prior context (git blame, prior PR, issue, or refactor if known): issue #51429 reports apparent hardcoded path behavior from config baking.
  • Why this regressed now: portability issues become visible when configs are reused across hosts.
  • If unknown, what was ruled out: actual hardcoded username path in source was ruled out.

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
  • Target test or file: src/agents/workspace.defaults.test.ts, src/commands/setup.test.ts
  • Scenario the test should lock in: default workspace persistence remains portable (~/.openclaw/...) while runtime still resolves absolute path correctly.
  • Why this is the smallest reliable guardrail: bug is in config serialization for default workspace value.
  • Existing test that already covers this (if any): setup/onboard tests extended for persisted value expectations.
  • If no new test is added, why not: N/A.

User-visible / Behavior Changes

  • Config files now store portable default workspace strings for default path cases.

Diagram (if applicable)

Before:
default workspace -> resolve absolute path -> persist /Users/<name>/.openclaw/workspace

After:
default workspace -> detect canonical default -> persist ~/.openclaw/workspace

Security Impact (required)

  • New permissions/capabilities? (Yes/No) No
  • Secrets/tokens handling changed? (Yes/No) No
  • New/changed network calls? (Yes/No) No
  • Command/tool execution surface changed? (Yes/No) No
  • Data access scope changed? (Yes/No) No
  • If any Yes, explain risk + mitigation:

Repro + Verification

Environment

  • OS: macOS (dev)
  • Runtime/container: Node 24 / pnpm workspace
  • Model/provider: N/A
  • Integration/channel (if any): onboarding/setup/configure flows
  • Relevant config (redacted): default workspace settings

Steps

  1. Run setup/onboard/configure with default workspace value.
  2. Inspect saved agents.defaults.workspace in config.
  3. Confirm persisted value is portable ~/.openclaw/... and runtime still resolves correctly.

Expected

  • Portable default path in config for canonical default workspace.

Actual

  • Config now stores ~/.openclaw/workspace (or profile-specific variant) for default-path cases.

Evidence

  • Failing test/log before + passing after

  • Trace/log snippets

  • Screenshot/recording

  • Perf numbers (if relevant)

  • pnpm test -- src/agents/workspace.defaults.test.ts src/commands/setup.test.ts src/commands/onboard-config.test.ts

  • pnpm test -- src/wizard/setup.test.ts

Human Verification (required)

  • Verified scenarios: setup/onboard/configure persist portable defaults when using canonical workspace.
  • Edge cases checked: profile-aware default workspace suffix behavior.
  • What you did not verify: full interactive onboarding matrix across all shells/platforms manually.

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

  • Backward compatible? (Yes/No) Yes
  • Config/env changes? (Yes/No) No
  • Migration needed? (Yes/No) No
  • If yes, exact upgrade steps:

Risks and Mitigations

  • Risk: users relying on absolute default path serialization may notice config text changes.
    • Mitigation: runtime path resolution remains unchanged; only persisted default representation becomes portable.

Made with Cursor

Changed files

  • src/agents/workspace.defaults.test.ts (modified, +29/-1)
  • src/agents/workspace.ts (modified, +29/-0)
  • src/commands/configure.wizard.ts (modified, +2/-1)
  • src/commands/onboard-helpers.ts (modified, +2/-2)
  • src/commands/onboard-non-interactive/local.ts (modified, +5/-1)
  • src/commands/setup.test.ts (modified, +1/-0)
  • src/commands/setup.ts (modified, +15/-3)
  • src/wizard/setup.ts (modified, +5/-1)

Code Example

<img width="897" height="1280" alt="Image" src="https://github.com/user-attachments/assets/0d1fe208-0253-456e-9760-b918419e74d7" />

<img width="897" height="1280" alt="Image" src="https://github.com/user-attachments/assets/16ab8ebd-7b3e-4763-8a09-f3f6d90bc0d0" />
RAW_BUFFERClick to expand / collapse

Bug type

Behavior bug (incorrect output/state without crash)

Summary

20260321,今天刚安装的,最新版,结果openclaw建了一个/Users/wangtao的文件夹,并且把工作区设成了这个目录。 这位wangtao是谁?

Apparently some wangtao hardcode his working space path into the code and somebody merged his code and published, now openclaw just mkdir /Users/wangtao then works there.

Really UGLY Code.

<img width="897" height="1280" alt="Image" src="https://github.com/user-attachments/assets/0d1fe208-0253-456e-9760-b918419e74d7" /> <img width="897" height="1280" alt="Image" src="https://github.com/user-attachments/assets/16ab8ebd-7b3e-4763-8a09-f3f6d90bc0d0" />

Steps to reproduce

只要问问openclaw它现在的工作区是什么就可以了。

Just ask openclaw where its working space is.

<img width="2232" height="2160" alt="Image" src="https://github.com/user-attachments/assets/b31db7c1-b71b-4335-bad9-8862118a81d8" />

Expected behavior

显然工作路径应该是~/.openclaw 而不是这个/User/wangtao,这个用户就不该出现在我的电脑上。

It should be ~/.openclaw

Actual behavior

/User/wangtao/.openclaw

OpenClaw version

2026.3.13

Operating system

non relevant

Install method

non relevant

Model

non relevant

Provider / routing chain

non relevant

Additional provider/model setup details

No response

Logs, screenshots, and evidence

<img width="897" height="1280" alt="Image" src="https://github.com/user-attachments/assets/0d1fe208-0253-456e-9760-b918419e74d7" />

<img width="897" height="1280" alt="Image" src="https://github.com/user-attachments/assets/16ab8ebd-7b3e-4763-8a09-f3f6d90bc0d0" />

Impact and severity

No response

Additional information

No response

extent analysis

Fix Plan

To fix the issue, we need to remove the hardcoded working space path and use the correct default path ~/.openclaw.

Here are the steps:

  • Identify the file where the working space path is hardcoded.
  • Replace the hardcoded path with the correct default path.
  • Use the os module to get the user's home directory and construct the default path.

Example code:

import os

# Get the user's home directory
home_dir = os.path.expanduser('~')

# Construct the default working space path
working_space_path = os.path.join(home_dir, '.openclaw')

# Use the working_space_path variable to set the working space
  • Remove any existing hardcoded working space directories that may have been created.

Verification

To verify that the fix worked, check the working space path after running the updated code. It should be ~/.openclaw instead of /Users/wangtao.

Extra Tips

  • Always use environment variables or user-configurable settings instead of hardcoding paths.
  • Use the os module to construct paths in a platform-independent way.
  • Test the code thoroughly to ensure that it works correctly on different systems and configurations.

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…

FAQ

Expected behavior

显然工作路径应该是~/.openclaw 而不是这个/User/wangtao,这个用户就不该出现在我的电脑上。

It should be ~/.openclaw

Still need to ship something?

×6

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

Back to top recommendations

TRENDING