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

Docker image cypress/factory does not support Yarn 3 #882

Open
Joelasaur opened this issue Apr 19, 2023 · 6 comments
Open

Docker image cypress/factory does not support Yarn 3 #882

Joelasaur opened this issue Apr 19, 2023 · 6 comments

Comments

@Joelasaur
Copy link

Current Behavior

Cypress factory fails to install Yarn 3.

+ curl -fsSLO --compressed https://yarnpkg.com/downloads/3.5.0/yarn-v3.5.0.tar.gz
curl: (22) The requested URL returned error: 404 
child process exited with code 22
The command '/bin/sh -c node /opt/installScripts/yarn/install-yarn-version.js ${YARN_VERSION}' returned a non-zero code: 22

Desired Behavior

We should be able to specify Yarn berry in the build args.

Test code to reproduce

Create a dockerfile like so

ARG CHROME_VERSION='107.0.5304.121-1'
ARG CYPRESS_VERSION='12.5.1'
ARG YARN_VERSION='3.5.0'

FROM cypress/factory

WORKDIR /app

COPY package.json ./
COPY .yarn/cache ./.yarn/cache
COPY .yarn/plugins ./.yarn/plugins
COPY .yarn/releases ./.yarn/releases
COPY .yarnrc.yml ./
COPY yarn.lock ./

RUN yarn install

Workaround

Current workaround is to specify Yarn 1 in the build arg, but then add a run step to set the version to Yarn 3 like so:

ARG CHROME_VERSION='107.0.5304.121-1'
ARG CYPRESS_VERSION='12.5.1'
ARG YARN_VERSION='1.22.19'

FROM cypress/factory

WORKDIR /app

COPY package.json ./
COPY .yarn/cache ./.yarn/cache
COPY .yarn/plugins ./.yarn/plugins
COPY .yarn/releases ./.yarn/releases
COPY .yarnrc.yml ./
COPY yarn.lock ./

# Upgrade to yarn 3 here:
RUN yarn set version berry
RUN yarn install
@mjhenkes
Copy link
Member

We currently only support yarn v1 in the docker factory. I think we could update the install script to support higher versions of yarn.

@mjhenkes mjhenkes removed their assignment Apr 20, 2023
@Joelasaur
Copy link
Author

Joelasaur commented Apr 20, 2023

We currently only support yarn v1 in the docker factory. I think we could update the install script to support higher versions of yarn.

This would be awesome! And since we are talking about Yarn 3 support, figured I'd mention this other relevant issue here, since it most likely has to do with Cypress not finding Typescript in the cypress/factory image while using Yarn 3.

This is my .yarnrc.yaml file, which as you can see is using the nodeLinker: node-modules fix which is working on my local machine, just not in the cypress factory image:

enableScripts: true

nodeLinker: node-modules

npmScopes:
  updater:
    npmAlwaysAuth: true
    npmAuthToken: "${GH_REGISTRY_TOKEN}"
    npmRegistryServer: "https://npm.pkg.github.com"

plugins:
  - path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
    spec: "@yarnpkg/plugin-interactive-tools"

supportedArchitectures:
  cpu:
    - x64
    - arm64
  libc:
    - glibc
  os:
    - darwin
    - linux

yarnPath: .yarn/releases/yarn-3.5.0.cjs

edit (fixed)

ignore this comment, it wasn't an issue with Yarn 3, I was just building and running my images incorrectly

@anishpb97
Copy link

We currently only support yarn v1 in the docker factory. I think we could update the install script to support higher versions of yarn.

Hey seems like the curl install script of Yarn might not support Yarn 2.x and 3.x.
I found this thread regarding the same. I would like to discuss futher on handling Yarn installation on these version and hopefully to contribute on them

@anishpb97
Copy link

@mjhenkes can I work on this?

@mjhenkes
Copy link
Member

mjhenkes commented Jun 1, 2023

@anishpb97, Sure! (sorry for the delay)

@MikeMcC399
Copy link
Collaborator

@Joelasaur

Yarn Modern recommends installing using corepack, however this technology is still experimental and not suitable for production use, according to the Node.js documentation for corepack.

The workaround you described to install Yarn Modern using Yarn v1 Classic is for the moment the way that Cypress Docker images can support with good conscience. This can change, if/when Yarn and Node.js are able to recommended corepack for production use.

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants