uutils / uutils/coreutils

uucore: perms imports safe_traversal unconditionally, breaking aix/hurd/redox builds

Open
#14,537 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
24.1k
Forks
2k
Avg merge
1d 5h
Merged PRs (30d)
365

Description

Summary

uucore's perms feature enables safe-traversal, and perms.rs imports it unconditionally:

// src/uucore/src/lib/features/perms.rs:32
use crate::features::safe_traversal::{DirFd, SymlinkBehavior};

But the module itself is compiled only for a subset of unix:

// src/uucore/src/lib/features.rs:88-93  (and lib.rs:106-111)
#[cfg(all(
    feature = "safe-traversal",
    unix,
    not(any(target_os = "aix", target_os = "hurd", target_os = "redox"))
))]
pub mod safe_traversal;

So on aix, hurd and redox, any crate that enables uucore/perms fails to build:

error[E0432]: unresolved import `crate::features::safe_traversal`
  --> src/uucore/src/lib/features/perms.rs:32:22
   |
32 | use crate::features::safe_traversal::{DirFd, SymlinkBehavior};
   |                      ^^^^^^^^^^^^^^ could not find `safe_traversal` in `features`

chmod, chown, chgrp, chcon, runcon, cp, mv and install all enable perms.

Why it matters for Redox specifically

feat_os_unix_redox includes chmod (Cargo.toml:371-377), and uu_chmod enables uucore/perms. So the documented Redox feature set does not build.

Why it has gone unnoticed

The Redox CI job is commented out:

# .github/workflows/CICD.yml:388
# - { os: ubuntu-latest, target: x86_64-unknown-redox, features: feat_os_unix_redox, use-cross: redoxer, skip-tests: true, check-only: true }
Reproducing without a Redox toolchain

Add target_os = "linux" to the exclusion list in both features.rs and lib.rs, then cargo build -p uu_chmod. The same E0432 appears.

Suggested fix

Either gate the perms.rs import and its uses on the same cfg as the module and provide a fallback for those targets, or widen safe_traversal to compile on them. Re-enabling the Redox check-only job afterwards would stop it regressing.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by comparing the cfg declarations in src/uucore/src/lib/features.rs and lib.rs with the import and uses in src/uucore/src/lib/features/perms.rs. Reproduce the failure with the documented cfg change and cargo build -p uu_chmod, then inspect Cargo.toml and .github/workflows/CICD.yml; done means the affected target configuration builds and the Redox check-only job can be re-enabled without regression.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
build-system, cli, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.