-
Notifications
You must be signed in to change notification settings - Fork 892
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
rustup-init.sh
fails to detect platform correctly under docker buildx
which lacks /proc
#2700
Comments
We use It sounds like this is a limitation of Any work to correct this would need to be fallback code in If someone wants to work on this, please talk to us on the Rust discord in |
rustup-init.sh
fails to detect platform correctly under docker buildx
which lacks /proc
This is my temporary solution that works (building python cryptography): # rust installer needs patched to get the correct binaries for ARMv6 and i686
RUN sed -i -e's/ main/ main contrib non-free/gm' /etc/apt/sources.list
RUN apt-get update -q && \
apt-get install -yq build-essential curl git libssl-dev libffi-dev libxml2 libxml2-dev libxslt1.1 libxslt-dev libz-dev mediainfo python3-dev unrar nano && \
pip install -U pip wheel && \
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rustup-init.sh && \
sed -i 's#/proc/self/exe#$(which head)#g' rustup-init.sh && \
sed -i 's#/proc/cpuinfo#/proc/cpuinfo 2> /dev/null || echo ''#g' rustup-init.sh && \
sed -i 's#get_architecture || return 1#RETVAL=$(gcc -dumpmachine | sed "s/-/-unknown-/") #g' rustup-init.sh && \
sh -x rustup-init.sh -y --default-host=$(gcc -dumpmachine | sed 's/-/-unknown-/') && \
rm rustup-init.sh && \
PATH=$PATH:$HOME/.cargo/bin pip install --no-cache-dir --no-input -Ur requirements.txt && \
PATH=$PATH:$HOME/.cargo/bin rustup self uninstall -y && \
apt-get purge -yq --autoremove build-essential libssl-dev libffi-dev libxml2-dev libxslt-dev libz-dev python3-dev && \
apt-get clean -yq && rm -rf /var/lib/apt/lists/* |
I do not believe all BSDs support |
This is debian buster |
True, but the relevant high-order bit there seemed to be |
I am getting this on macOS Monterey:
I am inside of a container built on: Cargo does install correctly though, so it doesn't hurt anything. Originally I thought this was a problem, but it still installs as expected. I figured this was still worth reporting here as another example of this occurring. |
Maybe I am misreading, but I can't quite tell: What CPU architecture is the host? AArch64? AMD64? PowerPC? |
aarch64-apple-darwin |
Perhaps we could switch from reading |
This is how I have been understanding it, I could be wrong entirely. If you are providing With When you need to add a target is when inside your docker file you have The definition of cross is when building a binary for a different architecture than the OS currently running. But it's 2 systems entirely, a docker image and the host OS. With one --platform arg inside the docker container you are just compiling (not cross), and outside you are building a dockerfile with cross, not cross compiling. Inside vs outside cross is a confusing situation right now with buildx. This has been some help understanding the confusion, but not enough: I'm currently having this exact issue again, without --platform in my dockerfile, using a base image of python3.10-slim (debian bullseye base) I'm going to try my previous hack some later, but maybe a bit different. Super annoying. |
So, I have made some progress on this. Buildkit runs in a security context that prevents the build from accessing /proc and other mounts. I am testing right now by providing these changes to my workflow: You have to pass this setting to buildkit and use a setting in the dockerfile. Pass
Then in your dockerfile: Test in buildkit shows exactly this: Now, since we know we can't read /proc/self/exe out of the box when using |
I spoke too soon. I successfully got security-insecure to work on github actions, and the script downloads the correct binaries for host/target, but the error still happens when trying to read /proc/self/exe. iirc from when I opened this issue it is a specially protected file in buildkit/docker to prevent exploiting any vulnerabilities and escaping the container.
I'll continue to look at it. Here was my POC |
POC seems to work with /proc/self/exe, but not rustup... Same command lol |
@miigotu I actually managed to get it running! I tried your command from the previous comment, but it seems that the SHELL env var was undeclared, so I just replaced it with "/bin/sh" and voilà!
For transparency: I was running the build through compose, with the following adjustments:
|
It's been a year. running the current rustup with
|
@bmarwell do you still see the problem? I've also encountered it with the
This problem seems unrelated to the original issue, but I'm writing here because this is the only place I found a report of the same behaviour. Could this be a problem of a missing kernel configuration? I found a patch for a kernel bug: https://lore.kernel.org/lkml/20240414003434.2659-1-danny@orbstack.dev/, but the described scenario doesn't quite fit the description; in the output above you see that the failing |
Uh I gave up on compiling on 16.04, sorry |
In my case it turned out that a |
rustup-init.sh installs the incorrect rustc and other binaries because of a failure to detect arch.
Problems:
/proc/self/exe
does not exist during docker build, so i686/386 etc is detected incorrectly as x86_64 due to failure on line 153. mips64 likely suffers the same issue because it also uses get_bitnessgrep '^Features' /proc/cpuinfo | grep -q -v neon
fails and ARMv6 is incorrectly detected as arm7 on line 367Running the downloaded binary fails with
/lib/ld-linux-armhf.so.3: No such file or directory
(because it isnt armhf, it is armel at/lib/ld-linux.so.3
)Logs and example code to produce the container and error:
https://gist.github.com/miigotu/2a0b80677420d806c96d8e792ae6652e
Note: gcc inside the container reports the correct info, kernel reports x86_64
and
The text was updated successfully, but these errors were encountered: