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

Cargo errors out when build script is not checked into git repository #15174

Open
msrd0 opened this issue Feb 12, 2025 · 5 comments
Open

Cargo errors out when build script is not checked into git repository #15174

msrd0 opened this issue Feb 12, 2025 · 5 comments
Labels
A-build-scripts Area: build.rs scripts A-git Area: anything dealing with git A-rebuild-detection Area: rebuild detection and fingerprinting C-bug Category: bug S-triage Status: This issue is waiting on initial triage.

Comments

@msrd0
Copy link

msrd0 commented Feb 12, 2025

Problem

I am trying to build an ArchLinux package. That means, the package build for ArchLinux is part of the git repository, but the actual source code gets downloaded from a tarball and placed into a subdirectory. Now I am trying to build probe-rs-tools 0.27.0 which has a build script. I got this funny output:

#12 20.41 ==> Starting build()...
#12 20.58 error: failed to determine package fingerprint for build script for probe-rs-tools v0.27.0 (/src/src/probe-rs-tools-0.27.0)
#12 20.58
#12 20.58 Caused by:
#12 20.58   failed to determine the most recently modified file in /src/src/probe-rs-tools-0.27.0
#12 20.58
#12 20.58 Caused by:
#12 20.58   failed to determine list of files in /src/src/probe-rs-tools-0.27.0
#12 20.58
#12 20.58 Caused by:
#12 20.58   did not expect repo at /src to be bare
#12 20.59 ==> ERROR: A failure occurred in build().
#12 20.59     Aborting...

The repository at /src is definitely not bare, but it definitely also does not contain any files within /src/src where the rust source code lives. I do not understand why cargo even cares about the VCS or searches beyond the topmost Cargo.toml which lives in /src/src.

Steps

git clone https://aur.archlinux.org/probe-rs.git
cd probe-rs
git checkout 84459d4de92d3b35619abe5568e30a1ea3d0ce6e
cat >Dockerfile <<EOF
FROM quay.io/archlinux/archlinux@sha256:bb6748109ed91bc0d6aad3293b339544ed626ed0cbc34d36e474068ea5af7665
SHELL ["/usr/bin/bash", "-exuo", "pipefail", "-c"]

RUN pacman -Sy --noconfirm git; \
	mkdir -p /src

COPY * /src/

RUN useradd -m -U aur \
 && chown -R aur:aur /src \
 && echo "aur ALL=(ALL) NOPASSWD: ALL" >/etc/sudoers.d/user

USER aur
WORKDIR /src

RUN makepkg --noconfirm --noarchive -s
EOF
docker build --progress=plain .

Possible Solution(s)

No response

Notes

No response

Version

cargo 1.84.1 (66221abde 2024-11-19)
release: 1.84.1
commit-hash: 66221abdeca2002d318fde6efff516aab091df0e
commit-date: 2024-11-19
host: x86_64-unknown-linux-gnu
libgit2: 1.8.1 (sys:0.19.0 vendored)
libcurl: 8.12.0 (sys:0.4.74+curl-8.9.0 system ssl:OpenSSL/3.4.0)
os: Arch Linux 20250212.0.307741 [64-bit]
@msrd0 msrd0 added C-bug Category: bug S-triage Status: This issue is waiting on initial triage. labels Feb 12, 2025
@epage epage added A-git Area: anything dealing with git A-rebuild-detection Area: rebuild detection and fingerprinting A-build-scripts Area: build.rs scripts labels Feb 12, 2025
@epage epage changed the title Cargo dies when build script is not checked into git repository Cargo errors out when build script is not checked into git repository Feb 12, 2025
@epage
Copy link
Contributor

epage commented Feb 12, 2025

When a package is assumed to be part of a git repo, we use git for enumerating the files and checking for changes.

I assume people have built for Arch before and have found ways of dealing with this.

@ehuss
Copy link
Contributor

ehuss commented Feb 13, 2025

I think there is an issue with the Dockerfile. The command should be something like COPY . /src/
The * ends up flattening the directories.

@msrd0
Copy link
Author

msrd0 commented Feb 13, 2025

I assume people have built for Arch before and have found ways of dealing with this.

It only happens in docker, so it is possible that my dockerfile is indeed weird. Nonetheless I don't believe that it is cargo's responsibility to care about broken git repositories. All files necessary to compile stuff exist and are in the correct location. Cargo can compile files outside of git repositories. So why cannot cargo compile files that are located in a subfolder of a broken git repository? Why doesn't cargo just fallback to compiling the code as if there was no git repository?

@weihanglo
Copy link
Member

So why cannot cargo compile files that are located in a subfolder of a broken git repository? Why doesn't cargo just fallback to compiling the code as if there was no git repository?

Cargo doesn't know whether a broken Git repository is intentionally broken.

@msrd0
Copy link
Author

msrd0 commented Feb 13, 2025

Cargo doesn't know whether a broken Git repository is intentionally broken.

Why does that matter?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-build-scripts Area: build.rs scripts A-git Area: anything dealing with git A-rebuild-detection Area: rebuild detection and fingerprinting C-bug Category: bug S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

No branches or pull requests

4 participants