Skip to content

Device identity ignores OPENCLAW_STATE_DIR, always writes to ~/.openclaw/identity #9866

Description

@ziligy

Bug

The device identity module hardcodes ~/.openclaw/identity instead of respecting
OPENCLAW_STATE_DIR.

Expected: All state should go to $OPENCLAW_STATE_DIR when set.
Actual: ~/.openclaw/identity/device.json and ~/.openclaw/agents/ are created regardless.

Location

src/infra/device-identity.ts:

const DEFAULT_DIR = path.join(os.homedir(), ".openclaw", "identity");                            

This pattern appears in multiple built files:

  • dist/client-Cb1nog5C.js
  • dist/client-BEiMC6c_.js
  • dist/extensionAPI.js
  • dist/plugin-sdk/index.js

Suggested fix

  const OPENCLAW_STATE_DIR = process.env.OPENCLAW_STATE_DIR || path.join(os.homedir(),             
".openclaw");                                                                                      
  const DEFAULT_DIR = path.join(OPENCLAW_STATE_DIR, "identity");                                   

Same pattern should be applied to agents directory resolution.

Environment

  • macOS (arm64)
  • OpenClaw installed via npm
  • OPENCLAW_STATE_DIR=/Users/jeffgreenberg/Eliza
                                                                                        
bug report created by openclaw

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstaleMarked as stale due to inactivity

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions