`cargo doc` and doc tests fail on Windows because `scripts/rustdoc` is a bash script

Aperta
#796 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
56/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
rust

Direzione di ricerca

Read .cargo/config.toml and scripts/rustdoc to confirm how the custom rustdoc command is configured. Then inspect doc examples in the listed crates, starting with the two laravel-rust-cache examples and the 200 failures that use laravel::… paths; run the workspace doc tests without the script to check the changes. Done means Windows can run cargo doc and doc tests, with the workspace examples passing across platforms.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

.cargo/config.toml sets build.rustdoc = "scripts/rustdoc", and scripts/rustdoc is a bash script. Windows can't execute it, so every rustdoc run in this repository fails there: cargo doc and all doc tests.

> cargo doc --no-deps -p laravel-rust
 Documenting laravel-rust v0.1.6 (C:\...\rust-framework)
error: could not document `laravel-rust`

Caused by:
  could not execute process `C:\...\rust-framework\scripts/rustdoc --edition=2024 ...`

Caused by:
  %1 is not a valid Win32 application. (os error 193)

cargo test --workspace reports the same error as a doc test failure for 23 crates, although no doc test ran. CI runs on ubuntu-latest only, so it doesn't show up there. Applications that depend on laravel-rust aren't affected, since they don't read this config.

A way to drop the script

The script only points laravel at the facade for the internal crates' doc tests. An example can do the same with a hidden line, using the laravel_facade dev-dependency the crates already have:

/// ```
/// # use laravel_facade as laravel;
/// use laravel::{Application, cache::{MemoryStore, CacheManager}};
///
/// Application::configure().booted(|app| async move {
///     app.resolve::<CacheManager>().await?.add_store("sessions", MemoryStore::default());
///     Ok(())
/// });
/// ```

With that line in its 2 examples that reach outside the crate, laravel-rust-cache passes all 21 of its doc tests with RUSTDOC=rustdoc, so without the script.

Across the workspace, running the doc tests without the script, 1,038 pass and 200 fail. All 200 fail to resolve a laravel::… path outside their crate (laravel::model, laravel::http, laravel::prelude, …), so they are the examples that would take the line: 64 in database, 40 in http, 32 in core, 23 in schedule, 15 in search, and 26 across 7 other crates.

The script and the build.rustdoc setting could then go. A new example that forgets the line would fail in CI on every platform, rather than only on Windows.

Renaming the dev-dependency to laravel instead doesn't work: rustc then gets two laravel crates and fails with E0464: multiple candidates for rlib dependency laravel found, which I guess is why the script exists.

The cost is one hidden line in about 200 examples. If you'd rather keep the script, a .cmd counterpart would also work, but Cargo has no per-platform build.rustdoc, so Windows contributors would have to set RUSTDOC themselves.

I'm happy to send a PR for either.

Tested on Windows 11 with Rust 1.100.1, on 0.x at 213c0c6e.

Lingua principale
Rust
Stelle
847
Fork
174
Merge medio
5h 40m
PR unite (30g)
167

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di laravel/rust-framework

Tutte le issue di laravel/rust-framework

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.