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

Failed to connect to the bus - Cypress failed to start #30529

Closed
ivanovid82 opened this issue Nov 4, 2024 · 9 comments
Closed

Failed to connect to the bus - Cypress failed to start #30529

ivanovid82 opened this issue Nov 4, 2024 · 9 comments

Comments

@ivanovid82
Copy link

ivanovid82 commented Nov 4, 2024

Current behavior

[FAILED] [31:1104/101225.003876:ERROR:bus.cc(407)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory

Desired behavior

Test should be executed

Test code to reproduce

Using
Cypress Docker included image version 13.15.0

Cypress Version

13.5.0

Node version

22.6

Operating System

Debian 12.7

Debug Logs

[STARTED] Task without title.
[FAILED] Cypress failed to start.
[FAILED] 
[FAILED] This may be due to a missing library or dependency. https://on.cypress.io/required-dependencies
[FAILED] 
[FAILED] Please refer to the error below for more details.
[FAILED] 
[FAILED] ----------
[FAILED] 
[FAILED] [31:1104/101225.003876:ERROR:bus.cc(407)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[FAILED] Fontconfig error: No writable cache directories
[FAILED] Fontconfig error: No writable cache directories
[FAILED] Fontconfig error: No writable cache directories
[FAILED] Fontconfig error: No writable cache directories
[FAILED] Fontconfig error: No writable cache directories
[FAILED] 
[FAILED] ----------
[FAILED] 
[FAILED] Platform: linux-x64 (Debian - 12.7)
[FAILED] Cypress Version: 13.15.0
Cypress failed to start.

This may be due to a missing library or dependency. https://on.cypress.io/required-dependencies
Error: Process completed with exit code 1.

Other

No response

@MikeMcC399
Copy link
Contributor

@ivanovid82

What host environment are you running in? Is this a local environment or a CI environment?

How are you running the Cypress Docker image cypress/included:13.15.0?

@ivanovid82
Copy link
Author

@ivanovid82

What host environment are you running in? Is this a local environment or a CI environment?
Self host runner. On github -> CI Env
How are you running the Cypress Docker image cypress/included:13.15.0?
As single container command via docker run

@MikeMcC399
Copy link
Contributor

@ivanovid82

In GitHub Actions, the recommended way to run a cypress/included image is

    container:
      image: cypress/included:13.15.0
      options: --user 1001

See for instance https://docs.cypress.io/app/continuous-integration/github-actions#Testing-with-Cypress-Docker-Images

@MikeMcC399
Copy link
Contributor

@ivanovid82
Copy link
Author

ivanovid82 commented Nov 4, 2024

So as per current situation

If i execute with root user it executed tests and works fine
If i execute with non-root user -> docker run -u $(id -u) cypress/included It fails with error i explained
If i execute with non root user included within cypress/included image called node
docker run -u node cypress/included

[STARTED] Task without title.
[FAILED] EACCES: permission denied, open '/app/.cache/Cypress/13.15.0/binary_state.json'
An unexpected error occurred while verifying the Cypress executable.

Please search Cypress documentation for possible solutions:

https://on.cypress.io/

Check if there is a GitHub issue describing this crash:

https://github.com/cypress-io/cypress/issues

Consider opening a new issue.

----------

Error: EACCES: permission denied, open '/app/.cache/Cypress/13.15.0/binary_state.json'

@MikeMcC399
Copy link
Contributor

@ivanovid82

If you use docker run instead of using the GitHub Actions jobs.<job_id>.container workflow option, as shown in the Cypress documentation, then it is expected that you will encounter permissions issues.

The cypress/included image stores the Cypress binary in /root/.cache/Cypress to avoid these issues and it assumes that the Cypress Docker image is used as documented.

@jennifer-shehane jennifer-shehane added the stage: needs information Not enough info to reproduce the issue label Nov 4, 2024
@ivanovid82
Copy link
Author

ivanovid82 commented Nov 5, 2024

Here is the piece of workflow where i am executing tests
Before that i am pulling image cypress-image via Docker file created also below (which contains cypress:included)

  • name: Run cypress api tests
    working-directory: ${{ github.workspace }}/tests
    run: |

       export X_APIKEY=${{ secrets.API_KEY_PREMIUM }}
       export ENV=${{ inputs.env }}
       export WORK_DIR=${{ github.workspace }}/tests/
       export DOCKER_USER=$(id -u)
    
       mkdir ${WORK_DIR}/reports/
    
       echo "User Name"
       echo $DOCKER_USER
    
       docker run --pull=always -v ${{ github.workspace }}/tests/reports:/app/cypress/results --env X_APIKEY=$X_APIKEY -u $DOCKER_USER cypress-image
    
       echo "User Name"
       echo $DOCKER_USER
       
       
       
      #Docker file
    

FROM cypress/included:latest

RUN mkdir -p /var/cache/fontconfig && chmod -R 777 /var/cache/fontconfig
ENV FONTCONFIG_PATH=/var/cache/fontconfig

WORKDIR /app

COPY package.json package-lock.json /app/

COPY . /app
COPY cypress.config.ts /app/

RUN npm i

RUN whoami

ENV appEnv="qa"
ENV grepTags=""
ENV X_APIKEY=${X_APIKEY}

ENTRYPOINT ["npx", "cypress", "run"]
CMD ["--env", "appEnv=${appEnv},grepTags=${grepTags}"]

@MikeMcC399
Copy link
Contributor

@ivanovid82

At this stage I don't see any sign that there is a bug in Cypress or the Cypress Docker image that you are using. If you think you have identified a bug in a Cypress Docker image or a mistake in the documentation, you are welcome to file an issue in the Cypress Docker repository.

The primary purpose of the issue list here is to report bugs or request feature enhancements for the core Cypress software.

Since you are not using the recommended way to run Cypress Docker images in GitHub Actions - calling docker directly instead of using the built-in container option of GitHub Actions - I don't see much scope for providing you with additional assistance for your setup.

Note: for better readability of code in GitHub issues, which use Markdown for formatting, you can use fenced code blocks with triple backticks. See the GitHub documentation Creating and highlighting code blocks.


The example workflow on https://github.com/cypress-io/cypress-docker-images/blob/master/.github/workflows/example-cypress-github-action.yml shows how a cypress/included Docker image is normally run in GitHub Actions. I pasted a shortened version below. You can fork and clone the repo https://github.com/cypress-io/cypress-docker-images to run the workflow in your fork as an example.

name: Example Cypress GitHub Actions
# This example workflow demonstrates
# GitHub Actions (https://docs.github.com/en/actions) using the
# Cypress JavaScript GitHub Action (https://github.com/cypress-io/github-action) with
# Cypress Docker images (https://github.com/cypress-io/cypress-docker-images)

# The workflow is triggered manually on demand, see
# https://docs.github.com/en/actions/using-workflows/manually-running-a-workflow
# To automatically trigger a workflow, for instance on a push event, see
# https://docs.github.com/en/actions/using-workflows/triggering-a-workflow

on: workflow_dispatch

jobs:
  docker-included:
    runs-on: ubuntu-24.04
    strategy:
      fail-fast: false
      matrix:
        browser: [chrome, edge, firefox]
    # from https://hub.docker.com/r/cypress/included/tags
    container:
      # Examples use latest tag
      # For production use, to avoid the risk of breaking changes,
      # choose a fixed version tag from
      # https://hub.docker.com/r/cypress/included/tags
      image: cypress/included:latest
      options: --user 1001
    steps:
      - uses: actions/checkout@v4
      - uses: cypress-io/github-action@v6
        with:
          # Using Cypress project with no Cypress version pre-installed
          working-directory: examples/basic-mini
          browser: ${{ matrix.browser }}
        env:
          # Cypress binary is already installed in cypress/included image
          # Use CYPRESS_INSTALL_BINARY=0 to prevent unneeded caching
          # which can cause errors with non-root user
          # see https://on.cypress.io/guides/references/advanced-installation#Skipping-installation
          CYPRESS_INSTALL_BINARY: 0

@jennifer-shehane jennifer-shehane closed this as not planned Won't fix, can't repro, duplicate, stale Nov 5, 2024
@jennifer-shehane jennifer-shehane removed the stage: needs information Not enough info to reproduce the issue label Nov 5, 2024
@MikeMcC399
Copy link
Contributor

[FAILED] EACCES: permission denied, open '/app/.cache/Cypress/13.15.0/binary_state.json'

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

3 participants