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 failed to use the correct git binary

See original GitHub issue

Some background, I’m using CentOS + Git 2.18 SCL, since lerna requires git --first-parent switch the vendor-provided git 1.8 does not have (#1726).

The bug is, even after git 2.18 has been enabled for the current shell, lerna keeps using the old 1.8.3 version. It seems to be a bug of execa@^1.0.0.

Expected Behavior

Git 2.18 is used, and no error is thrown.

Current Behavior

Git 1.8.3 is used, and the following error is thrown:

lerna ERR! Error: Command failed: git describe --always --long --dirty --first-parent --match v*.*.*
lerna ERR! error: unknown option `first-parent'

Possible Solution

Upgrade execa.

In the same directory lerna is setup (thus using execa@^1.0.0), the following script

const childProcess = require('child_process')
const execa = require('execa')
childProcess.exec('which git', (error, stdout, stderr) => console.log(stdout))
childProcess.exec('git --version', (error, stdout, stderr) => console.log(stdout))
execa('which', ['git']).then(({stdout}) => console.log(stdout))
execa('git', ['--version']).then(({stdout}) => console.log(stdout))

outputs

/opt/rh/rh-git218/root/usr/bin/git
git version 2.18.1
/usr/bin/git
git version 1.8.3.1

However, in a folder with the latest execa@^4.0.0 installed, the above script outputs:

/opt/rh/rh-git218/root/usr/bin/git
git version 2.18.1
/opt/rh/rh-git218/root/usr/bin/git
git version 2.18.1

Steps to Reproduce (for bugs)

  1. Set up and enable rh-git218 for current shell
  2. Run lerna publish --canary --preid rc --pre-dist-tag next
lerna.json

{
  "version": "0.1.0",
  "npmClient": "yarn",
  "command": {
    "publish": {
      "message": "chore(release): publish",
      "registry": "https://gitlab.com/api/v4/projects/12345678/packages/npm/"
    }
  },
  "useWorkspaces": true,
  "packages": [
    "packages/*"
  ]
}

Context

Your Environment

Executable Version
lerna --version 3.20.2
npm --version 6.13.6
yarn --version 1.21.1
node --version v10.18.1
OS Version
CentOS 7.7.1908

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
zypA13510commented, Feb 8, 2021

@MarcoEscaleira

What git version are you using ? Using git 2 or above solves this issue

The issue is not about git version, but when two different versions of git executable exist on the system, lerna failed to use the correct one (git 2 or above).

Like I said, upgrading the dependency to execa@^4.0.0 will solve this issue, which also proves it’s not a setup issue.

Btw, I’m not sure if things have changed since I opened this, I’m not using lerna anymore (mostly because of this issue).

0reactions
Tincolecommented, Oct 24, 2021

v4.0.0 is now available as lerna@next, which should resolve this issue. Please update if that’s not the case.

I have upgraded to V4.0.0, but I still get lerna ERR in gitlab CI! (Error: unknown option )How can I use commands to solve this problem? If the includeMergedTags are true, it will filter out --first-parent, but gitLab CI will still report the error @evocateur

Read more comments on GitHub >

github_iconTop Results From Across the Web

lerna publish on Jenkins "git remote update" Fails "Could not ...
I have been SSH'd into the machine via root and can view access. I am pulling the repo down with a user and...
Read more >
@lerna/symlink-binary | Yarn - Package Manager
BREAKING CHANGES. prompt: The ambiguous 'confirm', 'select', and 'input' exports have been removed. Please use the renamed exports 'promptConfirmation', ' ...
Read more >
How To Manage Monorepos With Lerna - DigitalOcean
Lerna is as a tool for managing JavaScript projects with multiple packages with features such as package bootstrapping, parallelized builds, ...
Read more >
Setting up a monorepo with Lerna for a TypeScript project
Lerna is a popular and widely used tool written in JavaScript for setting and managing multi-package repositories for Node.js projects with npm ...
Read more >
Git error - Fatal: Not a git repository and how to fix it | Datree.io
This error means you attempted to run a Git command, but weren't inside a Git repository. Make sure you've: Navigated to the right...
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