yarn icon indicating copy to clipboard operation
yarn copied to clipboard

Missing .yarn-integrity file on initial install

Open harmdewit opened this issue 4 years ago • 1 comments

Do you want to request a feature or report a bug?

bug

What is the current behavior? The first initial yarn install runs successfully but the yarn integrity file is missing. Running yarn install again does add the file.

The issue seems to happen when installing specific packages, one I've isolated is jest-when v2.7.0. Adding --verbose doesn't show any related info as far as I can see.

For CI environments or Docker builds it's very common to run yarn install once, so it often fails when later doing a yarn check later in the script.

If the current behavior is a bug, please provide the steps to reproduce.

package.json

{
  "name": "test",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "dependencies": {
    "jest-when": "^2.7.0"
  }
}

Dockerfile

FROM alpine:3.10 AS gemspec_files

WORKDIR /code

RUN apk add --no-cache \
      bash \
      curl \
      nodejs \
    && curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --rc \
    && cd /opt \
    && wget https://nightly.yarnpkg.com/latest.tar.gz \
    && tar zvxf latest.tar.gz

COPY package.json ./
RUN /opt/yarn-v1.18.0-20190901.1453/bin/yarn install
RUN test -f node_modules/.yarn-integrity
docker build -t yarn-test .
Sending build context to Docker daemon  13.73MB
Step 1/6 : FROM alpine:3.10 AS gemspec_files
 ---> 961769676411
Step 2/6 : WORKDIR /code
 ---> Using cache
 ---> f4dbd15c52e1
Step 3/6 : RUN apk add --no-cache       bash       curl       nodejs     && curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --rc     && cd /opt     && wget https://nightly.yarnpkg.com/latest.tar.gz     && tar zvxf latest.tar.gz
 ---> Using cache
 ---> 549604bf073c
Step 4/6 : COPY package.json ./
 ---> Using cache
 ---> bed807a06352
Step 5/6 : RUN /opt/yarn-v1.18.0-20190901.1453/bin/yarn install
 ---> Running in da1fa58152fa
yarn install v1.18.0-20190901.1453
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
info This package requires node-gyp, which is not currently installed. Yarn will attempt to automatically install it. If this fails, you can run "yarn global add node-gyp" to manually install it.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Installed "[email protected]" with binaries:
      - node-gyp
success Saved lockfile.
Done in 6.98s.
Removing intermediate container da1fa58152fa
 ---> c9cd308daf5a
Step 6/6 : RUN test -f node_modules/.yarn-integrity
 ---> Running in c28f53ca8a45
The command '/bin/sh -c test -f node_modules/.yarn-integrity' returned a non-zero code: 1

Changing /opt/yarn-v1.18.0-20190901.1453/bin/yarn install to /opt/yarn-v1.18.0-20190901.1453/bin/yarn install && /opt/yarn-v1.18.0-20190901.1453/bin/yarn install Does fix the issue.

What is the expected behavior?

I would expect node_modules/.yarn-integrity to exist after first yarn install, or raise an error to show why it didn't.

Please mention your node.js, yarn and operating system version.

  • Node 10.16.3
  • Yarn 1.18.0-20190901.1453
  • Alpine Linux 3.10.2
  • Docker version 19.03.2, build 6a30dfc

harmdewit avatar Sep 12 '19 20:09 harmdewit

I have same issue on yarn 1.22.19 with node 16. Seems related to https://github.com/yarnpkg/yarn/issues/3728 so that explicitly add node-gyp like RUN yarn global add node-gyp works around the issue.

babatakao avatar Aug 10 '22 02:08 babatakao