Skip to content

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

@craigfe

Description

@craigfe

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions