cypress icon indicating copy to clipboard operation
cypress copied to clipboard

Cypress should find Windows browsers in WSL2

Open dantman opened this issue 3 years ago • 6 comments

Current behavior

In WSL2 when you follow the installation instructions the resulting Cypress setup only runs the internal Electron browser. Even if it would've found all the browsers the user has installed if you ran it on the Windows host.

Desired behavior

When Cypress is run in WSL should detect all the browsers available in the Windows host. Windows' environment, filesystem, and the ability to run .exe files are all available from within WSL2 so Cypress should be fully capable of running the host Windows' browsers.

Test code to reproduce

n/a

Cypress Version

9.2.1

Other

No response

dantman avatar Jan 13 '22 03:01 dantman

I tried next command

cypress open --browser /mnt/c/Program\ Files/Google/Chrome/Application/chrome.exe

no luck so far

alehatsman avatar Aug 02 '22 08:08 alehatsman

I have also tried to create a symlink:

sudo ln -s /mnt/c/Program\ Files/Google/Chrome/Application/chrome.exe /usr/local/bin/google-chrome

Cypress opens the browser, but later says it is not recognized.

alehatsman avatar Aug 03 '22 08:08 alehatsman

I wonder what recognized means, but couldn't find in a few mins the code that is responsible for recognition.

alehatsman avatar Aug 03 '22 08:08 alehatsman

i have same problem, cypress cant open or recognized browser, i try to install in linux browser but not work too

misaku avatar Aug 29 '22 04:08 misaku

https://nickymeuleman.netlify.app/blog/gui-on-wsl2-cypress

fuleinist avatar Sep 13 '22 02:09 fuleinist

https://nickymeuleman.netlify.app/blog/gui-on-wsl2-cypress

That link just gives instructions on installing Cypress with WSL, which is required to get Cypress to open. Once you follow these steps then you run into the problem that dantman is describing, which is that only the Electron browser is available.

kyfohatl avatar Sep 21 '22 04:09 kyfohatl

in my case the real problem was version node, try to change.. can be resolve

misaku avatar Sep 27 '22 18:09 misaku

When you open cypress in WSL, the server load the Linux environment version of this code: https://github.com/cypress-io/cypress/blob/acc1050dd2659182fa87729be5ce9c3ca99de94b/packages/launcher/lib/linux/index.ts#L111-L123

However, when you link or use --browser with Window's chrome.exe, it just opens the browser. In which, code for the Window environment: https://github.com/cypress-io/cypress/blob/acc1050dd2659182fa87729be5ce9c3ca99de94b/packages/launcher/lib/windows/index.ts#L170-L179

zero41120 avatar Oct 10 '22 22:10 zero41120

I wanted to run cypress with chrome, and managed to do so by installing chrome in WSL2 wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb sudo apt -y install ./google-chrome-stable_current_amd64.deb

abulhawa avatar Jan 23 '23 10:01 abulhawa

@abulhawa The answer i have been trawling for. Thank you.

Sam-Ryan avatar Jun 14 '23 15:06 Sam-Ryan

I've faced this same issue and after a long research I've identified that my problem is related to webpack build, so I've tried to build(npm run build) and my webpack run out of memory(WSL), I've 32GB of RAM and this still happends, so I just run this export NODE_OPTIONS=--max_old_space_size=8192 and cypress work again, took me some months to discover this as cypress doesn't stop or show errors related to webpack build(just when succeed). Hope I can help you(I've never found that related solution).

matheuspellegrini avatar Jul 04 '23 15:07 matheuspellegrini