Skip to content

rustdoc on a standalone markdown file fails with an unclear error message #70431

Closed
@TimotheeGerber

Description

@TimotheeGerber

I tried this command:

rustdoc README.md

I expected the command to finish without error and the creation of the file README.html or doc/README.html.

Instead, I got the following error message:

error: doc/README.html: No such file or directory (os error 2)

Indeed, this file does not exist and we expected the command to create it! The error message is not really helping in this case and does not explain that it cannot create the file because the directory doc/ does not exists.

When launched on a standalone markdown file, rustdoc expects the output directory to exist. It is not created if missing (as it is the case when launched on *.rs file or with cargo doc), even if we specify it with --output argument.

I see two solutions to the problem:

  • change the error message and tell the user that the output directory (which default to doc/) does not exist;
  • recursively create the output directory.

I can propose a PR to close this issue. I just need someone to tell me which solutions to code. I think that the second solution would be a better choice as it would be more consistent with the other rustdoc uses case (on *.rs files or with cargo doc) which create the output directory.

Meta

rustc --version --verbose:

rustc 1.44.0-nightly (a5fb9ae5b 2020-03-25)
binary: rustc
commit-hash: a5fb9ae5b2ed3cb011ada9dc1e8633aa0927f279
commit-date: 2020-03-25
host: x86_64-unknown-linux-gnu
release: 1.44.0-nightly
LLVM version: 9.0

This bug is also present on the current stable release (v 1.42).

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions