playwright icon indicating copy to clipboard operation
playwright copied to clipboard

[Bug]: Running `npm install` fails with "Cannot install chromium-headless-shell"

Open whimboo opened this issue 1 year ago • 4 comments

Version

1.50.0

Steps to reproduce

Steps that I did:

  • Cloned https://github.com/microsoft/playwright/ a while ago for an older version of Playwright
  • Run npm install, npm run build and other commands
  • Run git pull upstream main today to fetch the latest code
  • Tried to run npm install again but it failed with the failure as it can be seen below
  • Run npm run clean
  • Run npm install again which now works

Expected behavior

Running npm install should just work and npm run clean shouldn't be necessary to clean up some broken state.

Actual behavior

npm install                                                                                                                                                        git:(main|)
npm warn deprecated @types/[email protected]: This is a stub types definition for Facebook's Immutable (https://github.com/facebook/immutable-js). Facebook's Immutable provides its own type definitions, so you don't need @types/immutable installed!
npm warn deprecated [email protected]: This functionality has been moved to @npmcli/fs
npm warn deprecated [email protected]: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.
npm error code 1
npm error path /Users/henrik/code/playwright/packages/playwright-chromium
npm error command failed
npm error command sh -c node install.js
npm error /Users/henrik/code/playwright/packages/playwright-core/lib/server/registry/index.js:961
npm error     if (!executable || executable.installType === 'none') throw new Error(`Cannot install ${browserName}`);
npm error                                                                 ^
npm error
npm error Error: Cannot install chromium-headless-shell
npm error     at installBrowsersForNpmInstall (/Users/henrik/code/playwright/packages/playwright-core/lib/server/registry/index.js:961:65)
npm error     at Object.<anonymous> (/Users/henrik/code/playwright/packages/playwright-chromium/install.js:27:3)
npm error     at Module._compile (node:internal/modules/cjs/loader:1546:14)
npm error     at Module._extensions..js (node:internal/modules/cjs/loader:1691:10)
npm error     at Module.load (node:internal/modules/cjs/loader:1317:32)
npm error     at Module._load (node:internal/modules/cjs/loader:1127:12)
npm error     at TracingChannel.traceSync (node:diagnostics_channel:315:14)
npm error     at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
npm error     at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:166:5)
npm error     at node:internal/main/run_main_module:30:49
npm error
npm error Node.js v22.8.0
npm error A complete log of this run can be found in: /Users/henrik/.npm/_logs/2024-12-06T10_09_38_653Z-debug-0.log

The referenced log file is empty.

Additional context

No response

Environment

System:
    OS: macOS 14.7.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 780.95 MB / 32.00 GB
  Binaries:
    Node: 22.8.0 - /opt/homebrew/bin/node
    Yarn: 1.22.22 - /opt/homebrew/bin/yarn
    npm: 10.8.2 - /opt/homebrew/bin/npm
  IDEs:
    VSCode: 1.95.3 - /opt/homebrew/bin/code
  Languages:
    Bash: 3.2.57 - /bin/bash

whimboo avatar Dec 06 '24 10:12 whimboo

Hi Henrik! Greetings to Dresden. I've seen that error too, yeah. Try commenting out headless-shell in packages/playwright-chromium/install.js, or commenting out the install script in packages/playwright-chromium/package.json. That unblocks the first build, and then you can remove the comment and run another build, that should work.

Skn0tt avatar Dec 06 '24 17:12 Skn0tt

Looks like you were not building npm run build after you were pulling.

mxschmitt avatar Dec 06 '24 17:12 mxschmitt

npm run build failed as well but I don't have the logs for that anymore. It was working as well after cleaning and installing.

whimboo avatar Dec 06 '24 20:12 whimboo

Did the commenting-out work for you?

Skn0tt avatar Dec 06 '24 22:12 Skn0tt

I wasn't able to try that given that I solved my problem already before with npm run clean. I would have to get the code into the same state to do that.

whimboo avatar Dec 09 '24 08:12 whimboo

I used TimeMachine now to revert the folder contents to early December and I was able to reproduce. It was not enough to comment out the above line in just that file but it was required in the following two files to get the initial npm install succeed:

  • packages/playwright-browser-chromium/install.js
  • packages/playwright-chromium/install.js

The commit I was on before the git pull is https://github.com/microsoft/playwright/commit/ce06a81aa6563cb63c8a5077b91fef753ed30ea3.

I'll leave the code as is in case you want more details.

whimboo avatar Dec 09 '24 08:12 whimboo

Also npm install works pretty fine with this old checkout and without pulling. So some change in the repository since September 16th potentially caused that.

whimboo avatar Dec 09 '24 08:12 whimboo

Normally git pull followed by npm install, npm run clean, npm run watch and npx playwright install just works if you update existing checkout. On rare occasions things may go haywire (e.g. if we change structure of the projects etc) with incremental build, in which case resetting the state to clean checkout should always help. Our bots do clean build on every commit. If it passes on CI, running the same steps locally should succeed. I don't think it makes sense to spend much time on looking at what exact issue caused the problem after the update as it's now resolved and was probably specific to how you updated the things. I'll close the issue for now but please don't hesitate to contact us if you need further help with local setup etc.

Update: I was able to reproduce the exceptio while updating from https://github.com/microsoft/playwright/commit/ce06a81aa6563cb63c8a5077b91fef753ed30ea3 to dfa24462dbad83c404dca9443e551b8083a4d8b1, but running npm run clean before npm i fixed it for me.

yury-s avatar Dec 09 '24 18:12 yury-s