Open flotwig opened 2 years ago
I wasn't able to reproduce this on a Mac in 9.5.1.
Hi @flotwig, I would like to help but I was not able to reproduce the error on my environment.
What can I do to try to help?
vinicius@arch my-app(main)$ uname -a
Linux arch 5.17.1-arch1-1 #1 SMP PREEMPT Mon, 28 Mar 2022 20:55:33 +0000 x86_64 GNU/Linux
@viniciuspietscher hmm, what is your DE? how are you launching Cypress?
@flotwig I'm using i3, I opened inside the project folder on the terminal using the command: node_modules/.bin/cypress open
I spent some time today reproducing and debugging this issue.
The "crash" as it were would actually be fixed by upgrading to the upstream opn@6.0.0
library, However, instead of the Cypress application closing, there would be no visible error printed and no new window would open when "View App Data" is clicked.
I believe that the root cause of the issue, is that there is no browser installed on the reporter's machine. Anyone should be able to reproduce this problem simply by uninstalling Firefox, Chromium, Chrome, etc. from their minimal Linux system. There is a list of browsers checked for existence, which is defined in the local version of xdg-open provided by the opn
library.
@flotwig: I think the issue would be resolved by running pacman -Syu firefox
(assuming you are running Arch)
@viniciuspietscher: I think that you can not reproduce the issue because you do have one of the binaries referenced by xdg-open
.
I am not sure exactly what should be done with this bug, perhaps it would be nice to at least catch the exception and print out a usable error, i.e. "This feature requires a browser to be installed. We suggest installing x". I did notice that the version of opn
in use, is a fork that exists under the cypress-io organization, with some modifications for running on darwin. That may complicate upgrading to the latest upstream version of the library. @brian-mann may want to take a look, since he made some changes to your forked version.
In addition, the opn
library has been superceded by a new package called open
, and looking at its README, it mentions that there is an alternative that can be used if your app is running under Electron:
If you need this for Electron, use shell.openPath() instead.
Hope this helps resolve the issue somewhat. If anyone has suggestions on what could be done next to resolve the bug, let me know! Thanks.
Small update: it would also be helpful to update to a later version of the xdg-open script in general.
When testing this functionality under GNOME 3, I found that xdg-open is trying to execute gnome-open
which does not seem to be included in version 3. It looks as though gio open
is now the correct way to open a file browser according to the upstream source: https://cgit.freedesktop.org/xdg/xdg-utils/tree/scripts/xdg-open.in#n164
Thanks for spending time getting to the root of this issue @jonhermansen
I believe that the root cause of the issue, is that there is no browser installed on the reporter's machine.
Interesting, I did have Firefox (and others) in my path at the time that I encountered this. Why would it be related to browsers anyways?
There is a list of browsers checked for existence, which is defined in the local version of xdg-open provided by the opn library.
Electron also uses xdg-open
. Here's the relevant location in Electron where xdg-open
is run: https://github.com/electron/electron/blob/31c2b5703a75a5ff2bf0e68f472d9002fe866bfb/shell/common/platform_util_linux.cc#L265 I'm not totally sure if Electron bundles xdg-open
or if it uses the system's xdg-open
.
If you need this for Electron, use shell.openPath() instead.
Hope this helps resolve the issue somewhat. If anyone has suggestions on what could be done next to resolve the bug, let me know! Thanks.
We also use shell.openExternal()
elsewhere, I'm not sure why opn
was chosen for this use case. Best path forward would be to drop our usage of opn
and switch to shell.openPath()
like you say, I think.
If you want to open a PR to fix this and ping me for a review, that would be very welcome.
This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided.
Seeing this crash on Cypress 12.12.0 on Ubuntu 22.04. Browsers Chrome and Firefox are installed.
Exited with code 4
Error: Exited with code 4
at ChildProcess.<anonymous> (<embedded>:3139:421199)
at Object.onceWrapper (node:events:642:26)
at ChildProcess.emit (node:events:527:28)
at maybeClose (node:internal/child_process:1092:16)
at Socket.<anonymous> (node:internal/child_process:451:11)
at Socket.emit (node:events:527:28)
at Pipe.<anonymous> (node:net:709:12)
Seeing this crash on Cypress 12.12.0 on Ubuntu 22.04. Browsers Chrome and Firefox are installed.
Exited with code 4 Error: Exited with code 4 at ChildProcess.<anonymous> (<embedded>:3139:421199) at Object.onceWrapper (node:events:642:26) at ChildProcess.emit (node:events:527:28) at maybeClose (node:internal/child_process:1092:16) at Socket.<anonymous> (node:internal/child_process:451:11) at Socket.emit (node:events:527:28) at Pipe.<anonymous> (node:net:709:12)
@MikeMcC399 Can you check if your BROWSER/DISPLAY environment variables are set, and also if you have any of these executables in your PATH?
BROWSER=links2:elinks:links:lynx:w3m
if [ -n "$DISPLAY" ]; then
BROWSER=x-www-browser:firefox:seamonkey:mozilla:epiphany:konqueror:chromium-browser:google-chrome:$BROWSER
fi
The logic for how Cypress is attempting to pick a browser is here. Maybe something is off with your browsers command name. Or could be something else entirely. Its been a while since I looked at this issue.
Also, your terminal may have different environment variable values set than what is available to Cypress. Depends on how you are launching the Cypress UI.
I was able to reproduce on Ubuntu 22.04 and 23.04, however on Ubuntu 20.04 View App Data worked correctly.
I will do a clean install of Ubuntu 22.04 and see what happens there.
This issue is reproducible with Cypress 12.12.0 (Edit: also on 12.17.0) on a clean install of Ubuntu 22.04.2 LTS using Node.js 18.16.1.
Install Ubuntu 22.04.02 from iso on VMware Workstation.
Install prerequisites:
sudo apt install curl
sudo apt install make
sudo apt install git
curl -L https://bit.ly/n-install | bash
then
mkdir cy-view-app-data
cd cy-view-app-data
git init
npm init -y
npm install cypress@12.12.0 -D
npx cypress open
In Cypress desktop app Click on File > View App Data
which then crashes with the console output:
Exited with code 4
Error: Exited with code 4
at ChildProcess.<anonymous> (<embedded>:3139:421199)
at Object.onceWrapper (node:events:642:26)
at ChildProcess.emit (node:events:527:28)
at maybeClose (node:internal/child_process:1092:16)
at Socket.<anonymous> (node:internal/child_process:451:11)
at Socket.emit (node:events:527:28)
at Pipe.<anonymous> (node:net:709:12)
On Ubuntu it should be displaying the contents of ~/.config/Cypress/cy/production
Check with
ls -al ~/.config/Cypress/cy/production
nautilus ~/.config/Cypress/cy/production
@jonhermansen Thanks for your debugging steps! I would like to leave this now to the Cypress.io team to look at as I have not installed any additional browsers or modified any environment variables. The Cypress desktop app otherwise works correctly and is able to run tests in Electron and Firefox. Hopefully they will also be able to reproduce and fix the issue.
This issue remains unresolved in cypress@13.1.0
cypress@13.6.2
. The Cypress desktop app crashes using "View App Data" on Ubuntu 22.04
.
In Cypress desktop app (npx cypress open
)
Click on File > View App Data
console output stack trace for cypress@13.1.0
:
Exited with code 4
Error: Exited with code 4
at ChildProcess.<anonymous> (<embedded>:3180:421654)
at Object.onceWrapper (node:events:642:26)
at ChildProcess.emit (node:events:527:28)
at maybeClose (node:internal/child_process:1092:16)
at Socket.<anonymous> (node:internal/child_process:451:11)
at Socket.emit (node:events:527:28)
at Pipe.<anonymous> (node:net:709:12)
nautilus ~/.config/Cypress/cy/production
This issue remains unresolved in cypress@13.6.1
. The Cypress desktop app crashes using "View App Data" on Ubuntu 22.04
.
Cypress package version: 13.6.1
Cypress binary version: 13.6.1
Electron version: 25.8.4
Bundled Node version: 18.15.0
Done in 0.16s.
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.3 LTS
Release: 22.04
Codename: jammy
To reproduce:
Desired behavior: View App Data works, and errors with View App Data are gracefully handled.