playwright icon indicating copy to clipboard operation
playwright copied to clipboard

[BUG] Host system is missing dependencies to run browsers (WSL2)

Open Newbie012 opened this issue 3 years ago • 1 comments

Context:

  • Playwright Version:1.28.1
  • Operating System: Ubuntu 20.04.5 LTS (WSL 2)
  • Node.js version: v18.4.0
  • Browser:All

System:

  • OS: Linux 5.10 Ubuntu 20.04.5 LTS (Focal Fossa)
  • Memory: 12.41 GB / 15.58 GB
  • Container: Yes

Binaries:

  • Node: 18.4.0 - ~/.nvm/versions/node/v18.4.0/bin/node
  • Yarn: 1.22.19 - ~/.nvm/versions/node/v18.4.0/bin/yarn
  • npm: 8.12.1 - ~/.nvm/versions/node/v18.4.0/bin/npm

Languages:

  • Bash: 5.0.17 - /usr/bin/bash

npmPackages:

  • playwright: 1.28.1 => 1.28.1

Code Snippet

Help us help you! Put down a short code snippet that illustrates your bug and that we can run and debug locally. For example:

import { chromium } from "playwright";

async function main() {
  const browser = await chromium.launch();
}

main();

Describe the bug

While running the code above, I'm getting

╔══════════════════════════════════════════════════════╗
║ Host system is missing dependencies to run browsers. ║
║ Please install them with the following command:      ║
║                                                      ║
║     sudo npx playwright install-deps                 ║
║                                                      ║
║ Alternatively, use apt:                              ║
║     sudo apt-get install libglib2.0-0\               ║
║         libnss3\                                     ║
║         libnspr4\                                    ║
║         libatk1.0-0\                                 ║
║         libatk-bridge2.0-0\                          ║
║         libcups2\                                    ║
║         libdrm2\                                     ║
║         libdbus-1-3\                                 ║
║         libatspi2.0-0\                               ║
║         libxcomposite1\                              ║
║         libxdamage1\                                 ║
║         libxfixes3\                                  ║
║         libxrandr2\                                  ║
║         libgbm1\                                     ║
║         libxkbcommon0\                               ║
║         libpango-1.0-0\                              ║
║         libcairo2\                                   ║
║         libasound2                                   ║
║                                                      ║
║ <3 Playwright Team                                   ║
╚══════════════════════════════════════════════════════╝

Trying to follow the instructions leads to the same error:

➜  xxx ✗ pnpm tsx src/index.ts
browserType.launch: 
╔══════════════════════════════════════════════════════╗
║ Host system is missing dependencies to run browsers. ║
║ Please install them with the following command:      ║
║                                                      ║
║     sudo npx playwright install-deps                 ║
║                                                      ║
║ Alternatively, use apt:                              ║
║     sudo apt-get install libglib2.0-0\               ║
║         libnss3\                                     ║
║         libnspr4\                                    ║
║         libatk1.0-0\                                 ║
║         libatk-bridge2.0-0\                          ║
║         libcups2\                                    ║
║         libdrm2\                                     ║
║         libdbus-1-3\                                 ║
║         libatspi2.0-0\                               ║
║         libxcomposite1\                              ║
║         libxdamage1\                                 ║
║         libxfixes3\                                  ║
║         libxrandr2\                                  ║
║         libgbm1\                                     ║
║         libxkbcommon0\                               ║
║         libpango-1.0-0\                              ║
║         libcairo2\                                   ║
║         libasound2                                   ║
║                                                      ║
║ <3 Playwright Team                                   ║
╚══════════════════════════════════════════════════════╝
    at main (/.../src/index.ts:167:34)
    at queue (/.../src/index.ts:269:1)
    at Object.<anonymous> (/.../src/index.ts:269:6)
    at Object.T (/home/eliya/projects/home-app/node_modules/.pnpm/@[email protected]/node_modules/@esbuild-kit/cjs-loader/dist/index.js:1:901) {
  name: 'Error'
}

Node.js v18.4.0
➜  xxx ✗ sudo npx playwright install-deps
sudo: npx: command not found
➜  xxx ✗ npx playwright install-deps
Installing dependencies...
Switching to root user to install dependencies...
Hit:1 https://download.docker.com/linux/ubuntu focal InRelease
Hit:2 https://apt.releases.hashicorp.com focal InRelease                                                                            
Hit:3 https://cli.github.com/packages focal InRelease                                                                               
Get:4 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]                                                           
Hit:5 https://cli.github.com/packages stable InRelease                                                                              
Hit:6 https://dl.google.com/linux/chrome/deb stable InRelease                                                                       
Hit:7 http://ppa.launchpad.net/redislabs/redis/ubuntu focal InRelease                                                      
Hit:8 http://archive.ubuntu.com/ubuntu focal InRelease                                               
Hit:9 http://apt.postgresql.org/pub/repos/apt focal-pgdg InRelease             
Hit:10 http://archive.ubuntu.com/ubuntu focal-updates InRelease                
Hit:11 http://archive.ubuntu.com/ubuntu focal-backports InRelease
Fetched 114 kB in 1s (131 kB/s)
Reading package lists... Done
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'libfontconfig1' instead of 'libfontconfig'
fonts-liberation is already the newest version (1:1.07.4-11).
libatk1.0-0 is already the newest version (2.35.1-1ubuntu2).
libatspi2.0-0 is already the newest version (2.36.0-2).
libcairo-gobject2 is already the newest version (1.16.0-4ubuntu1).
libcairo2 is already the newest version (1.16.0-4ubuntu1).
libdbus-glib-1-2 is already the newest version (0.110-5fakssync1).
libepoxy0 is already the newest version (1.5.4-1).
libevent-2.1-7 is already the newest version (2.1.11-stable-1).
libfontconfig1 is already the newest version (2.13.1-2ubuntu3).
libhyphen0 is already the newest version (2.8.8-7).
libnspr4 is already the newest version (2:4.25-1).
libopus0 is already the newest version (1.3.1-0ubuntu1).
libpango-1.0-0 is already the newest version (1.44.7-2ubuntu4).
libpangocairo-1.0-0 is already the newest version (1.44.7-2ubuntu4).
libpangoft2-1.0-0 is already the newest version (1.44.7-2ubuntu4).
libpng16-16 is already the newest version (1.6.37-2).
libsoup2.4-1 is already the newest version (2.70.0-1).
libvpx6 is already the newest version (1.8.2-1build1).
libwoff1 is already the newest version (1.0.2-1build2).
libxcb-shm0 is already the newest version (1.14-2).
libxcb1 is already the newest version (1.14-2).
libxcomposite1 is already the newest version (1:0.4.5-1).
libxcursor1 is already the newest version (1:1.2.0-2).
libxdamage1 is already the newest version (1:1.1.5-2).
libxext6 is already the newest version (2:1.3.4-0ubuntu1).
libxfixes3 is already the newest version (1:5.0.3-2).
libxi6 is already the newest version (2:1.7.10-0ubuntu1).
libxkbcommon0 is already the newest version (0.10.0-1).
libxrandr2 is already the newest version (2:1.5.2-0ubuntu1).
libxrender1 is already the newest version (1:0.9.10-1).
libxshmfence1 is already the newest version (1.3-1).
libxt6 is already the newest version (1:1.1.5-1).
libxtst6 is already the newest version (2:1.2.3-1).
ttf-unifont is already the newest version (1:12.0.01-2).
xfonts-scalable is already the newest version (1:1.0.3-1.1).
fonts-ipafont-gothic is already the newest version (00303-18ubuntu1).
fonts-tlwg-loma-otf is already the newest version (1:0.7.1-3).
fonts-wqy-zenhei is already the newest version (0.9.45-7ubuntu1).
gstreamer1.0-libav is already the newest version (1.16.2-2).
libenchant1c2a is already the newest version (1.6.0-11.3build1).
ttf-ubuntu-font-family is already the newest version (1:0.83-4ubuntu1).
xfonts-cyrillic is already the newest version (1:1.0.4).
fonts-noto-color-emoji is already the newest version (0~20200916-1~ubuntu20.04.1).
gstreamer1.0-plugins-base is already the newest version (1.16.3-0ubuntu1.1).
gstreamer1.0-plugins-good is already the newest version (1.16.3-0ubuntu1.1).
libasound2 is already the newest version (1.2.2-2.1ubuntu2.5).
libatk-bridge2.0-0 is already the newest version (2.34.2-0ubuntu2~20.04.1).
libatomic1 is already the newest version (10.3.0-1ubuntu1~20.04).
libcups2 is already the newest version (2.3.1-9ubuntu1.2).
libdbus-1-3 is already the newest version (1.12.16-2ubuntu2.3).
libdrm2 is already the newest version (2.4.107-8ubuntu1~20.04.2).
libegl1 is already the newest version (1.3.2-1~ubuntu0.20.04.2).
libenchant-2-2 is already the newest version (2.2.8-1ubuntu0.20.04.1).
libevdev2 is already the newest version (1.9.0+dfsg-1ubuntu0.2).
libfreetype6 is already the newest version (2.10.1-2ubuntu0.2).
libgbm1 is already the newest version (21.2.6-0ubuntu0.1~20.04.2).
libgdk-pixbuf2.0-0 is already the newest version (2.40.0+dfsg-3ubuntu0.4).
libgl1 is already the newest version (1.3.2-1~ubuntu0.20.04.2).
libgles2 is already the newest version (1.3.2-1~ubuntu0.20.04.2).
libglib2.0-0 is already the newest version (2.64.6-1~ubuntu20.04.4).
libgstreamer-gl1.0-0 is already the newest version (1.16.3-0ubuntu1.1).
libgstreamer1.0-0 is already the newest version (1.16.3-0ubuntu1.1).
libgtk-3-0 is already the newest version (3.24.20-0ubuntu1.1).
libharfbuzz-icu0 is already the newest version (2.6.4-1ubuntu4.2).
libharfbuzz0b is already the newest version (2.6.4-1ubuntu4.2).
libicu66 is already the newest version (66.1-2ubuntu2.1).
libjpeg-turbo8 is already the newest version (2.0.3-0ubuntu1.20.04.3).
libnotify4 is already the newest version (0.7.9-1ubuntu3.20.04.2).
libnss3 is already the newest version (2:3.49.1-1ubuntu1.8).
libopengl0 is already the newest version (1.3.2-1~ubuntu0.20.04.2).
libopenjp2-7 is already the newest version (2.3.1-1ubuntu4.20.04.1).
libsecret-1-0 is already the newest version (0.20.4-0ubuntu1).
libwayland-client0 is already the newest version (1.18.0-1ubuntu0.1).
libwayland-egl1 is already the newest version (1.18.0-1ubuntu0.1).
libwayland-server0 is already the newest version (1.18.0-1ubuntu0.1).
libwebp6 is already the newest version (0.6.1-2ubuntu0.20.04.1).
libwebpdemux2 is already the newest version (0.6.1-2ubuntu0.20.04.1).
libx11-6 is already the newest version (2:1.6.9-2ubuntu1.2).
libx11-xcb1 is already the newest version (2:1.6.9-2ubuntu1.2).
libxml2 is already the newest version (2.9.10+dfsg-5ubuntu0.20.04.4).
libxslt1.1 is already the newest version (1.1.34-4ubuntu0.20.04.1).
ffmpeg is already the newest version (7:4.2.7-0ubuntu0.1).
gstreamer1.0-plugins-bad is already the newest version (1.16.3-0ubuntu1).
xvfb is already the newest version (2:1.20.13-1ubuntu1~20.04.4).
0 upgraded, 0 newly installed, 0 to remove and 5 not upgraded.
➜  xxx ✗ sudo apt-get install libglib2.0-0 libnss3 libnspr4 libatk1.0-0 libatk-bridge2.0-0 libcups2 libdrm2 libdbus-1-3 libxkbcommon0 libxcomposite1 libxdamage1 libxfixes3 libxrandr2 libgbm1 libpango-1.0-0 libcairo2 libasound2 libatspi2.0-0 libwayland-client0
Reading package lists... Done
Building dependency tree       
Reading state information... Done
libatk1.0-0 is already the newest version (2.35.1-1ubuntu2).
libatspi2.0-0 is already the newest version (2.36.0-2).
libcairo2 is already the newest version (1.16.0-4ubuntu1).
libnspr4 is already the newest version (2:4.25-1).
libpango-1.0-0 is already the newest version (1.44.7-2ubuntu4).
libxcomposite1 is already the newest version (1:0.4.5-1).
libxdamage1 is already the newest version (1:1.1.5-2).
libxfixes3 is already the newest version (1:5.0.3-2).
libxkbcommon0 is already the newest version (0.10.0-1).
libxrandr2 is already the newest version (2:1.5.2-0ubuntu1).
libasound2 is already the newest version (1.2.2-2.1ubuntu2.5).
libatk-bridge2.0-0 is already the newest version (2.34.2-0ubuntu2~20.04.1).
libcups2 is already the newest version (2.3.1-9ubuntu1.2).
libdbus-1-3 is already the newest version (1.12.16-2ubuntu2.3).
libdrm2 is already the newest version (2.4.107-8ubuntu1~20.04.2).
libgbm1 is already the newest version (21.2.6-0ubuntu0.1~20.04.2).
libglib2.0-0 is already the newest version (2.64.6-1~ubuntu20.04.4).
libnss3 is already the newest version (2:3.49.1-1ubuntu1.8).
libwayland-client0 is already the newest version (1.18.0-1ubuntu0.1).
0 upgraded, 0 newly installed, 0 to remove and 5 not upgraded.
➜  xxx ✗ pnpm tsx src/index.ts           
browserType.launch: 
╔══════════════════════════════════════════════════════╗
║ Host system is missing dependencies to run browsers. ║
║ Please install them with the following command:      ║
║                                                      ║
║     sudo npx playwright install-deps                 ║
║                                                      ║
║ Alternatively, use apt:                              ║
║     sudo apt-get install libglib2.0-0\               ║
║         libnss3\                                     ║
║         libnspr4\                                    ║
║         libatk1.0-0\                                 ║
║         libatk-bridge2.0-0\                          ║
║         libcups2\                                    ║
║         libdrm2\                                     ║
║         libdbus-1-3\                                 ║
║         libatspi2.0-0\                               ║
║         libxcomposite1\                              ║
║         libxdamage1\                                 ║
║         libxfixes3\                                  ║
║         libxrandr2\                                  ║
║         libgbm1\                                     ║
║         libxkbcommon0\                               ║
║         libpango-1.0-0\                              ║
║         libcairo2\                                   ║
║         libasound2                                   ║
║                                                      ║
║ <3 Playwright Team                                   ║
╚══════════════════════════════════════════════════════╝
    at main (/.../src/index.ts:167:34)
    at queue (/.../src/index.ts:269:1)
    at Object.<anonymous> (/.../src/index.ts:269:6)
    at Object.T (...) {
  name: 'Error'
}

Node.js v18.4.0

Newbie012 avatar Nov 27 '22 22:11 Newbie012

Same thing here, using WSL.

thiagomini avatar Dec 12 '22 12:12 thiagomini

Same here

pbstrein avatar Jan 06 '23 16:01 pbstrein

Same here as well

Note that I can run GUI apps in WSL2 such as Gedit without any issues.

GuillaumeDeconinck avatar Jan 11 '23 12:01 GuillaumeDeconinck

I manage to make it run with the following: LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/ npx playwright test

But modifying globally LD_LIBRARY_PATH breaks something in my WSL (apparently Golang executables). I don't know if it's my WSL or if it's "expected". I don't know enough yet on this kind of stuff.

GuillaumeDeconinck avatar Jan 11 '23 14:01 GuillaumeDeconinck

#13995 Mentioned this SO, I haven't been able to test whether that fixes the problem or not.

pbstrein avatar Jan 12 '23 14:01 pbstrein

I manage to make it run with the following: LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/ npx playwright test

But modifying globally LD_LIBRARY_PATH breaks something in my WSL (apparently Golang executables). I don't know if it's my WSL or if it's "expected". I don't know enough yet on this kind of stuff.

Interestingly enough, I have the same problem but on ubuntu 20.04 and this fixes the issue and I am able to run the tests.

vuki656 avatar Mar 22 '23 23:03 vuki656

Was having this same issue, if you use nvm to manage your node versions in WSL2 (as I am), then removing the sudo and just running npx playwright install-deps should fix it.

Found this nugget in Microsoft's official guide to installing nvm on WSL2, right after step 9:

If you are using NVM to install Node.js and NPM, you should not need to use the SUDO command to install new packages.

After that the tests ran without errors.

381181295 avatar Sep 21 '23 01:09 381181295

npx playwright install-deps fix my problem. Thanks @ch4r-ch4r

emrancu avatar Jan 09 '24 12:01 emrancu

npx playwright install-deps still didn't work for me, but this setup did (API mode):

import { chromium } from "playwright";

const browser = await chromium.launch({
  executablePath: chromium.executablePath(), // <- add this
  headless: false,
});

If that doesn't work, you can try to install google chrome separately and provide it here. I used this for testing: https://askubuntu.com/questions/79280/how-to-install-chrome-browser-properly-via-command-line

import { chromium } from "playwright";

const browser = await chromium.launch({
  executablePath: "/usr/bin/google-chrome",
  headless: false,
});

The window was not sized properly though to the viewport, I'm not sure if this is a problem on my end (I use this X410 bridge: https://www.microsoft.com/store/productId/9NLP712ZMN9Q)

KubaJastrz avatar Mar 05 '24 17:03 KubaJastrz

npx playwright install-deps fix my problem. Thanks @ch4r-ch4r

work for me, thanks

howelwu avatar Mar 28 '24 09:03 howelwu

had the same issue on wsl2 with python playwright; I ran playwright installwithout having first run playwright install-deps

jnguyen1098 avatar Apr 10 '24 16:04 jnguyen1098