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

Unclear error message on read-only filesystem #7304

Closed
gendx opened this issue Aug 26, 2019 · 0 comments · Fixed by #7306
Closed

Unclear error message on read-only filesystem #7304

gendx opened this issue Aug 26, 2019 · 0 comments · Fixed by #7306
Labels
C-bug Category: bug

Comments

@gendx
Copy link

gendx commented Aug 26, 2019

Problem
I'm trying to compile Rust in a Docker container (on Linux/Debian) with a read-only root filesystem (--read-only), and a tmpfs to work in (--tmpfs /home/dev/build:exec). After running the ./x.py build script, I end up with the following error:

error: Read-only file system (os error 30)
failed to run: /home/dev/build/rust/build/x86_64-unknown-linux-gnu/stage0/bin/cargo build --manifest-path /home/dev/build/rust/src/bootstrap/Cargo.toml

The problem is that this error message doesn't say which path it tried to write to.

I ran the failing command again with strace to find that the missing part is $HOME/.cargo:

$ strace /home/dev/build/rust/build/x86_64-unknown-linux-gnu/stage0/bin/cargo build --manifest-path /home/dev/build/rust/src/bootstrap/Cargo.toml
...
mkdir("/home/dev/.cargo", 0777)         = -1 EROFS (Read-only file system)
...

I expected the error message to indicate which path triggered the EROFS (Read-only file system) error, for example:

error: Cannot create "/home/dev/.cargo": Read-only file system (os error 30)

That would be more user-friendly :)

Steps

  1. Start a Docker container (or a similar setup) with a read-only root filesystem, and a tmpfs in $HOME/build (with the exec flag enabled)
  2. Clone https://github.com/rust-lang/rust inside $HOME/build
  3. Run ./x.py inside $HOME/build/rust

Possible Solution(s)
I couldn't locate where this specific mkdir occurs in the code, but I'd suggest to add the faulty path to the I/O error message.

Notes

Output of cargo version:
cargo 1.38.0-beta (e853aa976 2019-08-09)

@gendx gendx added the C-bug Category: bug label Aug 26, 2019
bors added a commit that referenced this issue Aug 27, 2019
Improve error messages on mkdir failure

This commit ensures that `fs::create_dir*` isn't called throughout Cargo
and is instead routed through our own wrapper `paths::create_dir_all`
which brings with it a few benefits:

* Gracefully handles when the directory already exists (which is the
  behavior we always want anyway)
* Includes the path name in the error message of what failed
* Handles races of creating a directory by default

Closes #7304
@bors bors closed this as completed in 5102de2 Aug 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant