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

Build fails with sh: 1: cargo: not found #260

Closed
5 of 7 tasks
kariae opened this issue Mar 1, 2019 · 62 comments
Closed
5 of 7 tasks

Build fails with sh: 1: cargo: not found #260

kariae opened this issue Mar 1, 2019 · 62 comments
Assignees
Labels
A-wsl2-host Area: WSL2 hosts bug

Comments

@kariae
Copy link

kariae commented Mar 1, 2019

Maintainer's Note: This has become a meta-issue of multiple bugs all causing the host toolchain to not be mounted in the container, and includes:


The build fails on a Docker container with sh: 1: cargo: not found, the Docker container is run with a custom image that contains Docker with a wrapper to have DinD working, and Rust nightly docker run -it -v pwd:/var/tmp -v /var/run/docker.sock:/var/run/docker.sock kariae/docker-rust-nightly sh the command fails with sh: 1: cargo: not found

@evanjs
Copy link

evanjs commented Mar 3, 2019

I am also encountering this issue.
Nothing special about my setup, though.

[evanjs@nixentoo:~/src/scratch/sdl2test]$ cross build --target x86_64-pc-windows-gnu
Unable to find image 'japaric/x86_64-pc-windows-gnu:v0.1.14' locally
v0.1.14: Pulling from japaric/x86_64-pc-windows-gnu
b8a43e1b7983: Pull complete 
5c5185a06822: Pull complete 
8458c4a4e317: Pull complete 
6d0388b275d4: Pull complete 
56603a33e04b: Pull complete 
2cedd67f6904: Pull complete 
5d40de413ec5: Pull complete 
fbd3dda3b3f5: Pull complete 
ee23f3a81425: Pull complete 
22d70475d56a: Pull complete 
cc2c4c043bf3: Pull complete 
ace8770c3426: Pull complete 
Digest: sha256:b164f497e18f89133de814898d838603b07a6b1feb80b06271ddb3fb86128cc8
Status: Downloaded newer image for japaric/x86_64-pc-windows-gnu:v0.1.14
sh: 1: cargo: not found

Using NixOS 19.03 on 4.19.24
Docker: 18.09.2
Cross: 0.1.14
cargo 1.34.0-nightly (5c6aa46e6 2019-02-22)

@kariae
Copy link
Author

kariae commented Mar 3, 2019

I checked the image and I didn't find the installation of cargo which is a little bit tricky, since we use it to build the binaries ?!

@afiore
Copy link

afiore commented Mar 16, 2019

I am encountering the same problem. I have just tried running cross build --target aarch64-unknown-linux-musl and got the following output

Unable to find image 'japaric/x86_64-unknown-linux-musl:v0.1.14' locally
v0.1.14: Pulling from japaric/x86_64-unknown-linux-musl
8d51e945c435: Pull complete
d8d21cdaac84: Pull complete
99b5ff394311: Pull complete
3ab3190bc52d: Pull complete
8f2bd7981235: Pull complete
ba0de5bbf3ef: Pull complete
b8380c29d163: Pull complete
e75a875c5cd4: Pull complete
e10da4c5e540: Pull complete
26440e989b5e: Pull complete
b87e83e92416: Pull complete
2e920f245507: Pull complete
Digest: sha256:524b2d33f250ce4e243397b26aab5be7e90d5413b047cc1b9461a62b42b603e6
Status: Downloaded newer image for japaric/x86_64-unknown-linux-musl:v0.1.14
sh: 1: cargo: not found

like @evanjs I am also running on NixOS (18.03.133402.cb0e20d6db9 (Impala))

@wucke13
Copy link

wucke13 commented Jun 6, 2019

I'm also hit by

sh: 1: cargo: not found
failed to resize tty, using default size
sh: 1: cargo: not found

On Linux, NixOS 19.03

@binarylogic
Copy link

Same problem here. It appears to be limited to executing cross within a docker image. I'm curious if anyone has workarounds?

@AluisioASG
Copy link

AluisioASG commented Aug 11, 2019

The problem is that the image uses the host's own Rust install, which in some cases (e.g. NixOS) cannot be run on Ubuntu. You can work around it by building an image with its own Rust install, for example:

FROM japaric/x86_64-unknown-freebsd:v0.1.4
RUN apt-get update && apt-get install -y wget
RUN mkdir -m777 /opt/rust /opt/cargo
ENV RUSTUP_HOME=/opt/rust CARGO_HOME=/opt/cargo PATH=/opt/cargo/bin:$PATH
RUN wget --https-only --secure-protocol=TLSv1_2 -O- https://sh.rustup.rs | sh /dev/stdin -y
RUN rustup target add x86_64-unknown-freebsd
RUN printf '#!/bin/sh\nexport CARGO_HOME=/opt/cargo\nexec /bin/sh "$@"\n' >/usr/local/bin/sh
RUN chmod +x /usr/local/bin/sh

Rust is installed outside ~ so the user the build runs as can access it. About the last two lines, I wasn't able to override CARGO_HOME from the shell profile so I overrode the shell instead.
Not pretty, but gets the job done.

@wucke13
Copy link

wucke13 commented Aug 19, 2019

Using something from the host breakes many of the otherwise strong guarantees alike "runs fine with me, will run fine with you" docker has to offer. IMO this should be at least considered to be changed.

@reitermarkus
Copy link
Member

Have you tried installing cross from master?

@ndusart
Copy link

ndusart commented Sep 5, 2019

I had still to make some workaround for using cross in gitlab-ci even when using the master branch.
But I managed to do it, you can find information in this comment: #273 (comment)

This probably does not apply for nixOS users. But for the OP surely :)

@zonyitoo
Copy link

zonyitoo commented Feb 5, 2020

Same issue was found on circle-ci build: https://circleci.com/gh/shadowsocks/shadowsocks-rust/5

Could that be fixed by your script, too? @AluisioASG

@tomscript
Copy link

# cargo install --git https://github.com/rust-embedded/cross.git
    Updating git repository `https://github.com/rust-embedded/cross.git`
  Installing cross v0.2.0-alpha.1 (https://github.com/rust-embedded/cross.git#2f284acd)
<removed>
    Replaced package `cross v0.1.16` with `cross v0.2.0-alpha.1 (https://github.com/rust-embedded/cross.git#2f284acd)` (executable `cross`)

# cross build --target x86_64-pc-windows-gnu
Unable to find image 'rustembedded/cross:x86_64-pc-windows-gnu' locally
x86_64-pc-windows-gnu: Pulling from rustembedded/cross
<removed>
Digest: sha256:cdc542fe0a4b5cf89817388bcb4769f430a2979281add6f5e8fb26baf9f94a9a
Status: Downloaded newer image for rustembedded/cross:x86_64-pc-windows-gnu
sh: 1: cargo: not found

I tried to install cargo from master but running into the same issue. I'm using WSL. Any suggestions on how to troubleshoot further?

@urso
Copy link
Contributor

urso commented Mar 8, 2020

Did run into a similar issue with development containers and Docker in Docker setup. I created a small POC (PR #387) that tries to find the corrects paths on the host machine when spinning up the child container.

@edenreich
Copy link

edenreich commented Mar 8, 2020

I can confirm this issue, it also happens on armv7-unknown-linux-musleabihf-0.2.0

shouldn't rust be installed in those container images ? or I misunderstood the way this tool works

FROM rustembedded/cross:armv7-unknown-linux-musleabihf-0.2.0

ENV PATH="/root/.cargo/bin:$PATH"

RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain stable

@balboah
Copy link

balboah commented Mar 11, 2020

same problem, for some reason it worked a while ago. but not now (macOS)

@brainstorm
Copy link
Contributor

I can confirm as well, started happening a couple of days ago. Here I'm not even using an official rustembedded docker image, but a relatively simple Alpine linux one (see rust-bio/rust-htslib#193 if you need more details to reproduce and/or context):

$ rustup show
Default host: x86_64-unknown-linux-gnu
rustup home:  /home/limsadmin/.rustup

installed targets for active toolchain
--------------------------------------

x86_64-unknown-linux-gnu
x86_64-unknown-linux-musl

active toolchain
----------------

stable-x86_64-unknown-linux-gnu (default)
rustc 1.42.0 (b8cedc004 2020-03-09)

$ cat Cross.toml
[target.x86_64-unknown-linux-musl]
image = "brainstorm/rust-htslib-musl-alpine:latest"
$ cat docker/Dockerfile.alpine
FROM alpine:edge

RUN apk add --update wget git g++ build-base automake autoconf openssl openssl-dev curl-dev bzip2-dev xz-dev zlib-dev rustup && \
    rm -rf /var/cache/apk/*

WORKDIR /root
RUN rustup-init -y

ENV PATH "/root/.cargo/bin:$PATH"
RUN rustup target add x86_64-unknown-linux-musl
$ cross build --target x86_64-unknown-linux-musl
sh: cargo: not found

@wucke13
Copy link

wucke13 commented Apr 12, 2020

@reitermarkus Tagging you, as there seems to be official status on this, I hope you can provide more info.

Why is this issue still unfixed? @AluisioASG solution is a workaround that works, but it is rather inconvenient. How does cross pickup the host systems cargo? And why doesn't this mechanism work for some people (like me)?

Would it be possible to have a cargo with the matching target already added in the containers as a fallback? So that if possible host cargo is used, if not container image's cargo?

@tylerarnold
Copy link

I am hitting this issue as well, running on MacOS 10.15 and docker-in-dockering it. If I change cross to the master branch, it fails out with "Could not find directory of OpenSSL installation," but openssl-dev is installed.

@kajalsinha
Copy link

kajalsinha commented Jun 23, 2020

I have the same problem running on rust:1.44-alpine docker image.
After running apk add cmake make gcc libtool musl-dev g++
I see /bin/sh: 3: cargo: not found
This works perfectly fine on macOS.

@ghost
Copy link

ghost commented Jul 25, 2020

I also ran into the problem on nixOS while trying to cross compile for x86_64-unknown-linux-musl.
I ended up using https://github.com/emk/rust-musl-builder#what-is-this since it worked out of the box for me.

@jjlin
Copy link

jjlin commented Aug 23, 2020

For those running cross from within a Docker image, see https://github.com/rust-embedded/cross#docker-in-docker.

An example of doing this interactively using the official rust image:

docker-host$ docker run -it -e CROSS_DOCKER_IN_DOCKER=true -v /var/run/docker.sock:/var/run/docker.sock -v $(pwd):/usr/src/myproj -w /usr/src/myproj --rm rust bash
root@c7fddc07d311:/usr/src/myproj# wget https://download.docker.com/linux/static/stable/x86_64/docker-19.03.12.tgz
root@c7fddc07d311:/usr/src/myproj# tar -C /usr/local/bin --strip-components=1 -xf docker-19.03.12.tgz docker/docker
root@c7fddc07d311:/usr/src/myproj# cargo install cross
root@c7fddc07d311:/usr/src/myproj# cross build --target aarch64-unknown-linux-gnu

@jaredwolff
Copy link
Contributor

jaredwolff commented Oct 12, 2020

While working on this pull request (#467), I started encountering this message. I had just recently changed the path configuration for fish where I was placing /usr/local/bin before the one for cargo at ~/.cargo/bin/. Removing that entry seemed to clear up the issue. (As a side note, I'm on OSX running 10.14.6)

P.S. I'll also add I had two versions of Rust installed. One via brew and one via rustup. I uninstalled the one installed with Homebrew. That was likely the issue all along.

@andresv
Copy link

andresv commented Nov 3, 2020

I am having trouble to get cross to work with circleci.
I have following config.yml:

version: 2.1

executors:
  ci-runner:
    docker:
      - image: cimg/rust:1.47.0

jobs:
  build:
    docker:
      - image: cimg/rust:1.47.0
    environment:
      CROSS_DOCKER_IN_DOCKER: true
    steps:
      - checkout
      - restore_cache:
          key: v1-cargo-cross
      - setup_remote_docker:
          version: 19.03.13
          docker_layer_caching: true
      - run:
          name: Install protobuf dependencies
          command: |
            sudo apt-get update
            sudo apt install protobuf-compiler
      - run:
          name: Install cargo cross
          command: |
            set -x
            CROSS=/home/circleci/.cargo/bin/cross
            if [ -f "$CROSS" ]; then
              echo "cargo cross already installed"
            else
              cargo install cross
            fi
      - save_cache:
          key: v1-cargo-cross
          paths: /home/circleci/.cargo/bin/cross
      # - run:
      #     name: Build for x86_64
      #     command: cargo build
      - run:
          name: Build for aarch64
          command: docker run -e CROSS_DOCKER_IN_DOCKER=true -v /var/run/docker.sock:/var/run/docker.sock -v $(pwd):/home/circleci/project -w /home/circleci/project rustembedded/cross:aarch64-unknown-linux-musl cross build --target aarch64-unknown-linux-musl

workflows:
  version: 2
  app:
    jobs:
      - build

And I get error that cross is not found:

docker: Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"cross\": executable file not found in $PATH": unknown.

Maybe there is some obvious error in this docker command?

@jjlin
Copy link

jjlin commented Nov 3, 2020

@andresv rustembedded/cross:aarch64-unknown-linux-musl doesn't contain a cross executable, only the corresponding cross toolchain. You already installed cross in your cimg/rust:1.47.0 container, so just replace the whole docker run... command with cross build --target aarch64-unknown-linux-musl.

@kirill-d-lappo
Copy link

defining variable CROSS_DOCKER_IN_DOCKER=true inside of container helped me
thanks to @jjlin

@ndusart
Copy link

ndusart commented Nov 23, 2020

It appears to be added in this commit f2c70b3 (present in v0.2.1)

Does it mean this ticket could be closed ?

@wucke13
Copy link

wucke13 commented Nov 23, 2020

@ndusart No. I've had this issue without running docker in docker, so fixing docker in docker does not solve the entirety of this issue.

@IllustratedMan-code
Copy link

this solution worked

FROM ghcr.io/cross-rs/arm-unknown-linux-gnueabihf:main
RUN apt-get update && apt-get install -y wget
RUN mkdir -m777 /opt/rust /opt/cargo
ENV RUSTUP_HOME=/opt/rust CARGO_HOME=/opt/cargo PATH=/opt/cargo/bin:$PATH
RUN wget --https-only --secure-protocol=TLSv1_2 -O- https://sh.rustup.rs | sh /dev/stdin -y
RUN rustup target add arm-unknown-linux-gnueabihf
RUN printf '#!/bin/sh\nexport CARGO_HOME=/opt/cargo\nexec /bin/sh "$@"\n' >/usr/local/bin/sh
RUN chmod +x /usr/local/bin/sh

@Emilgardis
Copy link
Member

Emilgardis commented May 20, 2022

@IllustratedMan-code good that it worked for you, but that solution is not how cross is supposed to work (as I alluded to here and mentioned here), cross is supposed to mount your system sysroot for x86_64-unknown-linux-gnu into /

For nix specifically, the issue should have been fixed with #524

We have to continue and look into this, but its hard when we're not able to reproduce the issue

@bombsimon
Copy link

bombsimon commented May 24, 2022

I have the same issue in WSL2 (Ubuntu 20.04) running in Windows 11. Running Docker via Rancher Desktop in Windows and confirmed DinD works with docker run --rm -i hello-world.

Reproducing it like this:

Start build container that includes Docker

docker run --rm -it --entrypoint bash \
  -e CROSS_DOCKER_IN_DOCKER=true \
  -v /var/run/docker.sock:/var/run/docker.sock \
  gcr.io/cloud-builders/docker

Install Rust and cross, create project

apt update && apt install build-essential -y
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain stable
source $HOME/.cargo/env
cargo install cross
cargo init hello-world && cd hello-world

Try to build with cross

cross build
info: downloading component 'rust-src'
info: installing component 'rust-src'
sh: 1: cargo: not found

EDIT: The exact same steps works on Windows 11 and Manjaro 21.2.6 with Linux 5.17.

@Alexhuszagh
Copy link
Contributor

I checked the image and I didn't find the installation of cargo which is a little bit tricky, since we use it to build the binaries ?!

The docker images use the host cargo, so it is not installed on the image, and the directory is mounted to /cargo.

@IllustratedMan-code
Copy link

@Emilgardis I just took a look at #524 . It seems to rely on a NIX_STORE environment variable to determine the location of the nix store. The NIX_STORE variable is not set by nix normally as far as I can tell. The default location is /nix/store so I'll try setting the NIX_STORE variable and see if it fixes it.

@Emilgardis
Copy link
Member

Aha, that was not my understanding

@Garmelon
Copy link

Garmelon commented May 29, 2022

Running cross with the NIX_STORE environment variable set to /nix/store seems to work for me on NixOS.

@bombsimon
Copy link

Some more context to the WSL issue without really having a solution.

I had a look at the code for when cross starts a docker container and if you use DOCKER_IN_DOCKER=true it inspects the current container (docker inspect $HOSTNAME) to determine the volumes and tries to mount them, something like /var/lib/docker/overlay2/xxx/merged/root/.cargo:/cargo:Z. This is needed since afaik you won't be able to mount volumes from Docker to Docker but instead have to reference the host machine/volume (ref).

However, when running Rancher Desktop (and I think Docker Desktop as well?) in combination with WSL, it sets up two different distros to host Docker:

$ wsl --list -v
  NAME                    STATE           VERSION
* Ubuntu                  Running         2
  rancher-desktop         Running         2
  rancher-desktop-data    Running         2

The container data volume does not exist in Ubuntu or rancher-desktop, however it exists in rancher-desktop-data. This means that if I look at the output for docker inspect $HOSTNAME and .[0].GraphDriver.Data, it will refer to paths which does not exist and is not accessible in the current container that tries to run cross.

I usually don't use Windows or WSL so I need to read up more on how volume mounts + Windows + WSL + Docker in Docker works but right now it looks as simple as that the cross container that gets launched from the Docker container running in WSL basically can't mount any toolchain successfully which also explains why cargo is not found.

This feels like a very WSL specific issue so let me know if you want me to open a new issue to track this.

@Emilgardis
Copy link
Member

This feels like a very WSL specific issue so let me know if you want me to open a new issue to track this.

Yes please do!

@Alexhuszagh
Copy link
Contributor

Alexhuszagh commented Jul 2, 2022

I can confirm this issue, it also happens on armv7-unknown-linux-musleabihf-0.2.0

shouldn't rust be installed in those container images ? or I misunderstood the way this tool works

FROM rustembedded/cross:armv7-unknown-linux-musleabihf-0.2.0

ENV PATH="/root/.cargo/bin:$PATH"

RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain stable

No, although we will be shipping an image with cross pre-installed in #878.

I believe the only issue left is running cross in Rancher Desktop and WSL2. We've fixed:

  • NIX_STORE
  • Docker in docker
  • Remote docker support
  • Regular WSL2 issues

@Alexhuszagh
Copy link
Contributor

Alexhuszagh commented Jul 18, 2022

I am having trouble to get cross to work with circleci. I have following config.yml:

And I get error that cross is not found:

docker: Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"cross\": executable file not found in $PATH": unknown.

Maybe there is some obvious error in this docker command?

Yeah, the images do not come with cross-installed, you are supposed to use the host tooolchain and you are trying to use cross inside the image. You are supposed to run cross on the host which mounts the Rust toolchain inside the image and comes pre-installed with the necessary linkers/C compilers for cross-compilation. Just change the command to CROSS_DOCKER_IN_DOCKER=true build --target aarch64-unknown-linux-musl and it should work. Make sure the image itself was mounted with -v /var/run/docker.sock:/var/run/docker.sock or a correct mount from the host Docker socket to the image Docker socket.

The actual mount point seems to be /run/desktop/mnt/host/$drive/$path, however, this doesn't seem very fruitful. A better approach seems to be /mnt/wsl/docker-desktop-bind-mounts/Ubuntu-22.04/9d1f950fb5631e36b799853d4e1b9f9150a092eba2d6fce54dc60f78297cd082/hell, but um, this doesn't seem super reliable for reasons. This isn't the current hostname either, nor the current ID from the storage driver. So, I don't think this is really feasible, since it requires the current WSL2 machine name, and some seemingly random identifier.

@Alexhuszagh
Copy link
Contributor

The remaining issues for cargo not being found have their own independent issues, and there are better used to track the status of the container engine failing to mount host volumes.

@IllustratedMan-code
Copy link

Just created a pull request that should fix the NIX_STORE problem.

bors bot added a commit that referenced this issue Aug 8, 2022
989: added default nix_store value r=Alexhuszagh,otavio a=IllustratedMan-code

This pull request fixes the nix related issues described in #260. Its super simple, I just made the nix_store match statement default to `/nix/store` if the NIX_STORE variable is not set. 

There might be some edge cases where this won't fix the problem, but should be fine for any normal NixOS installation.




Co-authored-by: lew2mz <[email protected]>
@Alexhuszagh Alexhuszagh added the A-wsl2-host Area: WSL2 hosts label Nov 6, 2022
@bnheise
Copy link

bnheise commented Feb 7, 2023

I'm seeing these issue on mac.

@Emilgardis
Copy link
Member

@bnheise please open a new issue for your issue. For us to best help you/identify the problem, include the output of the cross command with -v added

@bnheise
Copy link

bnheise commented Feb 8, 2023

Hi @Emilgardis Thanks for the direction. The issue is no longer occurring for me. I'm not sure why yet though.

@nuket
Copy link

nuket commented Jun 28, 2023

I have an idea why this is happening on Docker in Docker runs.

If /var/lib/docker is not bind mounted to the outer Docker instance, when cross goes to forward some of those mounts, there is nothing to forward to the inner Docker instance:

rustuser@rust-build:~/workspace$ cross build -vv --target aarch64-unknown-linux-gnu
+ cargo metadata --format-version 1 --filter-platform aarch64-unknown-linux-gnu
+ rustc --print sysroot
+ rustup toolchain list
+ rustup target list --toolchain 1.70.0-x86_64-unknown-linux-gnu
+ rustup component list --toolchain 1.70.0-x86_64-unknown-linux-gnu
+ /usr/bin/docker
+ /usr/bin/docker run --userns host -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 'USER=rustuser' -v /var/lib/docker/overlay2/usdd8fbv8j2xwmrqyhw5v14b3/merged/home/rustuser/workspace/builddir/library:/var/lib/docker/overlay2/usdd8fbv8j2xwmrqyhw5v14b3/merged/home/rustuser/workspace/builddir/library --rm --user 1000:1000 -v /var/lib/docker/overlay2/usdd8fbv8j2xwmrqyhw5v14b3/merged/home/rustuser/.xargo:/xargo:z -v /var/lib/docker/overlay2/usdd8fbv8j2xwmrqyhw5v14b3/merged/opt/cargo:/cargo:z -v /cargo/bin -v /var/lib/docker/overlay2/usdd8fbv8j2xwmrqyhw5v14b3/merged/home/rustuser/workspace:/var/lib/docker/overlay2/usdd8fbv8j2xwmrqyhw5v14b3/merged/home/rustuser/workspace:z -v /var/lib/docker/overlay2/usdd8fbv8j2xwmrqyhw5v14b3/merged/usr/local/rustup/toolchains/1.70.0-x86_64-unknown-linux-gnu:/rust:z,ro -v /var/lib/docker/overlay2/usdd8fbv8j2xwmrqyhw5v14b3/merged/home/rustuser/workspace/target:/target:z -w /var/lib/docker/overlay2/usdd8fbv8j2xwmrqyhw5v14b3/merged/home/rustuser/workspace -i -t ghcr.io/cross-rs/aarch64-unknown-linux-gnu:0.2.5 sh -c 'PATH=$PATH:/rust/bin cargo build -vv --target aarch64-unknown-linux-gnu'
sh: 1: cargo: not found
+ rustup component list --toolchain 1.70.0-x86_64-unknown-linux-gnu

If you run the container above and drop into a shell, you can examine the paths available in /var/lib and see what is missing.

rustuser@rust-build:~/workspace$  /usr/bin/docker run --userns host -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 'USER=rustuser' -v /var/lib/docker/overlay2/usdd8fbv8j2xwmrqyhw5v14b3/merged/home/rustuser/workspace/builddir/library:/var/lib/docker/overlay2/usdd8fbv8j2xwmrqyhw5v14b3/merged/home/rustuser/workspace/builddir/library --rm --user 1000:1000 -v /var/lib/docker/overlay2/usdd8fbv8j2xwmrqyhw5v14b3/merged/home/rustuser/.xargo:/xargo:z -v /var/lib/docker/overlay2/usdd8fbv8j2xwmrqyhw5v14b3/merged/opt/cargo:/cargo:z -v /cargo/bin -v /var/lib/docker/overlay2/usdd8fbv8j2xwmrqyhw5v14b3/merged/home/rustuser/workspace:/var/lib/docker/overlay2/usdd8fbv8j2xwmrqyhw5v14b3/merged/home/rustuser/workspace:z -v /var/lib/docker/overlay2/usdd8fbv8j2xwmrqyhw5v14b3/merged/usr/local/rustup/toolchains/1.70.0-x86_64-unknown-linux-gnu:/rust:z,ro -v /var/lib/docker/overlay2/usdd8fbv8j2xwmrqyhw5v14b3/merged/home/rustuser/workspace/target:/target:z -w /var/lib/docker/overlay2/usdd8fbv8j2xwmrqyhw5v14b3/merged/home/rustuser/workspace -i -t ghcr.io/cross-rs/aarch64-unknown-linux-gnu:0.2.5 sh
$ ls
target
$ id
uid=1000 gid=1000 groups=1000
$ ls /
bin  boot  cargo  common.sh  dev  etc  home  lib  lib.sh  lib64  linux-image.sh  linux-runner  media  mnt  opt  proc  qemu  root  run  rust  sbin  srv  sys  target  tmp  usr  var  xargo
rustuser@rust-build:~/workspace$ ls -l /var/lib
total 48
drwxr-xr-x 1 root root 4096 Jun 28 14:25 apt
drwxr-xr-x 1 root root 4096 Jun 28 14:26 dpkg
drwxr-xr-x 2 root root 4096 Feb 22 10:51 git
drwxr-xr-x 2 root root 4096 Apr  2 13:55 misc
drwxr-xr-x 2 root root 4096 Jun 12 02:00 pam
drwxr-xr-x 2 root root 4096 Jun 13 05:29 python
drwxr-xr-x 3 root root 4096 Jun 28 14:25 sudo
drwxr-xr-x 1 root root 4096 Jun 13 05:29 systemd
drwxr-xr-x 3 root root 4096 Jun 13 05:29 ucf
rustuser@rust-build:~/workspace$ ls -l /var/lib/docker
ls: cannot access '/var/lib/docker': No such file or directory

I don't have a solution to this yet. It should be possible to bind mount /var/lib/docker, but the root:root permissions will be an issue. It doesn't really make sense to me why cross reuses the host system Rust tools.

@Emilgardis
Copy link
Member

Emilgardis commented Jun 28, 2023

cross reuses the hosts rust tools so that you can specify what rust version to run, and so that we don't have to follow the 6 week releases of rust.

@nuket

For docker in docker, are you using the correct env vars as mentioned in the readme (CROSS_CONTAINER_IN_CONTAINER=true)? If you are and it still doesn't work, thats a bug unrelated to this issue, feel free to open a new issue or reach out on our matrix chat (also found in our readme :D )

@nuket
Copy link

nuket commented Jun 28, 2023

Hmm. I think it creates a dependency that might be more easily folded into a single container or deriving from rust:latest. For people running CI servers, it means having to install Rust on the server directly or fiddling with this Docker in Docker situation.

I purposefully don't install Rust in the outermost host system I use for development. And I'm not sure how many corporate users are aiming for anything newer than the stable release anyways, it's usually the opposite 😼.

I am indeed using CROSS_CONTAINER_IN_CONTAINER=true. Let me go ahead and put the details in a new issue and link it here -- #1283

@cross-rs cross-rs locked as resolved and limited conversation to collaborators Jun 28, 2023
@Emilgardis
Copy link
Member

If you experience this, please see the other issues mentioned in the first comment, open a new issue or reach out on our matrix chat!

Thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-wsl2-host Area: WSL2 hosts bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.