Open fjnuLuis opened 2 months ago
I'm not able to try this right now, but did you get the same result on the main branch?
cargo install cross --git https://github.com/cross-rs/cross
/root/.cargo/bin
is not in $PATH
?
root@fa8fa42ed45d:/workspace# CROSS_REMOTE_COPY_REGISTRY=1 CROSS_REMOTE=1 CROSS_REMOTE_COPY_CACHE=1 cross build --offline --target aarch64-unknown-linux-gnu --verbose
symlink_recurse() { for f in "${1}"/*; do dst=${f#"$prefix"} if [ -f "${dst}" ]; then echo "invalid: got unexpected file at ${dst}" 1>&2 exit 1 elif [ -d "${dst}" ]; then symlink_recurse "${f}" else ln -s "${f}" "${dst}" fi done }
symlink_recurse "${prefix}" '
I think we should apply your suggested fix. However, are you sure you can't use CROSS_CONTAINER_IN_CONTAINER
instead? Do you need remote?
Yes, my docker storage driver is not overlay2, and this is not a service I can control, so I can’t use CROSS_CONTAINER_IN_CONTAINER
and can only copy /root/.cargo
to the new docker container.
Checklist
Describe your issue
How To Step On This Bug
cargo fetch
in advance to download the cache. After that, every time I compile, I will open--offline
mode and do not connect to the Internet.CROSS_REMOTE_COPY_REGISTRY=1
CROSS_REMOTE=1
CROSS_REMOTE_COPY_CACHE=1
--verbose
during compilation:symlink_recurse() { for f in "${1}"/*; do dst=${f#"$prefix"} if [ -f "${dst}" ]; then echo "invalid: got unexpected file at ${dst}" 1>&2 exit 1 elif [ -d "${dst}" ]; then symlink_recurse "${f}" else ln -s "${f}" "${dst}" fi done }
symlink_recurse "${prefix}" '
chown -R 0:0 /cross
prefix=/cross
symlink_recurse /cross
dst=/cargo
[ -f /cargo ]
[ -d /cargo ]
ln -s /cross/cargo /cargo
dst=/project
[ -f /project ]
[ -d /project ]
ln -s /cross/project /project
dst=/rust
[ -f /rust ]
[ -d /rust ]
ln -s /cross/rust /rust
/usr/bin/docker exec --user 0:0 -e 'PKG_CONFIG_ALLOW_CROSS=1' -e 'XARGO_HOME=/xargo' -e 'CARGO_HOME=/cargo' -e 'CARGO_TARGET_DIR=/target' -e 'CROSS_RUNNER=' -e TERM -e CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUNNER -e http_proxy -e CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER -e https_proxy -e 'USER=root' -w /project cross-stable-x86_64-unknown-linux-gnu-53e1a-25ef9e3d8-aarch64-unknown-linux-gnu-playground-c4b44 sh -c 'PATH=$PATH:/rust/bin cargo build --offline --target aarch64-unknown-linux-gnu --verbose --target-dir /cross/project/target' error: no matching package named
log
found location searched: registrycrates-io
required by packageplayground v0.1.0 (/cross/project)
As a reminder, you're using offline mode (--offline) which can sometimes cause surprising resolution failures, if this error is too confusing you may wish to retry without the offline flag./usr/bin/docker exec cross-stable-x86_64-unknown-linux-gnu-53e1a-25ef9e3d8-aarch64-unknown-linux-gnu-playground-c4b44 bash -c '[[ -d '\''/cross/project/target'\'' ]]'
/usr/bin/docker cp -a cross-stable-x86_64-unknown-linux-gnu-53e1a-25ef9e3d8-aarch64-unknown-linux-gnu-playground-c4b44:/cross/project/target /workspace Successfully copied 5.12kB to /workspace
/usr/bin/docker stop cross-stable-x86_64-unknown-linux-gnu-53e1a-25ef9e3d8-aarch64-unknown-linux-gnu-playground-c4b44 --time 2 cross-stable-x86_64-unknown-linux-gnu-53e1a-25ef9e3d8-aarch64-unknown-linux-gnu-playground-c4b44
/usr/bin/docker rm cross-stable-x86_64-unknown-linux-gnu-53e1a-25ef9e3d8-aarch64-unknown-linux-gnu-playground-c4b44
rustup component list --toolchain stable-x86_64-unknown-linux-gnu
The most critical log shows that the
log
package cache cannot be found during compilation:But in fact it can be
list
before compilation:Try To Analyze This Bug
/root/.cargo
directory was not copied into the volume. I tried executing some command after cross build executing/usr/bin/docker cp -a /root/.cargo cross-stable-x86_64-unknown-linux-gnu-*-unknown-linux-gnu-playground-*:/cross/cargo
, to see what the directory looks like, and use the following command:total 0 drwxr-xr-x 4 root root 31 Apr 28 07:49 . drwxr-xr-x 4 root root 31 Apr 28 07:49 .. drwxr-xr-x 4 root root 136 Apr 28 05:34 .cargo drwxr-xr-x 2 root root 6 Apr 28 07:49 bin
What target(s) are you cross-compiling for?
aarch64-unknown-linux-gnu
Which operating system is the host (e.g computer cross is on) running?
What architecture is the host?
What container engine is cross using?
cross version
cross 0.2.5
Example
TEST_DIR=playground TEST_DOCKER_TAG=test_offline:latest
delete cache
sudo rm -rf $TEST_DIR
init a cargo project with log dependency
mkdir $TEST_DIR && cd $TEST_DIR cargo init cargo add log
build rust compilable image from cross based image
cat > Dockerfile << EOF from ghcr.io/cross-rs/aarch64-unknown-linux-gnu:0.2.5
install rustup & cargo
RUN curl --retry 3 https://sh.rustup.rs -sSf | sh -s -- -y --profile minimal --default-toolchain stable ENV PATH=/root/.cargo/bin:$PATH
install cross
RUN cargo install cross
install aarch64 target
RUN rustup target add aarch64-unknown-linux-gnu
install rust-src
RUN rustup component add rust-src
install docker
RUN apt update \ && apt install apt-transport-https ca-certificates curl -y \ && install -m 0755 -d /etc/apt/keyrings \ && curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor --yes -o /etc/apt/keyrings/docker.asc \ && chmod a+r /etc/apt/keyrings/docker.asc \ && echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \ $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ tee /etc/apt/sources.list.d/docker.list > /dev/null \ && apt update \ && apt install docker-ce-cli -y EOF
docker build -t $TEST_DOCKER_TAG .
cross build offline using
docker-in-docker
modedocker run \ -v /var/run/docker.sock:/var/run/docker.sock \ -v $(pwd):/workspace \ -w /workspace \ -it $TEST_DOCKER_TAG /bin/bash -c "CROSS_REMOTE_COPY_REGISTRY=1 CROSS_REMOTE=1 CROSS_REMOTE_COPY_CACHE=1 cross build --offline --target aarch64-unknown-linux-gnu --verbose"
cd -