yarnpkg / yarn

The 1.x line is frozen - features and bugfixes now happen on https://github.com/yarnpkg/berry
https://classic.yarnpkg.com
Other
41.45k stars 2.73k forks source link

Yarn does not always install all required dependencies when lock file is present #2595

Open robrichard opened 7 years ago

robrichard commented 7 years ago

Not sure if this is intended behavior, but it was confusing to me.

Steps to reproduce 1) I created a new project using yarn init, and answered with the defaults to each prompt. 2) Added two dependencies -- yarn add lodash.find -- yarn add lodash.get 3) Remove node modules rm -rf node_modules 4) yarn install 5) Manually remove one of the dependencies rm -rf node_modules/lodash.get 6) Running yarn install again says "Already up-to-date." and does not install the missing package

Expected behavior I would have expected yarn to install the missing lodash.get. We run yarn install on our CI server to run tests on pull requests before they are merged. If one branch causes a dependency to be removed, then another one requires it, yarn install will report success but the build will fail because required dependencies are not installed. I would expect yarn install to always deterministically ensure that every dependency is installed in node_modules

Please mention your node.js, yarn and operating system version. node v6.9.1, yarn v0.19.1, macOS 10.12.2

Contents of yarn.lock

# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1

lodash.find@^4.6.0:
  version "4.6.0"
  resolved "http://npm.intranet.1stdibs.com:4783/lodash.find/-/lodash.find-4.6.0.tgz#cb0704d47ab71789ffa0de8b97dd926fb88b13b1"

lodash.get@^4.4.2:
  version "4.4.2"
  resolved "http://npm.intranet.1stdibs.com:4783/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99"
IvanAlegre commented 7 years ago

@robrichard you could use --force

earnubs commented 7 years ago

@robrichard from https://github.com/yarnpkg/yarn/issues/2240#issuecomment-300762981 try yarn --check-integrity

Also, in the steps to reproduce before step 6 if you use yarn check you will get an error:

$ rm -rf node_modules/lodash.get
$ yarn check
yarn check v0.27.5
error "lodash.get" not installed
error Found 1 errors.
info Visit https://yarnpkg.com/en/docs/cli/check for documentation about this command.