fix(aprz): drop directories and humantime-serde dependencies - #145
Conversation
The scheduled `anvil-aprz` gate rejected three crates in the workspace dependency graph: * `directories` 6.0.0 and `humantime` 2.4.0 as unmaintained * `option-ext` 0.2.0 (MPL-2.0, transitive via `directories`) on license Both advisories are withdrawn upstream (RUSTSEC-2020-0054 on 2021-04-19, RUSTSEC-2025-0014 on 2025-03-12), so the released cargo-aprz 1.1.0 the gate installs is reporting stale data. Rather than wait on a tool release, remove the dependencies outright: each was used for one small thing. `directories::BaseDirs::cache_dir` becomes `commands::cache_dir`, which reads `LOCALAPPDATA` on Windows, `HOME/Library/Caches` on macOS, and `XDG_CACHE_HOME` or `HOME/.cache` elsewhere. `humantime-serde` becomes `commands::duration`, a serde adapter for the same `<amount><unit>` grammar existing configuration files use, so `"1 week"` and friends keep parsing. Its error now names the offending value. Dropping `directories` also drops the MPL-2.0 `option-ext`, matching the precedent set by replacing MPL-2.0 `vlen` with 0BSD `vu128`. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
A newly-updated unit test relies on the host environment having cache-dir variables set, which can make CI runs flaky in sanitized environments.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR updates cargo-aprz-lib to remove the directories and humantime-serde dependencies by replacing them with small in-crate implementations for platform cache-dir discovery and human-readable duration (de)serialization, aiming to unblock the anvil-aprz gate by eliminating the flagged crates from the dependency graph.
Changes:
- Replace
directories::BaseDirsusage with a newcommands::cache_dirmodule that resolves the platform cache directory via environment variables. - Replace
humantime-serdewith a newcommands::durationmodule providing a compatible<amount><unit>duration grammar and improved error messages. - Remove the corresponding dependencies from
Cargo.toml/Cargo.lockand update snapshots/spellings accordingly.
File summaries
| File | Description |
|---|---|
| crates/cargo-aprz-lib/src/commands/snapshots/cargo_aprz_lib__commands__validate__tests__invalid_duration_format.snap | Updates snapshot to match the new duration parsing error message. |
| crates/cargo-aprz-lib/src/commands/mod.rs | Registers new cache_dir and duration modules. |
| crates/cargo-aprz-lib/src/commands/duration.rs | Adds custom Serde duration parsing/formatting to replace humantime-serde. |
| crates/cargo-aprz-lib/src/commands/config.rs | Switches duration fields to use #[serde(with = "super::duration")]. |
| crates/cargo-aprz-lib/src/commands/common.rs | Uses platform_cache_dir() for default cache-dir resolution and updates related tests. |
| crates/cargo-aprz-lib/src/commands/cache_dir.rs | Adds platform cache-dir discovery implementation (env-based) to replace directories. |
| crates/cargo-aprz-lib/Cargo.toml | Drops directories and humantime-serde direct dependencies. |
| Cargo.toml | Removes workspace dependency entries for directories and humantime-serde. |
| Cargo.lock | Removes directories, humantime(-serde), and transitive dependencies from the lockfile. |
| .spelling | Adds serializer and XDG to spelling allow-list. |
Review details
- Files reviewed: 9/10 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Codecov Report❌ Patch coverage is
❌ Your project status has failed because the head coverage (97.6%) is below the target coverage (100.0%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #145 +/- ##
=======================================
- Coverage 97.6% 97.6% -0.1%
=======================================
Files 290 297 +7
Lines 65913 67008 +1095
=======================================
+ Hits 64370 65423 +1053
- Misses 1543 1585 +42
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The cache-directory test resolved the platform default with `expect`, so a stripped environment with no `LOCALAPPDATA`, `HOME` or `XDG_CACHE_HOME` failed the test rather than exercising the documented behaviour. It now accepts both answers, which also covers the error branch of `resolve_cache_dir`. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🔵 Needs a closer look
The newly introduced cache-dir discovery failure message is not actionable enough for users in stripped/sandboxed environments where --cache-dir is required.
Review details
Suppressed comments (1)
Previously missed (1) — in code that hasn't changed since the last review.
crates/cargo-aprz-lib/src/commands/common.rs:311
- The error returned when no platform cache directory can be discovered is vague. Since
platform_cache_dir()can legitimately returnNonein stripped/sandboxed environments, this message should tell the user how to fix it (e.g., pass--cache-diror set the relevant environment variables).
- Files reviewed: 9/10 changed files
- Comments generated: 0 new
- Review effort level: Lite
🤖 Clawpilot here! Posted automatically by Clawpilot (an AI agent), not by a human. Please verify before acting.
Fixes AB#7829436.
Problem
The scheduled
anvil-aprzgate has been red onmainfor eight consecutive runs (run 33601935927):All three enter through
cargo-aprz-lib:directoriesandhumantime-serdeare direct workspace dependencies, andoption-ext(MPL-2.0) is transitive viadirectories.Why not just wait for a tool release
Both advisories are withdrawn upstream — RUSTSEC-2020-0054 on 2021-04-19 and RUSTSEC-2025-0014 on 2025-03-12 — so the released
cargo-aprz1.1.0 that the gate installs is acting on retracted data. The in-repo source already ignores withdrawn advisories and already allows MPL-2.0, but that is unreleased, andjustfiles/anvil/versions.justpinscargo_aprz_version := "1.1.0".Rather than block the gate on a tool release, this removes the dependencies. Each was used for one small thing, so the work item's guardrail against
allow_list/cargo-deny/baseline suppression is respected: the crates are gone from the graph, not excused.Changes
commands::cache_dirreplacesdirectories::BaseDirs::cache_dir(), the crate's only use ofdirectories. It readsLOCALAPPDATAon Windows,HOME/Library/Cacheson macOS, andXDG_CACHE_HOME(absolute only, per the XDG specification) falling back toHOME/.cacheelsewhere. An empty variable counts as unset.commands::durationreplaceshumantime-serde, used by the five*_cache_ttlfields. It reads and writes the same<amount><unit>grammar, so existing configuration files (crates_cache_ttl = "1 week") keep working, including themminutes /Mmonths case distinction. Its rejection message now names the offending value, which is the one visible behaviour change — see the updated snapshot.Dropping
directoriesalso drops the MPL-2.0option-ext, matching the precedent set by #120 (MPL-2.0vlenreplaced with 0BSDvu128).Cargo.locklosesdirectories,dirs-sys,option-ext,humantimeandhumantime-serde.Effects
anvil-aprzno longer sees them regardless of whichcargo-aprzversion is pinned.%LOCALAPPDATA%from the environment instead of the known-folder API. In practice these agree; an environment that clears the variable now falls back to an explicit--cache-dirinstead of the known-folder value.Validation
just anvil-clippy— cleanjust test—cargo-aprz-libfully green (831 unit + all integration tests). Fourcargo-gamma-libfailures reproduce independently of this change; they assert an unconfigured cargo environment and fail on this machine because of a global~/.cargo/config.toml.just format,just anvil-cargo-sort,just spellcheck— clean (serializerandXDGadded to.spelling)cargo doc— cleanPer
AGENTS.md,CHANGELOG.mdis not edited by hand.