question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

lerna changed returns ambiguous code

See original GitHub issue

In our continuous integration pipeline we use lerna changed --include-merged-tags --loglevel=silent --json to collect changed packages for the next step. When there are no changes, this command fails with a return code of 1 and an empty result. In this case we still want to go on executing the build process. However, lately there was an invalid package.json file in one of the packages. Turns out lerna returns the same result (error code 1, empty result) in this case, too. This caused a faulty build. As a user, it would be really helpful to be able to distinguish between response being “no changes” or “invalid files”, for example, based on the response code. Our current workaround is to do a lerna list first, that fails only when there are invalid files.

Expected Behavior

lerna changed returns a different code for no changes, and for errors

Current Behavior

lerna changed returns the same error response in both scenarios

Possible Solution

Return a different response code for these cases.

Steps to Reproduce (for bugs)

  • run lerna changed --include-merged-tags --loglevel=silent --json with a broken package.json in one of the projects (make the json invalid)
  • run it without changes in the projects
  • compared outputs are the same
lerna.json

{
  "lerna": "3.0.0",
  "packages": [
    "packages/*"
  ],
  "version": "independent",
  "command": {
    "publish": {
      "ignoreChanges": [
        "**/package-lock.json"
      ],
      "registry": "https://artifactory-us.prezi.com/api/npm/npm/",
      "bump": "patch"
    }
  }
}

lerna-debug.log

0 silly argv { _: [ 'changed' ],
0 silly argv   'include-merged-tags': true,
0 silly argv   includeMergedTags: true,
0 silly argv   loglevel: 'silent',
0 silly argv   json: true,
0 silly argv   composed: 'changed',
0 silly argv   lernaVersion: '3.4.2',
0 silly argv   '$0': 'node_modules/.bin/lerna' }
1 notice cli v3.4.2
2 verbose rootPath /Users/csuvikg/projects/frontend-packages
3 info versioning independent
4 error JSONError: Unexpected string in JSON at position 2790 while parsing '{  "name": "@prezi/viewer-lite",  "ver' in packages/viewer-lite/package.json
4 error     at module.exports (/Users/csuvikg/projects/frontend-packages/node_modules/parse-json/index.js:26:19)
4 error     at parse (/Users/csuvikg/projects/frontend-packages/node_modules/load-json-file/index.js:8:29)

Context

Your Environment

Executable Version
lerna --version 3.4.2
npm --version 6.4.1
yarn --version 1.15.2
node --version v10.10.0
OS Version
macOS Mojave 10.14.5

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
QuestionAndAnswercommented, May 7, 2020

Agree with @endreymarcell as I’m facing the same issue. lerna changed is trying to detect changes and the response might be list of changed packages, and it’s should be acceptablet to have empty list, but this should be list anyway. And from program execution standpoint - program completed correctly and expects such conditions, so nothing prevent’s it from functioning correctly, therefore there shouldn’t be any error code emit. Meanwhile broken packages or anything that potentially breaks following program execution reasonable to throw and return error code.

0reactions
github-actions[bot]commented, Jun 17, 2022

Hi Folks 👋

You will have seen in our message above that we at Nrwl are working really hard to bring the lerna repo up to date with what matters most to its community in June 2022.

As previously stated in that message, because we have not heard from the original author of this issue within the last 14 days, we are now automatically closing it.

If any users, including the original author, are still impacted by this issue then we still want to hear from you!

All we ask is that you first update to the latest lerna (5.1.4 at the time of writing) to make sure it is still reproducible, and then fill out one of our new issue templates, providing all the requested details which apply to your situation:

https://github.com/lerna/lerna/issues/new/choose

Many thanks again! 🙏


P.S. Over and above getting to grips with the repo, we have also been hard at work launching a new website, resolving all vulnerabilities, merging exciting new features and reigniting community PR contributions! 🚀

You can read our recent blog post to learn more about what we’ve been up to: https://blog.nrwl.io/lerna-5-1-new-website-new-guides-new-lerna-example-repo-distributed-caching-support-and-speed-64d66410bec7

Read more comments on GitHub >

github_iconTop Results From Across the Web

lerna changed returns ambiguous code - - Bountysource
When there are no changes, this command fails with a return code of 1 and an empty result. In this case we still...
Read more >
Troubleshooting | Lerna
Failing when git tree has uncommitted changes​. You will receive fatal: ambiguous argument 'HEAD': error, when the current project has uncommitted changes.
Read more >
lerna import always returns EDESTDIR - Stack Overflow
I have a pre-existing project that I'd like to import into my existing lerna monorepo that uses yarn workspaces.
Read more >
@lerna/changed | Yarn - Package Manager
When you run the new command lerna repair , lerna will execute a series of code migrations/codemods which update your workspace to the...
Read more >
@lerna/changed - npm
Install lerna for access to the lerna CLI. Usage. The output of lerna changed is a list of packages that would be the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found