cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
46.69k stars 3.16k forks source link

Unable to find chromium browser when using 'open --browser' flag #30055

Open jamesikanos opened 3 weeks ago

jamesikanos commented 3 weeks ago

Current behavior

I have a custom build of chromium installed at $HOME/Downloads/Linux_x64_916288_chrome-linux/chrome-linux/chrome

This is "Chromium 95"

When I launch with: cypress open --browser $HOME/Downloads/Linux_x64_916288_chrome-linux/chrome-linux/chrome

It does not detect and simply displays Chrome 121 and Electron.

However, when I sym link 'chromiim' then it is fine and displays 3 browsers (Chrome, Chromium and Electron):

ln -s $HOME/Downloads/Linux_x64_916288_chrome-linux/chrome-linux/chrome $HOME/bin/chromium

However, i don't really desire setting my global chromium PATH to this specific version as it is just used for testing.

How should the --browser flag work?

Debug log attached as a file because I couldn't paste the whole thing: cypress-missing-browser.log

Desired behavior

Cypress should query the path specified in --browser and launch it?

Test code to reproduce

Download any build of chromium to a path not on $PATH and try and run with --browser

Cypress Version

13.13.3

Node version

v20.16.0

Operating System

Ubuntu 22.04

Debug Logs

Attached as file in main body

Other

No response

jamesikanos commented 3 weeks ago

Workaround script, added into my node binaries folder:


#!/bin/bash

# Create a temporary directory
tmpdir=$(mktemp -d)

# Clean up on exit
trap "rm -rf $tmpdir" EXIT

# Create a symlink to the Chrome 95 binary in the temporary directory
ln -s $(which chrome-95) $tmpdir/chromium

# Run Cypress with the temporary directory in the PATH and append any further arguments
# For example, cypress-95 open
PATH=$tmpdir:$PATH cypress $@
MikeMcC399 commented 3 weeks ago

@jamesikanos

I can reproduce this issue. Try instead the following as a workaround:

npx cypress open --e2e --browser $HOME/Downloads/chromium/linux-916288/chrome-linux/chrome

cypress run picks up Custom Chromium 95 without needing any workaround:

npx cypress run --browser $HOME/Downloads/chromium/linux-916288/chrome-linux/chrome
jamesikanos commented 3 weeks ago

@MikeMcC399

Unfortunately I'm not getting results with that workaround. It is back to 2 browsers (latest Chrome & Electron).

I also sym linked "Chromium" in the same directory to map to "Chrome" and not working either:

cypress open --e2e --browser $HOME/Downloads/Linux_x64_916288_chrome-linux/chrome-linux/chrome

cypress open --e2e --browser $HOME/Downloads/Linux_x64_916288_chrome-linux/chrome-linux/chromium <-- Symlink to chrome in the same directory

As a shortcut, I've just added a "cypress-95" script in my PATH which does the trick for now.

If I get a chance, I might tackle this as a PR