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

Path::is_absolute is wrong on hermit #132141

Closed
m-mueller678 opened this issue Oct 25, 2024 · 1 comment · Fixed by #134252
Closed

Path::is_absolute is wrong on hermit #132141

m-mueller678 opened this issue Oct 25, 2024 · 1 comment · Fixed by #134252
Labels
C-bug Category: This is a bug. O-hermit Operating System: Hermit T-libs Relevant to the library team, which will review and decide on the PR/issue.

Comments

@m-mueller678
Copy link

m-mueller678 commented Oct 25, 2024

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.

@m-mueller678 m-mueller678 added the C-bug Category: This is a bug. label Oct 25, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Oct 25, 2024
@workingjubilee workingjubilee added O-hermit Operating System: Hermit T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Oct 25, 2024
@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Oct 26, 2024
@mkroening
Copy link
Contributor

Always feel free to tag @stlankes and me on Hermit related issues or chat with us on our Zulip to make sure we have them on our radar. :)

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Dec 13, 2024
…ross35

Fix `Path::is_absolute` on Hermit

Paths on Hermit work like paths on Unix.

Closes rust-lang#132141.
@bors bors closed this as completed in c58b8bc Dec 14, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Dec 14, 2024
Rollup merge of rust-lang#134252 - hermit-os:hermit-is_absolute, r=tgross35

Fix `Path::is_absolute` on Hermit

Paths on Hermit work like paths on Unix.

Closes rust-lang#132141.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. O-hermit Operating System: Hermit T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants