Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lerna publish:Error: Command failed: git rev-parse --abbrev-ref HEAD fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree. #763

Closed
Vincent2015 opened this issue Apr 14, 2017 · 12 comments · Fixed by #1432

Comments

@Vincent2015
Copy link

bogon:lerandemo qiupengchao$ lerna publish
Lerna v2.0.0-rc.1
Current version: 1.1.1
Checking for updated packages...
No tags found! Comparing with initial commit.
? Select a new version (currently 1.1.1) Minor (1.2.0)

Changes:

  • aa: 1.1.1 => 1.2.0

? Are you sure you want to publish the above changes? Yes
fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git [...] -- [...]'
GitUtilities.getCurrentBranch ({"cwd":"."})
Error: Command failed: git rev-parse --abbrev-ref HEAD
fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git [...] -- [...]'

at checkExecSyncError (child_process.js:483:13)
at Object.execSync (child_process.js:523:13)
at Function.execSync (/Users/qiupengchao/.nvm/versions/node/v6.9.5/lib/node_modules/lerna/lib/ChildProcessUtilities.js:68:44)
at getCurrentBranch (/Users/qiupengchao/.nvm/versions/node/v6.9.5/lib/node_modules/lerna/lib/GitUtilities.js:148:46)
at Function.descriptor.value (/Users/qiupengchao/.nvm/versions/node/v6.9.5/lib/node_modules/lerna/lib/logger.js:146:33)
at isDetachedHead (/Users/qiupengchao/.nvm/versions/node/v6.9.5/lib/node_modules/lerna/lib/GitUtilities.js:65:37)
at Function.descriptor.value (/Users/qiupengchao/.nvm/versions/node/v6.9.5/lib/node_modules/lerna/lib/logger.js:146:33)
at PublishCommand.execute (/Users/qiupengchao/.nvm/versions/node/v6.9.5/lib/node_modules/lerna/lib/commands/PublishCommand.js:167:55)
at PublishCommand._attempt (/Users/qiupengchao/.nvm/versions/node/v6.9.5/lib/node_modules/lerna/lib/Command.js:219:21)
at /Users/qiupengchao/.nvm/versions/node/v6.9.5/lib/node_modules/lerna/lib/Command.js:204:15

GitUtilities.isDetachedHead ({"cwd":"."})
Error: Command failed: git rev-parse --abbrev-ref HEAD
fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git [...] -- [...]'

at checkExecSyncError (child_process.js:483:13)
at Object.execSync (child_process.js:523:13)
at Function.execSync (/Users/qiupengchao/.nvm/versions/node/v6.9.5/lib/node_modules/lerna/lib/ChildProcessUtilities.js:68:44)
at getCurrentBranch (/Users/qiupengchao/.nvm/versions/node/v6.9.5/lib/node_modules/lerna/lib/GitUtilities.js:148:46)
at Function.descriptor.value (/Users/qiupengchao/.nvm/versions/node/v6.9.5/lib/node_modules/lerna/lib/logger.js:146:33)
at isDetachedHead (/Users/qiupengchao/.nvm/versions/node/v6.9.5/lib/node_modules/lerna/lib/GitUtilities.js:65:37)
at Function.descriptor.value (/Users/qiupengchao/.nvm/versions/node/v6.9.5/lib/node_modules/lerna/lib/logger.js:146:33)
at PublishCommand.execute (/Users/qiupengchao/.nvm/versions/node/v6.9.5/lib/node_modules/lerna/lib/commands/PublishCommand.js:167:55)
at PublishCommand._attempt (/Users/qiupengchao/.nvm/versions/node/v6.9.5/lib/node_modules/lerna/lib/Command.js:219:21)
at /Users/qiupengchao/.nvm/versions/node/v6.9.5/lib/node_modules/lerna/lib/Command.js:204:15

Errored while running PublishCommand.execute
Error: Command failed: git rev-parse --abbrev-ref HEAD
fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git [...] -- [...]'

at checkExecSyncError (child_process.js:483:13)
at Object.execSync (child_process.js:523:13)
at Function.execSync (/Users/qiupengchao/.nvm/versions/node/v6.9.5/lib/node_modules/lerna/lib/ChildProcessUtilities.js:68:44)
at getCurrentBranch (/Users/qiupengchao/.nvm/versions/node/v6.9.5/lib/node_modules/lerna/lib/GitUtilities.js:148:46)
at Function.descriptor.value (/Users/qiupengchao/.nvm/versions/node/v6.9.5/lib/node_modules/lerna/lib/logger.js:146:33)
at isDetachedHead (/Users/qiupengchao/.nvm/versions/node/v6.9.5/lib/node_modules/lerna/lib/GitUtilities.js:65:37)
at Function.descriptor.value (/Users/qiupengchao/.nvm/versions/node/v6.9.5/lib/node_modules/lerna/lib/logger.js:146:33)
at PublishCommand.execute (/Users/qiupengchao/.nvm/versions/node/v6.9.5/lib/node_modules/lerna/lib/commands/PublishCommand.js:167:55)
at PublishCommand._attempt (/Users/qiupengchao/.nvm/versions/node/v6.9.5/lib/node_modules/lerna/lib/Command.js:219:21)
at /Users/qiupengchao/.nvm/versions/node/v6.9.5/lib/node_modules/lerna/lib/Command.js:204:15
@evocateur
Copy link
Member

Please use the issue template: https://raw.githubusercontent.com/lerna/lerna/master/.github/ISSUE_TEMPLATE.md

In this case, git --version would also be appropriate.

@Vincent2015
Copy link
Author

bogon:lerandemo qiupengchao$ git --version
git version 2.10.1 (Apple Git-78)
bogon:lerandemo qiupengchao$

@otbe
Copy link

otbe commented Apr 28, 2017

Same issue here. Fails with:

lerna info version 2.0.0-rc.4
lerna ERR! initialize Error: fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
lerna ERR! initialize Use '--' to separate paths from revisions, like this:
lerna ERR! initialize 'git <command> [<revision>...] -- [<file>...]'
lerna ERR! initialize
lerna ERR! initialize     at Function.module.exports.sync (/Users/boo/.nvm/versions/node/v7.7.2/lib/node_modules/lerna/node_modules/execa/index.js:277:26)
lerna ERR! initialize     at Function.execSync (/Users/boo/.nvm/versions/node/v7.7.2/lib/node_modules/lerna/lib/ChildProcessUtilities.js:51:30)
lerna ERR! initialize     at Function.getCurrentSHA (/Users/boo/.nvm/versions/node/v7.7.2/lib/node_modules/lerna/lib/GitUtilities.js:193:49)
lerna ERR! initialize     at ImportCommand.initialize (/Users/boo/.nvm/versions/node/v7.7.2/lib/node_modules/lerna/lib/commands/ImportCommand.js:136:51)
lerna ERR! initialize     at ImportCommand._attempt (/Users/boo/.nvm/versions/node/v7.7.2/lib/node_modules/lerna/lib/Command.js:265:21)
lerna ERR! initialize     at ImportCommand.runCommand (/Users/boo/.nvm/versions/node/v7.7.2/lib/node_modules/lerna/lib/Command.js:251:12)
lerna ERR! initialize     at ImportCommand.run (/Users/boo/.nvm/versions/node/v7.7.2/lib/node_modules/lerna/lib/Command.js:148:12)
lerna ERR! initialize     at Object.handler (/Users/boo/.nvm/versions/node/v7.7.2/lib/node_modules/lerna/lib/commands/ImportCommand.js:53:53)
lerna ERR! initialize     at Object.self.runCommand (/Users/boo/.nvm/versions/node/v7.7.2/lib/node_modules/lerna/node_modules/yargs/lib/command.js:231:22)
git version 2.11.0 (Apple Git-81)

Im using 2.0.0-rc.4 right now on a new created (lerna init) test repo.

@devmao
Copy link

devmao commented May 11, 2017

OS: Ubuntu 16.04 LTS
Git: 2.7.4 and 2.11.0
Lerna: 2.0.0-rc.4

/lerna-repo:$ lerna import ../pippo/

lerna info version 2.0.0-rc.4
lerna info versioning independent
lerna ERR! initialize Error: fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
lerna ERR! initialize Use '--' to separate paths from revisions, like this:
lerna ERR! initialize 'git <command> [<revision>...] -- [<file>...]'
lerna ERR! initialize 
lerna ERR! initialize     at Function.module.exports.sync (/home/mao/.nvm/versions/node/v6.10.1/lib/node_modules/lerna/node_modules/execa/index.js:277:26)
lerna ERR! initialize     at Function.execSync (/home/mao/.nvm/versions/node/v6.10.1/lib/node_modules/lerna/lib/ChildProcessUtilities.js:51:30)
lerna ERR! initialize     at Function.getCurrentSHA (/home/mao/.nvm/versions/node/v6.10.1/lib/node_modules/lerna/lib/GitUtilities.js:193:49)
lerna ERR! initialize     at ImportCommand.initialize (/home/mao/.nvm/versions/node/v6.10.1/lib/node_modules/lerna/lib/commands/ImportCommand.js:136:51)
lerna ERR! initialize     at ImportCommand._attempt (/home/mao/.nvm/versions/node/v6.10.1/lib/node_modules/lerna/lib/Command.js:265:21)
lerna ERR! initialize     at ImportCommand.runCommand (/home/mao/.nvm/versions/node/v6.10.1/lib/node_modules/lerna/lib/Command.js:251:12)
lerna ERR! initialize     at ImportCommand.run (/home/mao/.nvm/versions/node/v6.10.1/lib/node_modules/lerna/lib/Command.js:148:12)
lerna ERR! initialize     at Object.handler (/home/mao/.nvm/versions/node/v6.10.1/lib/node_modules/lerna/lib/commands/ImportCommand.js:53:53)
lerna ERR! initialize     at Object.self.runCommand (/home/mao/.nvm/versions/node/v6.10.1/lib/node_modules/lerna/node_modules/yargs/lib/command.js:231:22)
lerna ERR! initialize     at Object.Yargs.self._parseArgs (/home/mao/.nvm/versions/node/v6.10.1/lib/node_modules/lerna/node_modules/yargs/yargs.js:990:30)
lerna ERR! initialize  caught error
lerna ERR! initialize  Error: fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
lerna ERR! initialize Use '--' to separate paths from revisions, like this:
lerna ERR! initialize 'git <command> [<revision>...] -- [<file>...]'
lerna ERR! initialize 
lerna ERR! initialize     at Function.module.exports.sync (/home/mao/.nvm/versions/node/v6.10.1/lib/node_modules/lerna/node_modules/execa/index.js:277:26)
lerna ERR! initialize     at Function.execSync (/home/mao/.nvm/versions/node/v6.10.1/lib/node_modules/lerna/lib/ChildProcessUtilities.js:51:30)
lerna ERR! initialize     at Function.getCurrentSHA (/home/mao/.nvm/versions/node/v6.10.1/lib/node_modules/lerna/lib/GitUtilities.js:193:49)
lerna ERR! initialize     at ImportCommand.initialize (/home/mao/.nvm/versions/node/v6.10.1/lib/node_modules/lerna/lib/commands/ImportCommand.js:136:51)
lerna ERR! initialize     at ImportCommand._attempt (/home/mao/.nvm/versions/node/v6.10.1/lib/node_modules/lerna/lib/Command.js:265:21)
lerna ERR! initialize     at ImportCommand.runCommand (/home/mao/.nvm/versions/node/v6.10.1/lib/node_modules/lerna/lib/Command.js:251:12)
lerna ERR! initialize     at ImportCommand.run (/home/mao/.nvm/versions/node/v6.10.1/lib/node_modules/lerna/lib/Command.js:148:12)
lerna ERR! initialize     at Object.handler (/home/mao/.nvm/versions/node/v6.10.1/lib/node_modules/lerna/lib/commands/ImportCommand.js:53:53)
lerna ERR! initialize     at Object.self.runCommand (/home/mao/.nvm/versions/node/v6.10.1/lib/node_modules/lerna/node_modules/yargs/lib/command.js:231:22)
lerna ERR! initialize     at Object.Yargs.self._parseArgs (/home/mao/.nvm/versions/node/v6.10.1/lib/node_modules/lerna/node_modules/yargs/yargs.js:990:30)

@otbe
Copy link

otbe commented May 11, 2017

@devmao
I guess you have to pass a file system path not a remote URL. So try to clone the repo and use this path :)

@devmao
Copy link

devmao commented May 11, 2017

@otbe same issue with a path, relative or absolute.

@iyobo
Copy link

iyobo commented May 16, 2017

Same issue here with lerna import. Unable to work around it.
Seems to be a git problem though, because git show HEAD throws same error in git.

git version 2.11.0 (Apple Git-81)

@iyobo
Copy link

iyobo commented May 16, 2017

Okay looks like I found a fix for this.
This issue only comes up when I try to lerna import into a lerna repo with uncommited changes.

Commit all changes in your monorepo and have a clean tree before attempting to import another package and it's git history. I suppose it makes sense :)

@evocateur
Copy link
Member

evocateur commented May 16, 2017 via email

@devmao
Copy link

devmao commented May 16, 2017

@iyobo yes, it's the solution for me too.
lerna really need to provide some sort of checking for these trivial mistakes to report useful error messages.

thetutlage added a commit to thetutlage/lerna that referenced this issue May 21, 2018
Lerna throws a Git error when current project has uncommitted changes.

fixes: lerna#763
evocateur pushed a commit that referenced this issue May 24, 2018
Lerna throws a Git error when current project has uncommitted changes.

Fixes #763

[ci skip]
@MillerGregor
Copy link

fyi...

you'll also get this error when trying to lerna version a branch that has no upstream

I wouldn't consider this a bug, as it's only likely to be encountered while testing

@lock
Copy link

lock bot commented Dec 27, 2018

This thread has been automatically locked because there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Dec 27, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants