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

Open
#796 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
56/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
rust

Research direction

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.

Written by the indexing model from the issue text.

Description

.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.

Dominant language
Rust
Stars
847
Forks
174
Avg merge
5h 40m
Merged PRs (30d)
167

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

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.

More from laravel/rust-framework

All issues in laravel/rust-framework

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.