Cargo doc --open doesn't show dependency documentation

Description:

I'm learning Rust by following the official book at The Rust Programming Language - The Rust Programming Language and ran into confusion with cargo doc --open.

Issue: When I run cargo doc --open, it successfully documents all dependencies (I can see "Documenting rand v0.8.5" in the output), but it only opens my crate's documentation page. There's no visible way to navigate to the randdocumentation or other dependencies from the opened page.

Expected: Based on examples in the Rust book and docs.rs, I expected to see links or a sidebar to browse dependency documentation, similar to how docs.rs interconnects all crate docs.

Current Workaround: I have to manually open target/doc/rand/index.html or edit the URL path directly.

Question: Is this intended behavior? Is there a better way to access dependency documentation locally that I'm missing as a beginner?

Environment:

  • OS: macOS
  • Command: cargo doc --open

unless you are using custom style sheets, on the index page of your own crate (or of any crate, for that matter), on the left sidebar, where you have groups like "all items", "sections", "crate items", at the bottom of which should be a group labeled "crates", you'll find all the dependency crates in the list.

if you don't see them in the sidebar, can you check the content of the target/doc/crates.js file? it should contain a list of all the crates documented by cargo doc.

1 Like

I can confirm the same issue as @NabilJada . I do not use any custom style sheets and simply follow the Rust Book and the very first example with the Guessing Game implementation. After running cargo doc --open I see the following

There is no sidebar or any styling at all.

Same here, also on macOS

that's not how the page is supposed to look. the page should look the same as online documentation of crates on docs.rs and doc.rust-lang.org.

I wonder if there's some security settings that prevented the browser from loading the linked resources, particularly the css and js files.

do you see any errors in the browser's developer console?

This appears relevant, and the comments contain suggested solutions:

In particular:

On macOS Sonoma (14.1.1), Safari 17.1, you need to go to Settings and then the Advanced tab and enable

  • Show features for web developers

Setting up new computer on macOS 14.3. Turning on developer mode by itself did not fix my issue. But turning on developer mode then quitting Safari did fix it.

1 Like