Skip to content

Path::is_absolute is wrong on hermit #132141

Closed
@m-mueller678

Description

@m-mueller678

On Hermit, this currently returns false, I would expect it to be true:

PathBuf::from("/root/example.csv").is_absolute()

I could not find any documentation on what Hermit considers an absolute path, so just to be sure, this is also false:

std::path::absolute(PathBuf::from("/root/example.csv")).unwrap().is_absolute()

I think adding hermit alongside wasi here in path.rs in std would suffice:

  #[stable(feature = "rust1", since = "1.0.0")]
    #[must_use]
    #[allow(deprecated)]
    pub fn is_absolute(&self) -> bool {
        if cfg!(target_os = "redox") {
            // FIXME: Allow Redox prefixes
            self.has_root() || has_redox_scheme(self.as_u8_slice())
        } else {
            self.has_root() && (cfg!(any(unix, target_os = "wasi")) || self.prefix().is_some())
        }
    }

Meta

rustc 1.82.0 (f6e511eec 2024-10-15)
binary: rustc
commit-hash: f6e511eec7342f59a25f7c0534f1dbea00d01b14
commit-date: 2024-10-15
host: x86_64-unknown-linux-gnu
release: 1.82.0
LLVM version: 19.1.1

build-std is giving me trouble, so I cannot test this on nightly right now, but the code in is_absolute was not touched since, as far as I can tell.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.O-hermitOperating System: HermitT-libsRelevant to the library team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions