Skip to content

fix: support linux config paths with unified home resolution#223

Open
jiang1997 wants to merge 1 commit into
TencentCloud:mainfrom
jiang1997:fix/linux-config-paths
Open

fix: support linux config paths with unified home resolution#223
jiang1997 wants to merge 1 commit into
TencentCloud:mainfrom
jiang1997:fix/linux-config-paths

Conversation

@jiang1997

Copy link
Copy Markdown

Description | 描述

  • checks the per-user app config directory before falling back to the data dir
    • Linux: $XDG_CONFIG_HOME/memory-tencentdb or ~/.config/memory-tencentdb
    • macOS/Windows paths are supported by the same helper
  • uses one shared home fallback chain for config lookup and default data dir:
    HOME -> USERPROFILE -> os.homedir() -> userInfo().homedir -> /tmp
  • keeps missing optional config candidates silent, avoiding repeated missing-path noise
  • adds regression tests for Linux config paths and home-resolution consistency

Related Issue | 关联 Issue

Fix #103

Change Type | 修改类型

  • Bug fix | Bug 修复
  • New feature | 新功能
  • Documentation update | 文档更新
  • Code optimization | 代码优化

Self-test Checklist | 自测清单

  • Verified locally | 本地验证通过
  • No existing features affected | 无影响现有功能

@jiang1997 jiang1997 marked this pull request as ready for review June 15, 2026 14:09
@Maxwell-Code07

Copy link
Copy Markdown
Collaborator

Thanks for the contribution! We'll review the Linux config path support.

Add optional-path helpers for XDG-style config lookup and resolveHomeDir()
so gateway config discovery and default data dir share the same home
fallback chain (HOME, USERPROFILE, os.homedir, userInfo, /tmp).
@jiang1997 jiang1997 force-pushed the fix/linux-config-paths branch 3 times, most recently from cbcb088 to e8047a2 Compare June 15, 2026 16:16
@Xuruida

Xuruida commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the contribution! The gateway config path resolution part looks good — clean code, proper XDG support, and solid test coverage.

However, this PR only partially fixes #103. There are two other files with the same fragile home-directory resolution pattern that should be updated in this PR for a complete fix:

  1. src/utils/ensure-hook-policy.ts — resolveConfigPath()

Line 155 still uses the old inline pattern without a /tmp fallback:

const home = getEnv("HOME") ?? getEnv("USERPROFILE") ?? "";

This should use resolveHomeDir() instead. The three fs.existsSync calls in this function (lines 145, 151, 158) should also be replaced with optionalConfigFileExists for consistency.

  1. src/utils/openclaw-state-dir.ts — resolveOpenClawStateDir()

Line 33 uses bare homedir() with no fallback chain:

path.join(homedir(), ".openclaw")

This should use resolveHomeDir() so all three call sites share the same HOME → USERPROFILE → os.homedir() → userInfo().homedir → /tmp resolution chain.

Both are the same class of bug described in #103. Could you apply resolveHomeDir() to these two files as well?

@YOMXXX

YOMXXX commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Triage note: #443 is now the canonical verified fix for #103.

I previously could not select #223 because local focused verification still resolved the default port instead of the test fixture config path. #443 covers the same Linux/XDG config-path problem with a shared helper and regression tests for Gateway config, OpenClaw config, and OpenClaw state-dir fallback.

Verified #443 locally with:

  • COREPACK_ENABLE_AUTO_PIN=0 pnpm vitest run src/utils/config-paths.test.ts
  • COREPACK_ENABLE_AUTO_PIN=0 pnpm test
  • COREPACK_ENABLE_AUTO_PIN=0 pnpm build
  • git diff --check

Recommendation: close this as superseded by #443.

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.

[good first issue]🎯 Plugin reads platform-specific paths that do not exist on Linux

4 participants