-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Description
Problem
before 1.68, this worked:
# be in a git repository
$ git init .
# create a junk commit (required; any history)
$ touch x && git add x && git commit -m x
$ mkdir -p a/b && cd a/b
# grab a rust project, that does not have a git repository in it (github tag tarball, .crate, ...)
$ curl https://github.com/sharkdp/hyperfine/archive/refs/tags/v1.16.0.tar.gz | tar -xz --strip-components=1
# build the project somehow
$ cargo buildhowever, since 1.68, you now get:
>>> hyperfine: Unpacking /var/cache/distfiles/hyperfine-1.16.0.tar.gz...
error: failed to determine package fingerprint for build script for hyperfine v1.16.0 (/home/demon/src/aports/community/hyperfine/src/hyperfine-1.16.0)
Caused by:
failed to determine the most recently modified file in /home/demon/src/aports/community/hyperfine/src/hyperfine-1.16.0
Caused by:
failed to determine list of files in /home/demon/src/aports/community/hyperfine/src/hyperfine-1.16.0
Caused by:
failed to open git index at /home/demon/src/aports/.git/
Caused by:
invalid data in index - calculated checksum does not match expected; class=Index (10)
>>> ERROR: hyperfine: build failed
of course, there is a workaround:
git init .inside the source directory
however, i'm not sure if it's necessarily "correct" to break here, or why that is the case.
Steps
# be in a git repository
$ git init .
# create a junk commit (required; any history)
$ touch x && git add x && git commit -m x
$ mkdir -p a/b && cd a/b
# grab a rust project, that does not have a git repository in it (github tag tarball, .crate, ...)
$ curl https://github.com/sharkdp/hyperfine/archive/refs/tags/v1.16.0.tar.gz | tar -xz --strip-components=1
# build the project somehow
$ cargo buildPossible Solution(s)
revert to old behaviour? i don't know the semantics for why this is the case now.
Notes
for background, the reason why the build is in an arbitrary git repository is because it is ran inside a ports tree (alpine linux aports in this case), and that is inside git.
as an aside (does not impact the above), GIT_CEILING_DIRECTORIES is set to prevent actual access to the repository metadata (versioning), but it does not affect this issue (whether it is set or not).
my question is- is there a reason cargo now 'requires' git to be clean/new or not exist to succeed and fails inside an existing repository?
Version
$ cargo version --verbose
cargo 1.68.0
release: 1.68.0
host: x86_64-alpine-linux-musl
libgit2: 1.5.0 (sys:0.16.0 vendored)
libcurl: 7.88.1 (sys:0.4.59+curl-7.86.0 system ssl:OpenSSL/3.1.0)
os: Alpine Linux 3.18_alpha20230208 [64-bit]