Yarn: Error in yarn install --frozen-lockfile should result in non-zero exit code

Created on 24 Jan 2017  ยท  6Comments  ยท  Source: yarnpkg/yarn

Do you want to request a feature or report a bug?
I'd consider this a behavior change or bug.

What is the current behavior?
When I run yarn install --frozen-lockfile with an out-of-date lockfile, I get an error message after the "Resolving packages" step. Then I get an exit code of 0, indicating success.

As a consequence of this, our CI system does not fail the build when the package.json file has been changed but the yarn.lock file has not been updated accordingly.

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

  1. Check out the yarn repository at commit 93fa0f7c2857b5e9301d554b2b4c362d20988324
  2. Remove all local files if necessary (i.e. git clean -xdf)
  3. yarn install
  4. Update the chalk dependency in package.json from "^1.1.1" to "^1.1.2"
  5. yarn install --frozen-lockfile
  6. echo $? to check that the exit code is 0

What is the expected behavior?
Whenever I run yarn install --frozen-lockfile and get an error message due to the lockfile being out-of-date, I get a non-zero error code.

Please mention your node.js, yarn and operating system version.
Node: v6.2.2
Yarn: 0.19.1
Operating system: Mac OS X 10.11.6

All 6 comments

Bash workaround:

set -o pipefail
yarn_output=$(yarn install --frozen-lockfile 2>&1 | tee /dev/tty)
if (echo "$yarn_output" | grep -q 'error.*frozen-lockfile'); then # work around https://github.com/yarnpkg/yarn/issues/2538
  exit 1
fi

@john-kurkowski Total nerd snipe...

Given that the frozen lockfile setting appears to specifically be for CI servers, this seems to be a pretty big shortcoming.

Sorry for that. When I implemented the feature, I assumed, incorrectly, that reporter.error would cause the process to exit with non-zero. But, that is apparently not so. The PR above should fix this.

This seems to be a regression in 0.23.2 - can anyone confirm?:

$ git co yarn.lock
$ yarn install --frozen-lockfile
yarn install v0.23.2
[1/4] ๐Ÿ”  Resolving packages...
warning Integrity check: Lock files don't match
[2/4] ๐Ÿšš  Fetching packages...
[3/4] ๐Ÿ”—  Linking dependencies...
[4/4] ๐Ÿ“ƒ  Building fresh packages...
success Saved lockfile.
โœจ  Done in 6.76s.
$ echo $?
0

Update: seems to be a regression: https://gist.github.com/joscha/9079e5853bce79ee5de2d081188b10b8

Yes, looks like a regression

Was this page helpful?
0 / 5 - 0 ratings