Docs.rs automatically builds documentation for crates released on crates.io. It may take a while to build your crate, depending on how many crates are in the queue.
All crates are built in a sandbox using the nightly release of the Rust compiler.
The current version in use is
rustc 1.72.0-nightly (498553fc0 2023-05-29).
The README of a crate is taken from the
readme field defined in
Cargo.toml. If this field is not set, no README will be displayed.
To recognize Docs.rs from
build.rs files, you can test for the environment variable
This approach can be helpful if you need dependencies for building the library, but not for building the documentation.
All targets other than
x86_64-unknown-linux-gnu are cross-compiled. For implementation reasons, this is unlikely to change for the foreseeable future.
You can configure how your crate is built by adding package metadata to your
Here, the compiler arguments are set so that
 = ["--cfg", "docsrs"]
#[cfg(docsrs)](not to be confused with
#[cfg(doc)]) can be used for conditional compilation. This approach is also useful for setting cargo features.
The Docs.rs README describes how to build unpublished crate documentation locally using the same build environment as the Docs.rs build agent.
Missing dependencies are a common reason for failed builds. Docs.rs dependencies are managed through crates-build-env. See Forge for how to add a dependency.
Most of the sandbox is a read-only file system, including the source directory of your crate and its dependencies.
build.rs generates files that are relevant for documentation, consider writing to the
cargo output directory,
passed in the environment variable
All the builds are executed inside a sandbox with limited resources. The current limits are:
|Available RAM||3 GB|
|Maximum rustdoc execution time||15 minutes|
|Maximum size of a build log||100 KB|
|Maximum number of build targets||10|
If your build fails because it hit one of these limits, please open an issue to get them increased for your crate. Since our build agent has finite resources, we have to consider each case individually. However, there are a few general policies:
If your crate fails to build for a reason not listed here, please file an issue. Some build failures can be fixed by Docs.rs, e.g., by issuing a rebuild after a bug in Docs.rs has been fixed.