Skip to content

Unclear error message on read-only filesystem #7304

Closed
@gendx

Description

@gendx

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions