Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]browserType.launch: Failed to launch firefox because executable doesn't exist at /root/.cache/ms-playwright/firefox-1234/firefox/firefox #5801

Closed
tanvee38 opened this issue Mar 11, 2021 · 2 comments

Comments

@tanvee38
Copy link

Context:

  • Playwright Version: [1.9.1]
  • Operating System: [Docker - Ubuntu bionic]
  • Node.js version: [14]
  • Browser: [All the browsers]

I am having browser missing issue on docker when I try to install playwright through “Run npm install” command in my dockerfile. I see that Playwright folder under node_modules but browsers don’t get installed. For this I get the above mentioned error when running the tests in my docker container. @yury-s kindly suggest.

package.json I have is as below:

{
  "name": "jest-playwright-docker",
  "version": "1.0.0",
  "description": "jest playwright simple example",
  "main": "app.js",
  "scripts": {
    "test": "jest -i",
    "test-firefox-headless": "BROWSER='firefox' HEADLESS='true' npm test",
    "test-firefox-headful": "BROWSER='firefox' HEADLESS='false' npm test",
    "test-chromium-headless": "BROWSER='chromium' HEADLESS='true' npm test",
    "test-chromium-headful": "BROWSER='chromium' HEADLESS='false' npm test",
    "report": "allure serve"
  },
  "author": "Moin Tanvee",
  "license": "ISC",
  "devDependencies": {
    "jest": "^26.4.2",
    "jest-allure": "^0.1.3",
    "playwright": "^1.9.1"
  }
}

Dockerfile I have is as below:

FROM ubuntu:bionic

LABEL Maintainer=MOIN

ENV DEBIAN_FRONTEND noninteractive

##### update ubuntu
RUN apt-get update \
    && apt-get install -y automake pkg-config libpcre3-dev zlib1g-dev liblzma-dev \
    && apt-get install -y curl net-tools build-essential git wget unzip vim python python-setuptools python3-pip python-dev python-numpy openjdk-8-jdk \
    && apt-get -y install locales \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

######################################
#### ---- NodeJS from Ubuntu ---- ####
######################################
#RUN apt-get update -y && \
#    apt-get install -y git xz-utils && \
#    apt-get install -y nodejs npm && \
#    npm --version && \
#    apt-get install -y gcc g++ make
#########################################
#### ---- Node from NODESOURCES ---- ####
#########################################
# Ref: https://github.com/nodesource/distributions
ARG NODE_VERSION=${NODE_VERSION:-14}
ENV NODE_VERSION=${NODE_VERSION}
RUN apt-get update -y && \
    apt-get install -y sudo curl git xz-utils && \
    curl -sL https://deb.nodesource.com/setup_${NODE_VERSION}.x | bash - && \
    apt-get install -y gcc g++ make && \
    apt-get install -y nodejs && \
    node -v && npm --version && \
    npm install npm -g


# install tzdata package
RUN apt-get update
ENV TZ=America/Edmonton
RUN apt-get -y install tzdata

# 2. Install WebKit dependencies - playwright
RUN apt-get update && apt-get install -y --no-install-recommends \
    libwoff1 \
    libopus0 \
    libwebp6 \
    libwebpdemux2 \
    libenchant1c2a \
    libgudev-1.0-0 \
    libsecret-1-0 \
    libhyphen0 \
    libgdk-pixbuf2.0-0 \
    libegl1 \
    libnotify4 \
    libxslt1.1 \
    libevent-2.1-6 \
    libgles2 \
    libvpx5 \
    libxcomposite1 \
    libatk1.0-0 \
    libatk-bridge2.0-0 \
    libepoxy0 \
    libgtk-3-0 \
    libharfbuzz-icu0

# 4. Install Chromium dependencies - playwright
RUN apt-get update && apt-get install -y --no-install-recommends \
    libnss3 \
    libxss1 \
    libasound2 \
    fonts-noto-color-emoji \
    libxtst6


# Install Firefox dependencies - playwright
RUN apt-get update && apt-get install -y --no-install-recommends \
    libdbus-glib-1-2 \
    libxt6 \
    libpci-dev

# create a app directory in docker image
RUN mkdir /app

# Set the working directory to /app
WORKDIR /app

# Copy the current directory contents into the container
COPY . .

# Install npm packages
COPY package.json .
COPY package-lock.json .

RUN npm install

@yury-s Kindly take a look and let me know if you need any other information. Thanks a lot again for your kind support.

@yury-s yury-s changed the title [BUG]browserType.launch: Failed to launch firefox because executable doesn't exist at /root/.cache/ms-playwright/firefox-1234/firefox/firefox Try re-installing playwright with "npm install playwright"browserType.launch: Failed to launch firefox because executable doesn't exist at /root/.cache/ms-playwright/firefox-1 234/firefox/firefox [BUG]browserType.launch: Failed to launch firefox because executable doesn't exist at /root/.cache/ms-playwright/firefox-1234/firefox/firefox Mar 11, 2021
@yury-s
Copy link
Member

yury-s commented Mar 11, 2021

It looks like the directory where you build the image from already contains node_modules which are copied into the docker image. This confuses npm install command which considers playwright as already installed and doesn't do anything about it. The reason it fails is because playwright downloads browsers into ~/.cache during installation but when you run it later in docker the directory is not there. The easiest way to fix it would be to delete node_modules from the host system before building the image so that npm install installs everything in the docker including browsers from scratch. Another option would be to run npm playwright install in the docker, it would download missing browsers to the cache.

@yury-s yury-s closed this as completed Mar 11, 2021
@tanvee38
Copy link
Author

Thanks a lot @yury-s for your kind help. Your suggestion worked 👍

csouchet added a commit to process-analytics/bpmn-visualization-js that referenced this issue Dec 17, 2021
csouchet added a commit to process-analytics/bpmn-visualization-js that referenced this issue Dec 20, 2021
* To be sure that the browser is correctly installed in the GH: microsoft/playwright#5801
* Skip browser installation with 'npm ci'
* Change steps name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants