How to tell docs.rs not to build dependencies?

Hi!

Today I published my first crate on crates.io. That went fine, but the documentation on docs.rs won't build. There is no problem building it locally.

As far as I understand, docs.rs tries to include the documentation of all dependencies, which fails because xkbcommon-sys is not installed there.
This is not what I want anyway, so what do I need to do to make docs.rs ommit all dependencies?

I tried to upload a new version with the following added to Cargo.toml:

[package.metadata.docs.rs]
cargo-args = ["--no-deps"]

but that just causes different build errors.

The build log can be found here: xkb_evdev_trans 0.1.0 - Docs.rs

I believe the recommended way to fix a missing dependency in the build environment is to add the dependency to it.

It does not document dependencies, but rustdoc still needs the crate metadata of all dependencies to be able to do macro expansion, resolve the types of items, for inlined documentation and for resolving intra-doc links.

This is not true; docs.rs builds each package’s documentation on its own. However, your package’s documentation can only be built if your package can be built. rustdoc is somewhat more lenient than a normal rustc build, but it still needs the dependencies to be present.

Thanks for the quick answers :slight_smile:

So the way forward would be to learn docker and make a PR for crates-build-env, right?

But one thing does not make sense to me:

[INFO] [stderr]   The system library `xkbcommon-x11` required by crate `xkbcommon-sys` was not found.

If it does not have xkbcommon-x11 already installed, why then is there documentation for xkbcommon-sys on docs.rs? Would that not have to fail for the same reason?

Yes. I'm not on Ubuntu, but I think the libxkbcommon-x11-dev package is required in your case and should be added somewhere here.

When building its documentation, xkbcommon-sys does not enable its x11 feature, which you do in your build.

Ok, now I understand.

I tried making a PR, but the documentation on how to build the docker-image (Adding dependencies to the build environment - Rust Forge) is out of date and I decided not to spend time to learn docker at the moment. Instead I opened an issue requesting the package.

Maybe I’ll self-host the documentation until that is done.

For cross-referencing purposes:

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.