Open ZachHandley opened 9 months ago
came here to say that I'm seeing the same thing with the same bun
version (1.0.22) as well every version back to and including 1.0.17--but in my case I tried to install newer versions of cypress
as well including 13.6.0 and 13.6.2 with no success.
bun version 1.0.16 doesn't exhibit these issues with the same two cypress 13.6.x versions mentioned above.
@ZachHandley I'm wondering if this is actually a bun issue perhaps. I had success in getting past this issue with using --ignore-scripts
on my bun install command in my Dockerfile. See https://github.com/oven-sh/bun/issues/7689
@ZachHandley
This is similar to issue https://github.com/cypress-io/cypress/issues/27997 where network security may be causing an issue in downloading Cypress. Edit: not relevant.
Note that there is no mention in the Cypress documentation that Bun is a supported environment. See System requirements. There was a request for Bun support in https://github.com/cypress-io/github-action/issues/585 for the Cypress GitHub Action. I haven't seen any request or plan for the core Cypress product to support Bun so far.
You may want to test installing using npm
instead. If it's a network security issue then I would expect you to see the same error.
@ZachHandley
This is similar to issue https://github.com/cypress-io/cypress/issues/27997 where network security may be causing an issue in downloading Cypress.
Note that there is no mention in the Cypress documentation that Bun is a supported environment. See System requirements. There was a request for Bun support in https://github.com/cypress-io/github-action/issues/585 for the Cypress GitHub Action. I haven't seen any request or plan for the core Cypress product to support Bun so far.
You may want to test installing using
npm
instead. If it's a network security issue then I would expect you to see the same error.
Unfortunately not, NPM worked fine, it usually makes it to 99% before failing and it usually seems like it's right around when it would begin executing an install script, so not sure.
But also I just want to say, I have 0 issues with any other packages using Bun so far, so support it or don't but this is almost definitely on Cypress or some weird interaction that shouldn't be happening
@ZachHandley
I can reproduce your error using the Bun Docker image oven/bun. This is an image based on linux-x64 (Debian - 11.8)
.
Running the following in the Docker container:
# bun add cypress -D --ignore-scripts
bun add v1.0.25 (a8ff7be6)
installed cypress@13.6.3 with binaries:
- cypress
1 package installed [2.85s]
then:
bun add cypress -D
export DEBUG=cypress:*
bun cypress install
showed the following debug log:
# bun cypress install
cypress:cli:cli cli starts with arguments ["/usr/local/bin/bun","/root/cy/node_modules/.bin/cypress","install"] +0ms
cypress:cli NODE_OPTIONS is not set +0ms
cypress:cli:cli program parsing arguments +5ms
cypress:cli parsed cli options {} +154ms
cypress:cli installing with options {} +0ms
cypress:cli detecting arch { osPlatform: 'linux', osArch: 'x64' } +2ms
cypress:cli arm uname -m result: { stdout: 'x86_64' } +22ms
cypress:cli version in package.json is 13.6.3, version to install is 13.6.3 +24ms
cypress:cli Reading binary package.json from: /root/.cache/Cypress/13.6.3/Cypress/resources/app/package.json +0ms
cypress:cli no binary installed under cli version +20ms
cypress:cli checking local file /13.6.3 cwd /root/cy +1ms
cypress:cli preparing to download and unzip version 13.6.3 to path /root/.cache/Cypress/13.6.3 +0ms
Installing Cypress (version: 13.6.3)
cypress:cli needed Cypress version: 13.6.3 +0ms
cypress:cli source url https://download.cypress.io/desktop/13.6.3?platform=linux&arch=x64 +1ms
cypress:cli downloading cypress.zip to "/tmp/cypress-64.zip" +0ms
cypress:cli Downloading package {
url: 'https://download.cypress.io/desktop/13.6.3?platform=linux&arch=x64',
proxy: null,
downloadDestination: '/tmp/cypress-64.zip'
} +1ms
cypress:cli expected file size 81 +413ms
cypress:cli redirect version: 13.6.3 +0ms
cypress:cli redirect url: https://cdn.cypress.io/desktop/13.6.3/linux-x64/cypress.zip +0ms
cypress:cli Downloading package {
url: 'https://cdn.cypress.io/desktop/13.6.3/linux-x64/cypress.zip',
proxy: null,
downloadDestination: '/tmp/cypress-64.zip'
} +0ms
cypress:cli expected checksum 1631654914f16e0b5b797d9e4ceae044d55fcbcca543222c721a5230c4cd4d2aaf1a16d316454e019b6e1861be19cfe3050ca5468c754ac898ec42e29fb008c4 +128ms
⠹ Downloading Cypress 100% 0s
cypress:cli downloading finished +22s
cypress:cli verifying checksum and file size +1ms
cypress:cli URL: https://download.cypress.io/desktop/13.6.3?platform=linux&arch=x64
✖ The Cypress App could not be downloaded.
Does your workplace require a proxy to be used to access the Internet? If so, you must configure the HTTP_PROXY en…
Otherwise, please check network connectivity and try again:
----------
URL: https://download.cypress.io/desktop/13.6.3?platform=linux&arch=x64
TypeError: undefined is not an object
----------
Platform: linux-x64 (Debian - 11.8)
Cypress Version: 13.6.3
The Cypress App could not be downloaded.
Does your workplace require a proxy to be used to access the Internet? If so, you must configure the HTTP_PROXY environment variable before downloading Cypress. Read more: https://on.cypress.io/proxy-configuration
Otherwise, please check network connectivity and try again:
----------
URL: https://download.cypress.io/desktop/13.6.3?platform=linux&arch=x64
TypeError: undefined is not an object
----------
Platform: linux-x64 (Debian - 11.8)
Cypress Version: 13.6.3
error: "cypress" exited with code 1
The error is:
TypeError: undefined is not an object
I can't say what the reason for this error is. I would guess that the Docker image oven/bun is missing some prerequisite that Cypress requires. Edit: see next comment.
Cypress provides compatible Docker images on the Docker Hub under cypress.
You may have more success if you use one of these Cypress Docker images as a base and install Bun on top. I have not tried this out myself. Edit: I can successfully run Cypress 13.6.3
natively under Ubuntu 22.04 using Bun 1.0.25
. I haven't been able to do this yet in Docker.
Please note that I am a community contributor not a Cypress.io employee, so I don't make statements on behalf of Cypress.io. Any statement about whether Cypress supports Bun or not would need to come from the Cypress.io team.
The Cypress installation documentation lists npm, Yarn and pnpm as installation tools. There is no mention anywhere in the Cypress documentation about using Bun and so you can assume that Cypress is not regularly tested against Bun in Cypress' CI/CD process.
@ZachHandley
The Docker image oven/bun does not include Node.js and this is required for a successful download of Cypress.
The documentation Installing Cypress > System requirements > Node.js implies this, although it is not specific to say that one of npm, Yarn or pnpm is required.
I can also reproduce this on Ubuntu with only Bun and no Node.js installed.
So the issue is that Cypress cannot be installed without Node.js. This would be a separate enhancement request to allow Cypress to be installed and run in a pure Bun environment with no Node.js present. It's also possible that this issue is a Bun bug, since Bun is advertised as a drop-in replacement for Node.js. Edit: The Bun / Node.js compatibility page shows multiple gaps in Bun's compatibility with Node.js.
Another enhancement request would be for Cypress Docker images to allow use with Bun.
I used cypress/factory to build a Docker image and run Cypress using Bun.
Dockerfile
contents:
ARG NODE_VERSION='20.11.0'
FROM cypress/factory
RUN npm install bun --global
COPY . /opt/app
WORKDIR /opt/app
RUN bun add cypress -D
It is not very elegant to have to use Node.js in parallel to Bun, and to install Bun with npm. This was just to show that it is possible. There is no claim that it is an optimal solution!
docker build . -t test
docker run -it test bun cypress run
Adding a note to the docs about Node.js being required: https://github.com/cypress-io/cypress-documentation/pull/5615
So my only issue with this is that Bun is meant to be a direct replacement of NPM. It quite literally works as a drop in replacement for me everywhere I go. Is there a specific thing that's causing this in Cypress? Bun has replacement features for almost everything, and it has node webserver and such built in, so can there be compatibility added? I'd be happy to peek at it.
@ZachHandley agreed with your point. However, in my own mind that seems to give more credence to what I was saying in my prior comment, which is that this is actually a bun issue since 1.0.017. See the link in my prior comment to the GitHub issue in Bun’s repo.
@ZachHandley agreed with your point. However, in my own mind that seems to give more credence to what I was saying in my prior comment, which is that this is actually a bun issue since 1.0.017. See the link in my prior comment to the GitHub issue in Bun’s repo.
For the record, my Dockerfile is actually not based on oven/bun
https://github.com/ZachHandley/invoiceninja/blob/v5-stable/Dockerfile I was running the Bun install script and then running those commands from an Ubuntu base image, but maybe you are correct. I see that issue, but it doesn't seem to point to anything specific, re2
and firebase
something?
Just trying to help InvoiceNinja out by dockerizing the application entirely with all deps
@jonnalley
However, in my own mind that seems to give more credence to what I was saying in my prior comment, which is that this is actually a bun issue since 1.0.017. See the link in my prior comment to the GitHub issue in Bun’s repo.
I don't believe this is the same as issue https://github.com/oven-sh/bun/issues/7689
The Cypress binary install can be started with bun cypress install
. Up until Bun 1.0.7
it fails with "The Dirent.name getter can only be used on instances of Dirent", from Bun 1.0.8
it fails with "TypeError: undefined is not an object". Perhaps somebody could pass this on to Bun as an issue, on the basis that Bun is supposed to be a drop-in replacement for Node.js? The repro steps are relatively short:
With no Node.js installed, execute the following:
bun init --yes
bun add cypress --save-dev --ignore-scripts
export DEBUG=cypress:*
bun cypress install
This fails with
TypeError: undefined is not an object
@ZachHandley
For the record, my Dockerfile is actually not based on
oven/bun
https://github.com/ZachHandley/invoiceninja/blob/v5-stable/Dockerfile I was running the Bun install script and then running those commands from an Ubuntu base image, but maybe you are correct.
An Ubuntu base image would not normally have Node.js installed by default.
In any case the environment to reproduce the issue is now clear (no Node.js installed) and it does not require Docker to reproduce.
The Bun / Node.js compatibility page says:
Bun aims for complete Node.js API compatibility. Most
npm
packages intended forNode.js
environments will work with Bun out of the box; the best way to know for certain is to try it.This page is updated regularly to reflect compatibility status of the latest version of Bun. The information below reflects Bun's compatibility with Node.js v20. If you run into any bugs with a particular package, please open an issue. Opening issues for compatibility bugs helps us prioritize what to work on next.
I don't normally use Bun, so I wouldn't want to open a Bun issue. Perhaps somebody who is interested in using Cypress with Bun could open a Bun issue, so that the compatibility is looked at? In the meantime you will need to have Node.js installed.
Edit: I didn't see any Bun user reporting the compatibility issue with the Cypress postinstallation script, and since I had already done the work to reproduce the issue, I decided after all to report it to Bun myself.
The comment (above) that Node.js is required still stands.
@ZachHandley
In https://github.com/cypress-io/cypress/issues/28722#issuecomment-1908494774 @jennifer-shehane clarified that Node.js is required to install Cypress and this is also now listed in the Cypress documentation under System requirements.
At this time, Bun has implemented only a subset of Node.js as listed on Bun > Node.js compatibility.
Attempting to download the Cypress binary fails with only Bun installed and no Node.js installed. This is the subject of this issue. It seems that the failure occurs when Cypress tries to verify the checksum of the downloaded cypress.zip
Cypress binary file. Although it is possible to work around this issue by downloading and unzipping the Cypress binary file into the Cypress cache by hand, this is not helpful overall because other incompatibilities still prevent Cypress from running. See issue https://github.com/cypress-io/cypress/issues/28962.
@ZachHandley
Please re-test as it seems that bun has resolved this issue in bun v1.1.8 which was released on May 10, 2024.
I tested yesterday both on windows and linux with bun v1.1.8 around 200 e2e tests with cypress. The UI is written with quasar dev framework (vue js based).
So from my point of view it works.
The command bun test
does not work but at this moment the flow described at my previous post is sufficient.
@dinuta
Thanks for the feedback from your tests which confirm that this issue could be closed!
The remaining support issues of Cypress running under Bun are covered in a separate issue https://github.com/cypress-io/cypress/issues/28962. The issue #28722 only covers installation of Cypress. It doesn't cover running Cypress under Bun.
Hi @MikeMcC399 ,
Seems like npm is still required, and this seems not a full support for cypress. Let me present you the Dockerfile I use:
FROM oven/bun:1.1.8-alpine
ENV APP_DIR /home/node/app
WORKDIR $APP_DIR
COPY ./ $APP_DIR
RUN apk add --update npm
RUN bun install --yarn
RUN bun install -g @quasar/cli
RUN quasar build
RUN chmod 744 /home/node/app/start.sh
ENTRYPOINT ["/home/node/app/start.sh"]
@dinuta
I'm having issues with this as well:
5.913 [SUCCESS] Downloaded Cypress
5.913 [STARTED] Task without title.
5.913
5.913 75 | };
5.913 76 | const unzipFallback = _.once(unzipWithNode);
5.913 77 | const unzipWithUnzipTool = () => {
5.913 78 | debug('unzipping via `unzip`');
5.913 79 | const inflatingRe = /inflating:/;
5.913 80 | const sp = cp.spawn('unzip', ['-o', zipFilePath, '-d', installDir]);
5.913 ^
5.913 TypeError: Executable not found in $PATH: "unzip"
5.913 code: "ERR_INVALID_ARG_TYPE"
5.913
5.913 at spawn (node:child_process:710:15)
5.913 at node:child_process:2:41
5.913 at unzipWithUnzipTool (/usr/src/app/node_modules/cypress/lib/tasks/unzip.js:80:22)
5.913 at /usr/src/app/node_modules/cypress/lib/tasks/unzip.js:147:20
5.913 at /usr/src/app/node_modules/yauzl/index.js:37:7
5.913 at /usr/src/app/node_modules/yauzl/index.js:141:16
5.913 at /usr/src/app/node_modules/yauzl/index.js:631:5
5.913 at /usr/src/app/node_modules/fd-slicer/index.js:32:7
5.913 at node:fs:294:107
5.913
Is unzip
part of node-js as well?
@hammzj
Which Docker image are you using?
To install the Cypress binary, Cypress can use unzip
from Debian / Ububtu. If you are using a Bun Docker image, then you would need to add the Debian / Ubuntu package unzip
using a Dockerfile
. This is however only helpful to test this issue. Currently Cypress does not run under Bun without Node.js, so even if you get the binary installed it still does not work. This is the subject of the open feature request https://github.com/cypress-io/cypress/issues/28962
Note that the Cypress Docker images provide all the prerequisites for installing and running Cypress in a Docker container. They are however configured with Node.js, so this is not a solution if the requirement is to run in an environment with no Node.js installed.
@MikeMcC399 Funny enough, we're not trying to use a Cypress image. Our issue is related to Bun installing Cypress unintentionally for our main app containers. Even though Cypress is an optional/dev dependency, it's still being installed as part of the web app container. Thus, we just need to get through unzipping Cypress so it doesn't fail when building images needed for our internal servers. I know there's likely two issues going on there that need some more investigation but we just want to get this working in the meantime. However, this seemed to work:
RUN apt-get update -y && apt-get upgrade -y RUN apt-get install -y unzip
I also looked at these images that bundle Bun and node together but we ran into separate issues there: https://github.com/ImBIOS/bun-node
@hammzj
Thanks for confirming that adding unzip
to your Docker image solves the installation issue!
I believe that it should be possible to close this issue now.
In my container installing unzip
also works for me with bun 1.1.8
This should probably be denoted somewhere in the Cypress docs if it makes sense.
@hammzj
This should probably be denoted somewhere in the Cypress docs if it makes sense.
You're free to make this suggestion in the https://github.com/cypress-io/cypress-documentation repo, however you should consider that Cypress does not support or document the use of Bun at this time.
The Cypress documentation lists Node.js as a prerequisite in the System requirements section and this is sufficient to install Cypress without unzip
being installed. What won't work is if neither unzip
nor Node.js
are installed.
Returning to this. So, I got it to work locally with bun, but the cypress.io GH Action will not work with bun.
There's no support in it for bun, so no matter what, this error will be given immediately if only bun install
is used:
Action failed. Missing package manager lockfile. Expecting one of package-lock.json (npm), pnpm-lock.yaml (pnpm) or yarn.lock (yarn) in working-directory ...
@hammzj
Nice! I didn't know about that @MikeMcC399 . Thanks for the information on that!
I suggest to close this issue, since there is nothing in Cypress preventing Cypress being installed in a Docker container with Bun.
If you use a Bun Docker container such as oven/bun:debian then you need to install the Debian package unzip
.
This is also the case for Cypress Docker images. See cypress-io/cypress-docker-images > factory/factory.Dockerfile which is used to build Cypress Docker images:
# Needed by cypress installation 'unzip.js' script
unzip
In this case the set of Dockerfile
commands to install Cypress will run successfully:
WORKDIR /opt/app
RUN bun init
RUN bun add cypress -D
RUN bun cypress install
RUN bun cypress verify
Note that this does not solve the separate issue of Cypress failing to run under Bun without Node.js. Bun would still need to fill the API gaps for this to work. (See https://bun.sh/docs/runtime/nodejs-apis for Bun's list of implemented, partially implemented and unimplemented Node.js methods.)
@hammzj
This should probably be denoted somewhere in the Cypress docs if it makes sense.
The Cypress documentation Getting Started > Installing Cypress > System requirements > Docker prerequisites has been updated to spell out the need for Node.js and the recommendation to install unzip
in any Docker image. Cypress Docker images already fulfil these requirements.
Thank you for your suggestion!
Current behavior
Setting up a Dockerfile, when running install it fails to download Cypress and I don't quite understand why, seems like a Cypress issue
Desired behavior
bun install --frozen-lockfile
should installTest code to reproduce
I'm attempting to build a Dockerfile for Invoice Ninja, and this is the relevant code
with the following for Cypress in the package.json
"cypress": "^12.5.1",
Cypress Version
12.8.1 was attempted install
Node version
Bun 1.0.22
Operating System
Docker
Debug Logs
No response
Other
No response