fix(browser): install Playwright runtime in package dir, not cwd#1000
fix(browser): install Playwright runtime in package dir, not cwd#1000LonestoneBot wants to merge 1 commit into
Conversation
The "Install Runtime" button ran `npm install playwright` and
`playwright install chromium` with `cwd: process.cwd()` — the directory
CloudCLI happened to be launched from. Playwright therefore landed in that
directory's `node_modules`, but `getPlaywright()` resolves the package via
`require('playwright')`, which resolves relative to this module inside the
CloudCLI install. The two never meet: the install "succeeds" (and Chromium
downloads to the shared cache) yet the runtime probe keeps reporting
`playwrightInstalled: false`, so the button spins and silently reverts with
no error.
Run the install commands from the package root (the nearest package.json
ancestor of this module) so Playwright lands in a node_modules that
require() can resolve.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughRuntime command execution now finds the nearest owning ChangesPackage-root execution
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Problem
Clicking Install Runtime in the Browser panel spins for a moment, then silently reverts to "not installed" — no error is shown and nothing in the server console indicates a failure. The runtime never becomes usable.
Root cause
installRuntime()inbrowser-use.service.tsruns the install commands throughrunCommand(), which spawns them with:process.cwd()is whatever directory CloudCLI happened to be launched from. Sonpm install --no-save playwrightinstalls Playwright into that directory'snode_modules(e.g.~/some-project/node_modules/playwright).But the runtime is later resolved with:
require('playwright')resolves relative to this module inside the CloudCLI install, walking up its directory tree — never the launch directory. The two locations never meet:~/.cache/ms-playwright/~/Library/Caches/ms-playwright).require('playwright'), which still throws →playwrightInstalled: false.Reproduced against
@cloudcli-ai/cloudcli@1.36.1installed globally: after clicking the button,playwrightends up in the launch dir'snode_modules, whilerequire('playwright')from the global package keeps failing.Fix
Run the install commands from the package root (the nearest
package.jsonancestor of this module) instead ofprocess.cwd(), so Playwright lands in anode_modulesthatrequire()can actually resolve. Verified: installing into the package root makesrequire('playwright')resolve and the runtime report ready. Works in both the compiled layout (dist-server/...) and dev (tsx server/...), since both resolve to the repo/package root.runCommandgains an optionalcwdparam defaulting to the package root, keeping the change contained (it is only used by the install path).Summary by CodeRabbit