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

Cache causes dune build to fail when HEAD doesn't exist #4429

Closed
craigfe opened this issue Mar 31, 2021 · 4 comments
Closed

Cache causes dune build to fail when HEAD doesn't exist #4429

craigfe opened this issue Mar 31, 2021 · 4 comments
Assignees
Milestone

Comments

@craigfe
Copy link
Contributor

craigfe commented Mar 31, 2021

The Dune cache uses Vcs.commit_id as an input to the Dune cache here. Unfortunately, this commit ID might not always exist: when using Git, HEAD doesn't exist in commit-less repositories:

  $ git init

  Initialized empty Git repository in $TESTCASE_ROOT/.git/

  $ $ dune subst 2>&1 | sed 's/\/tmp\/.*.output/<tmp_file>/g'
           git (internal) (exit 128)
  /usr/bin/git describe --always --dirty > <tmp_file>
  fatal: bad revision 'HEAD'
           git (internal) (exit 128)
  /usr/bin/git rev-parse HEAD > <tmp_file>
  fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
  Use '--' to separate paths from revisions, like this:
  'git <command> [<revision>...] -- [<file>...]'
           git (internal) (exit 128)
  /usr/bin/git ls-tree -r --name-only HEAD > <tmp_file>
  fatal: Not a valid object name HEAD

As of today, this is also triggerable via dune build with the cache enabled:

  $ DUNE_CACHE=enabled dune build

           git (internal) (exit 128)
  /usr/bin/git rev-parse HEAD > /tmp/buildd528b2.dune/dune6c093a.output
  fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
  Use '--' to separate paths from revisions, like this:
  'git <command> [<revision>...] -- [<file>...]'
  [1]

As discussed in #4430, the latter case is going away for unrelated reasons.

Obviously only a tiny problem, but seemed worth a bug report.

Reproduction

See #4430.

craigfe added a commit to craigfe/dune that referenced this issue Mar 31, 2021
craigfe added a commit to craigfe/dune that referenced this issue Apr 1, 2021
ghost pushed a commit that referenced this issue Apr 1, 2021
Signed-off-by: Craig Ferguson <[email protected]>
Signed-off-by: Jeremie Dimino <[email protected]>
@emillon
Copy link
Collaborator

emillon commented Apr 1, 2021

Duplicate of #3619

@emillon emillon marked this as a duplicate of #3619 Apr 1, 2021
@emillon
Copy link
Collaborator

emillon commented Apr 1, 2021

Thanks for the report! I found that before but it seemed innocuous - the fact that it can be triggered through the cache makes it a bit more important.

@craigfe
Copy link
Contributor Author

craigfe commented Apr 1, 2021

Ah, apologies for the duplicate; should have looked a bit more closely.

As @jeremiedimino and @snowleopard point out in the linked PR, the caching reproduction is likely to go away due to unrelated refactoring, so this isn't such a big problem. It is also possible to observe it via dune-build-info, however.

@rgrinberg
Copy link
Member

This was fixed in #4441

@rgrinberg rgrinberg added this to the 3.0 milestone Jun 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants