Skip to content

Global npm install on macOS/Linux causes incorrect repo root resolution (/opt/homebrew instead of actual workspace) #541

@rongtianhua

Description

@rongtianhua

Problem

When @evomap/evolver is installed globally via npm (e.g. npm install -g @evomap/evolver), the getRepoRoot() function walks upward from the package directory inside node_modules and stops at the first .git directory it finds. On macOS with Homebrew, this causes it to resolve to /opt/homebrew (Homebrew's own git repo) instead of the user's actual project workspace.

Impact

  • repoRoot/opt/homebrew
  • workspaceRoot/opt/homebrew
  • memoryDir/opt/homebrew/memory (does not exist)
  • evolutionDir/opt/homebrew/memory/evolution (does not exist)

The evolver scans wrong session logs and produces evolution proposals for the wrong codebase.

Workaround

Set EVOLVER_REPO_ROOT env var explicitly:

<<key>EVOLVER_REPO_ROOT</key>
<string>/Users/allenrong/.openclaw/workspace</string>

Suggested Fix

When the evolver binary is installed inside a node_modules directory (global or local), detect this condition and either:

  1. Skip the .git auto-discovery entirely and require explicit EVOLVER_REPO_ROOT
  2. Add a node_modules boundary in the upward walk so it never escapes the user's project
  3. Prefer process.env.HOME or process.cwd() over git root when inside package manager directories

Environment

  • OS: macOS 15.5 (arm64)
  • Node: v26.0.0
  • Evolver: v1.85.2
  • Install method: npm install -g @evomap/evolver

Verification

cd /opt/homebrew/lib/node_modules/@evomap/evolver && node -e "
const {getRepoRoot} = require('./src/gep/paths');
console.log(getRepoRoot()); // → /opt/homebrew ← wrong
"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions