Open my4ng opened 6 months ago
this smells like a filesystem problem with podman, possibly permission related.
does
podman run -it ubuntu:20.04 -v /home/my4ng/.rustup/toolchains/stable-x86_64-unknown-linux-gnu:/rust:z,ro bash
ls /rust/lib/rustlib
show x86_64-unknown-linux-musl
?
I ran podman run -v /home/my4ng/.rustup/toolchains/stable-x86_64-unknown-linux-gnu:/rust:z,ro -it ubuntu:22.04 bash
:
$ ls /rust/lib/rustlib
ls: cannot access '/rust/lib/rustlib/components': Permission denied
components manifest-rust-std-x86_64-unknown-linux-musl
etc manifest-rustc-x86_64-unknown-linux-gnu
manifest-cargo-x86_64-unknown-linux-gnu manifest-rustfmt-preview-x86_64-unknown-linux-gnu
manifest-clippy-preview-x86_64-unknown-linux-gnu multirust-channel-manifest.toml
manifest-llvm-tools-preview-x86_64-unknown-linux-gnu multirust-config.toml
manifest-rust-analyzer-preview-x86_64-unknown-linux-gnu rust-installer-version
manifest-rust-docs-x86_64-unknown-linux-gnu src
manifest-rust-src x86_64-unknown-linux-gnu
manifest-rust-std-x86_64-unknown-linux-gnu x86_64-unknown-linux-musl
Strangely components
has the same permission as others in host:
.rw-r--r--@ 347 my4ng 26 May 04:10 components
drwxr-xr-x@ - my4ng 3 May 01:49 etc
.rw-r--r--@ 1.5k my4ng 3 May 01:49 manifest-cargo-x86_64-unknown-linux-gnu
.rw-r--r--@ 148 my4ng 3 May 01:49 manifest-clippy-preview-x86_64-unknown-linux-gnu
.rw-r--r--@ 938 my4ng 3 May 01:49 manifest-llvm-tools-preview-x86_64-unknown-linux-gnu
.rw-r--r--@ 147 my4ng 3 May 01:49 manifest-rust-analyzer-preview-x86_64-unknown-linux-gnu
.rw-r--r--@ 24 my4ng 3 May 01:49 manifest-rust-docs-x86_64-unknown-linux-gnu
.rw-r--r--@ 109k my4ng 3 May 01:49 manifest-rust-src
.rw-r--r--@ 2.7k my4ng 3 May 01:49 manifest-rust-std-x86_64-unknown-linux-gnu
.rw-r--r--@ 3.4k my4ng 26 May 04:10 manifest-rust-std-x86_64-unknown-linux-musl
.rw-r--r--@ 1.1k my4ng 3 May 01:49 manifest-rustc-x86_64-unknown-linux-gnu
.rw-r--r--@ 142 my4ng 3 May 01:49 manifest-rustfmt-preview-x86_64-unknown-linux-gnu
.rw-r--r--@ 745k my4ng 26 May 04:10 multirust-channel-manifest.toml
.rw-r--r--@ 720 my4ng 26 May 04:10 multirust-config.toml
.rw-r--r--@ 1 my4ng 26 May 04:10 rust-installer-version
drwxr-xr-x@ - my4ng 3 May 01:49 src
drwxr-xr-x@ - my4ng 3 May 01:49 x86_64-unknown-linux-gnu
drwxr-xr-x@ - my4ng 26 May 04:10 x86_64-unknown-linux-musl
But not in the container:
ls: cannot access 'components': Permission denied
total 884
drwxr-xr-x. 1 root root 1132 May 25 18:10 ./
drwxr-xr-x. 1 root root 268 May 2 15:49 ../
-?????????? ? ? ? ? ? components
drwxr-xr-x. 1 root root 236 May 2 15:49 etc/
-rw-r--r--. 1 root root 1482 May 2 15:49 manifest-cargo-x86_64-unknown-linux-gnu
-rw-r--r--. 1 root root 148 May 2 15:49 manifest-clippy-preview-x86_64-unknown-linux-gnu
-rw-r--r--. 1 root root 938 May 2 15:49 manifest-llvm-tools-preview-x86_64-unknown-linux-gnu
-rw-r--r--. 1 root root 147 May 2 15:49 manifest-rust-analyzer-preview-x86_64-unknown-linux-gnu
-rw-r--r--. 1 root root 24 May 2 15:49 manifest-rust-docs-x86_64-unknown-linux-gnu
-rw-r--r--. 1 root root 108723 May 2 15:49 manifest-rust-src
-rw-r--r--. 1 root root 2728 May 2 15:49 manifest-rust-std-x86_64-unknown-linux-gnu
-rw-r--r--. 1 root root 3390 May 25 18:10 manifest-rust-std-x86_64-unknown-linux-musl
-rw-r--r--. 1 root root 1056 May 2 15:49 manifest-rustc-x86_64-unknown-linux-gnu
-rw-r--r--. 1 root root 142 May 2 15:49 manifest-rustfmt-preview-x86_64-unknown-linux-gnu
-rw-r--r--. 1 root root 745481 May 25 18:10 multirust-channel-manifest.toml
-rw-r--r--. 1 root root 720 May 25 18:10 multirust-config.toml
-rw-r--r--. 1 root root 1 May 25 18:10 rust-installer-version
drwxr-xr-x. 1 root root 8 May 2 15:49 src/
drwxr-xr-x. 1 root root 12 May 2 15:49 x86_64-unknown-linux-gnu/
drwxr-xr-x. 1 root root 6 May 25 18:10 x86_64-unknown-linux-musl/
strange! maybe try recreating the file. does it work with cross +nightly
?
I have fixed it by uninstalling and reinstalling the stable toolchain, very strange indeed! Thanks for the help! I will close it now
I have to reopen the issue since the problem creeps back up when I try to install a second target i686-unknown-linux-gnu
. Whichever second target I try to add, it fails with unable to find core:
$ rustup toolchain uninstall stable
$ cross build --target i686-unknown-linux-gnu --release --locked -vv <- success
$ cross build --target x86_64-unknown-linux-musl --release --locked -vv <- failure
OR
$ rustup toolchain uninstall stable
$ cross build --target x86_64-unknown-linux-musl --release --locked -vv <- success
$ cross build --target i686-unknown-linux-gnu --release --locked -vv <- failure
I've finally identified the cause: selinux is preventing access to components and the various .lib
files from within the container.
According to the podman documentation:
To change a label in the container context, add either of two suffixes :z or :Z to the volume mount. These suffixes tell Podman to relabel file objects on the shared volumes. The z option tells Podman that two or more containers share the volume content. As a result, Podman labels the content with a shared content label. Shared volume labels allow all containers to read/write content. The Z option tells Podman to label the content with a private unshared label Only the current container can use a private volume. Relabeling walks the file system under the volume and changes the label on each file, if the volume has thousands of inodes, this process takes a long time, delaying the start of the container. If the volume was previously relabeled with the z option, Podman is optimized to not relabel a second time. If files are moved into the volume, then the labels can be manually change with the
chcon -Rt container_file_t PATH
command.
This makes sense why the first installed target works but not the second, since the first is installed before being relabelled with the z option, and the second one is done after.
Hence, I recommend adding an entry to the FAQ to both confirm this is indeed a permission issue (e.g. using ls -lZ
) and suggest a solution chcon -Rt container_file_t ~/.rustup/toolchains
.
Maybe we could run chcon
ourselves after running rustup target add
That’s certainly the best, after detection that selinux is indeed installed on the system. It really only need to chcon the specific lib folder, but there doesnt appear to be any harm in chcon the toolchains folder entirely.
Yes, I think the way to mitigate is
and ofc we should document this caveat
Unfortunately that won't be enough. If the user installed the rust-std for the specific target after the initial run of cross themselves, then it won't get relabelled. I think the only way is on a per-use basis, i.e. if we are going to use a specific target, we install (if does not exist) and then check, and if necessarily, change permission.
and ofc we should document this caveat
Agreed. I can submit a PR for both the code and docs if you want.
any movement on this? was there a PR submitted that needs to be merged? just checking, thanks!
any movement on this? was there a PR submitted that needs to be merged? just checking, thanks!
Sorry have been busy working on other things but it should be a relatively easy fix. It appears chcon -Rt container_file_t ~/.rustup/toolchains
needs to be run every time, in case rustup update
has overwritten with a new release (esp. for nightly).
@spemmons unfortunately I don't have a Linux machine with me at the moment and can maybe have a PR out next weekend at the earliest. If you want to work on it yourself, that's all good with me.
curiously, i have the same problem w/ docker, not podman -- i can look into it but i'm not 100% clear on what needs to be done
@spemmons I believe it is the same issue as I explained in a previous comment, essentially when the toolchain updates, the folder no longer has the correct SELinux type, and therefore cannot be used by podman/docker. :z/Z
is lazy and will only change it once at the first time.
Checklist
Describe your issue
cross build --target x86_64-unknown-linux-musl -vv
fails to compile whilecargo build --target x86_64-unknown-linux-musl
:I have done
cargo clean
but it does not help. It works forcargo
:rustup show
:It works on GitHub Runner
ubuntu-latest
using thetaiki-e/install-action@cross
action (see build.yml for details).EDIT: tested with edge image, still the same error.
What target(s) are you cross-compiling for?
x86_64-unknown-linux-musl
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
No response
Additional information / notes
No response