Issue installation on Ubuntu 22.04 ("failed to extract package")

Hello, first time user here.

I got curious today and I am trying to install Rust on a Ubuntu 22.04 laptop but I got the following error:

~$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
info: downloading installer

Welcome to Rust!

This will download and install the official compiler for the Rust
programming language, and its package manager, Cargo.

Rustup metadata and toolchains will be installed into the Rustup
home directory, located at:

  /home/myusername/.rustup

This can be modified with the RUSTUP_HOME environment variable.

The Cargo home directory is located at:

  /home/myusername/.cargo

This can be modified with the CARGO_HOME environment variable.

The cargo, rustc, rustup and other commands will be added to
Cargo's bin directory, located at:

  /home/myusername/.cargo/bin

This path will then be added to your PATH environment variable by
modifying the profile files located at:

  /home/lobianco/.profile
  /home/lobianco/.bashrc

You can uninstall at any time with rustup self uninstall and
these changes will be reverted.

Current installation options:


   default host triple: x86_64-unknown-linux-gnu
     default toolchain: stable (default)
               profile: default
  modify PATH variable: yes

1) Proceed with standard installation (default - just press enter)
2) Customize installation
3) Cancel installation
>1

info: profile set to 'default'
info: default host triple is x86_64-unknown-linux-gnu
info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
info: latest update on 2024-09-05, rust version 1.81.0 (eeb90cda1 2024-09-04)
info: downloading component 'cargo'
info: downloading component 'clippy'
info: downloading component 'rust-docs'
info: downloading component 'rust-std'
info: downloading component 'rustc'
info: downloading component 'rustfmt'
info: installing component 'cargo'
info: installing component 'clippy'
info: installing component 'rust-docs'
  8.9 MiB /  15.9 MiB ( 56 %)   5.8 MiB/s in  1s ETA:  1s
info: rolling back changes
error: failed to extract package: Operation not permitted (os error 1)

I have plenty of space and I have already trying removing ~/.cargo and ~/.rustup folders...

Any hint ? Do I need to install rust as root ?

You don't need to install as root. This indicates a problem with ownership or mode of something. Unfortunately it isn't telling you what it is trying to do when failing (it really should, could be worth filing a bug about that).

I would check that your home directory is owned by you and the user has rwx permissions. Also check your .bashrc/.profile etc that it tries to write PATH to (should be mode rw for the user).

You could also write a find command to find any files with wrong owner (or missing read/write/execute) in your home dir, I would write out such a one liner for you, but I'm on my phone at the moment.

Could also be some weirdness with some temporary directory it is downloading to before unpacking (/tmp? Not sure what it uses).

1 Like

Thanks. The home directory is quite standard, owned by my name, and both .bashc and .profile are rw-r--r--

This is if I run the installation script with the -v option:

info: profile set to 'default'
info: setting default host triple to x86_64-unknown-linux-gnu
verbose: installing toolchain 'stable-x86_64-unknown-linux-gnu'
verbose: toolchain directory: '/home/lobianco/.rustup/toolchains/stable-x86_64-unknown-linux-gnu'
info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
verbose: creating temp file: /home/lobianco/.rustup/tmp/1zc3blzb8f2rfb4w_file
verbose: downloading file from: 'https://static.rust-lang.org/dist/channel-rust-stable.toml.sha256'
verbose: downloading with reqwest
verbose: deleted temp file: /home/lobianco/.rustup/tmp/1zc3blzb8f2rfb4w_file
verbose: no update hash at: '/home/lobianco/.rustup/update-hashes/stable-x86_64-unknown-linux-gnu'
verbose: creating temp file: /home/lobianco/.rustup/tmp/dr5zfi0vvpa26sht_file.toml
verbose: downloading file from: 'https://static.rust-lang.org/dist/channel-rust-stable.toml'
verbose: downloading with reqwest
verbose: checksum passed
verbose: deleted temp file: /home/lobianco/.rustup/tmp/dr5zfi0vvpa26sht_file.toml
info: latest update on 2024-09-05, rust version 1.81.0 (eeb90cda1 2024-09-04)
info: downloading component 'cargo'
verbose: reusing previously downloaded file
verbose: checksum passed
info: downloading component 'clippy'
verbose: reusing previously downloaded file
verbose: checksum passed
info: downloading component 'rust-docs'
verbose: reusing previously downloaded file
verbose: checksum passed
info: downloading component 'rust-std'
verbose: reusing previously downloaded file
verbose: checksum passed
info: downloading component 'rustc'
verbose: reusing previously downloaded file
verbose: checksum passed
info: downloading component 'rustfmt'
verbose: reusing previously downloaded file
verbose: checksum passed
info: installing component 'cargo'
verbose: creating temp directory: /home/lobianco/.rustup/tmp/tzuy19_qg4w4jml2_dir
verbose: deleted temp directory: /home/lobianco/.rustup/tmp/tzuy19_qg4w4jml2_dir
info: installing component 'clippy'
verbose: creating temp directory: /home/lobianco/.rustup/tmp/uph_hr0mqjzxaxvg_dir
verbose: creating temp file: /home/lobianco/.rustup/tmp/_0moj8vsuz2v6w5f_file
verbose: creating temp file: /home/lobianco/.rustup/tmp/bfzpu_lyf8r26q1r_file
verbose: deleted temp directory: /home/lobianco/.rustup/tmp/uph_hr0mqjzxaxvg_dir
info: installing component 'rust-docs'
verbose: creating temp directory: /home/lobianco/.rustup/tmp/gsrqb_0e2v527nzp_dir
  8.9 MiB /  15.9 MiB ( 56 %)   5.4 MiB/s in  1s ETA:  1s
verbose: deleted temp directory: /home/lobianco/.rustup/tmp/gsrqb_0e2v527nzp_dir
info: rolling back changes
verbose: removing toolchain directory: '/home/lobianco/.rustup/toolchains/stable-x86_64-unknown-linux-gnu'
error: failed to extract package

Caused by:
    Operation not permitted (os error 1)

Unfortunatly it doesn't tell me where it is getting issues....

EDIT: I have tried the installation script with the option not to update the ENV variables, but same error
EDIT2: If I choose the nighly build, minimal, no env var, it installs correctly (but I am just starting, that's not the solution I want)
EDIT3: The issue is not in the stable/nightly nor in the variables, it is in the default or minimal installation. If I choose minimal, it installs, if I choose "default" it gives me the error.
So, if I choose minimal, what I then need to install to get back a default installation ?

The difference seems:

The default profile includes all of components in the minimal profile, and adds rust-docs, rustfmt, and clippy.

How do I install them having installed a minimal installation ?

EDIT:

The culprit is rust-docs (the other two works):

$ rustup component add rust-docs
info: downloading component 'rust-docs'
info: installing component 'rust-docs'
  8.9 MiB /  15.9 MiB ( 56 %)   5.9 MiB/s in  1s ETA:  1s
info: rolling back changes
error: failed to extract package: Operation not permitted (os error 1)

That is truly weird. It a really shouldn't be doing that. Could there be some weirdness with SELinux or anti-malware software going on? Much less common on Linux than on Windows, but in a corporate environment you might have something like that.

Another random idea: weird file system? Such as a FUSE based home dir encryption or such (as opposed to normal block device based full disk encryption).

One idea would be to run strace on rustup to see what the last failing syscall is. You likely need to redirect to a file and sift through, since it apparently does a bunch of cleanup after, so the issue won't be at the very end.

3 Likes

I have a pretty standard ext4 fs..
Indeed it could have been an antivirus they made me to install, "WithSecure" (ex f-secure).. I removed it, and the command then it worked...

3 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.