Fix: codeflash package installation for pnpm workspaces and dev environments - #1966
Fix: codeflash package installation for pnpm workspaces and dev environments#1966mohammedahmed18 wants to merge 1 commit into
Conversation
…onments
- Add -w flag for pnpm workspace roots to avoid ERR_PNPM_ADDING_TO_ROOT
- Use local package path (/opt/codeflash/packages/codeflash) in dev mode
- Improve error logging to show actual stderr at ERROR level instead of WARNING
- Add unit tests for workspace detection and local package usage
Fixes 9/13 optimization failures caused by 'Cannot find package codeflash'
Trace IDs affected: 08d594a2, 1722cff7, 23480bf7, 3074f19b, 6043236e,
b883f1bd, d01b03ce, e56507a4, f8f54e06
|
Claude finished @mohammedahmed18's task in 3m 34s —— View job PR Review SummaryTriageLARGE (108 additions across 5 files, including 55-line test file and 44 lines of new production logic). Prek ChecksAll ruff checks pass. No linting or formatting issues. Code Review1. Test file is in the wrong location — The test file is co-located with the source in 2. Tests violate Both tests use 3. assert (
"/opt/codeflash/packages/codeflash" in cmd_str
or "file:" in cmd_str
or cmd[0] in ["npm", "pnpm", "yarn", "bun"] # ← always True
)The third condition is always true because 4. Hardcoded if "/opt/codeflash" in str(codeflash_python_path):This hardcodes a deployment-specific filesystem path. If the dev environment moves (or if someone's dev setup uses a different path), the detection silently fails. An explicit env variable ( 5. Docstrings added to new private functions — Per code style rules: "Do not add docstrings to new or changed code unless the user explicitly asks for them." Both Duplicate DetectionThe No new duplicates introduced. Test CoverageThe new |
Problem
9 out of 13 optimization runs failed with
Cannot find package 'codeflash'error because the codeflash npm package installation was failing.Root causes:
pnpm add <package>requires-wflag to explicitly add to workspace root. Without it, installation fails withERR_PNPM_ADDING_TO_ROOT./opt/codeflash/), tried to install from npm registry but package either doesn't exist there or is wrong version. Should use local package at/opt/codeflash/packages/codeflash/.Solution
_is_pnpm_workspace()function to detectpnpm-workspace.yamland append-wflag when needed._get_local_codeflash_package_path()to detect dev environment and use local package path instead of npm package name.Testing
openclawworkspace)Impact
Fixes optimization failures in these trace IDs: