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 version from version lifecycle polluting global lerna execution

See original GitHub issue

Expected Behavior

lerna version would automatically commit the changes or at least complete correctly.

Current Behavior

Running lerna version does update the version in the package.json but then immediately complains about those changes are unstaged and exits.

lerna version
lerna notice cli v3.16.4
lerna info current version 1.1.3
lerna info Looking for changed packages since v1.0.3
? Select a new version (currently 1.1.3) Patch (1.1.4)

Changes:
 - @me/packageA: 1.1.3 => 1.1.4
 - @me/packageB: 1.1.3 => 1.1.4

? Are you sure you want to create these versions? Yes
lerna info execute Skipping releases
lerna info lifecycle root@1.1.3~version: root@1.1.3

> root@1.1.3 version /Users/iMightyJun/Projects/Mitosis
> lerna version

lerna notice cli v3.16.4
lerna info current version 1.1.4
lerna info Looking for changed packages since v1.0.3
lerna ERR! EUNCOMMIT Working tree has uncommitted changes, please commit or remove the following changes before continuing:
lerna ERR! EUNCOMMIT  M lerna.json
lerna ERR! EUNCOMMIT  M packages/packageA/package.json
lerna ERR! EUNCOMMIT  M packages/packageB/package.json
lerna info lifecycle root@1.1.3~version: Failed to exec version script
lerna ERR! lifecycle "version" errored in "root", exiting 1

Possible Solution

lerna version should recognize it made those package.json changes and either stage these commits automatically or exit gracefully.

Steps to Reproduce (for bugs)

  1. run lerna version
  2. type yes
lerna.json

{
  "version": "1.1.4",
  "npmClient": "yarn",
  "useWorkspaces": true,
  "command": {
    "publish": {
      "message": "chore(release): publish %s"
    },
    "version": {
      "allowBranch": "master",
      "message": "chore(release): %s"
    },
    "run": {
      "npmClient": "yarn"
    }
  },
  "packages": [
    "packages/*"
  ]
}

lerna-debug.log

<!-- If you have a `lerna-debug.log` available, please paste it here -->
<!-- Otherwise, feel free to delete this <details> block -->

Context

Your Environment

Executable Version
lerna --version v3.16.4
npm --version 6.9.0
yarn --version 1.17.0
node --version v10.16.0

| OS | Version | | macOS Mojave| 10.14.5 | | NAME | VERSION |

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:2
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

23reactions
evocateurcommented, Oct 8, 2019

but the underlying problem is

You’re running lerna version with a version lifecycle in the root package.json. Don’t do that, and you’ll avoid this error.

In general, you should not name the scripts that you call lerna commands from (in the root package.json) “publish” or “version”, as these are significant names in npm-land.

I thought https://github.com/lerna/lerna/commit/089392d242b6326f4865f81a8083ea858ed4091b would have fixed this, but I guess I failed to account for folks who call lerna globally. PRs welcome.

3reactions
kkataevcommented, Sep 11, 2019

This issue just appeared on mac after reinstall lerna. Please, help)

Executable Version
lerna --version v3.16.4
npm --version 6.10.3
node --version 10.16.3
Read more comments on GitHub >

github_iconTop Results From Across the Web

Lerna version from version lifecycle polluting global lerna ...
Expected Behavior. lerna version would automatically commit the changes or at least complete correctly. Current Behavior.
Read more >
@lerna/version - npm
Prompts for a new version. Modifies package metadata to reflect new release, running appropriate lifecycle scripts in root and per-package.
Read more >
Version and Publish - Lerna
Lerna can increment your package's versions as well as publish your packages to NPM, and it provides a variety of options to make...
Read more >
@lerna/version | Yarn - Package Manager
0 (2022-12-26). Features. version: support custom command for git tag (#2760 (6eac92f); version: use npmClientArgs in npm install after lerna ...
Read more >
Untitled
```sh $ npm install --global lerna ``` Next we'll create a new folder: ```sh ... The version is kept in the `lerna.json` file...
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