Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs.rs failing to compile dependent crate #240

Closed
spadarian opened this issue Jan 12, 2022 · 17 comments
Closed

docs.rs failing to compile dependent crate #240

spadarian opened this issue Jan 12, 2022 · 17 comments

Comments

@spadarian
Copy link
Contributor

Hello everyone. I hope you are having a good start to the year.

I'm having problems compiling the docs for my crate (map-engine) probably because docs.rs' build system doesn't have GDAL installed.

I saw that you guys have a custom build script that mentions a similar (?) problem. I was hoping that docs.rs would execute that and that everything would work 😄

I also noticed that many of the crates that depend on gdal (not as a development dependency) have the same problem.

Do you have any recommendations on how to deal with this?

For future reference, I also created an issue on their repo: rust-lang/docs.rs#1591

Thanks

@lnicola
Copy link
Member

lnicola commented Jan 12, 2022

Looks like we're taking this branch in the gdal (not gdal-sys) build script.

We'll probably get a linker error if we look at DOCS_RS instead. Maybe we should remove the version check?

@lnicola
Copy link
Member

lnicola commented Jan 12, 2022

@spadarian can you add

[package.metadata.docs.rs]
rustdoc-args = ["--cfg", "docsrs"]

to your manifest?

@spadarian
Copy link
Contributor Author

I will give that a try tomorrow.

Is there a way of checking if that works locally? I guess I can use their docker container...

Just to confirm... not rustc-args = ["--cfg", "docsrs"] like you have in your Cargo.toml?

@rmanoka
Copy link
Contributor

rmanoka commented Jan 12, 2022

I also have the same problem in rasters crate. I have included the [package.metadata.docs.rs] section, but the build still errors out.

The previous version of the crate (which used gdal 0.7.2) did build successfully: https://docs.rs/crate/rasters/0.6.2 . Upgrading to latest, broke docs. For reference, snippet from the build-logs:

env/linux@sha256:a429bb59b7a3b4e7270a4b4c243bb115fc561d8f62ec34ef63a0a36cabf65dfd" "/opt/rustwide/cargo-home/bin/cargo" "+nightly" "rustdoc" "--lib" "-Zrustdoc-map" "--all-features" "-Z" "unstable-options" "--config" "build.rustflags=[\"--cfg\", \"docsrs\"]" "--config" "build.rustdocflags=[\"-Z\", \"unstable-options\", \"--emit=invocation-specific\", \"--resource-suffix\", \"-20220106-1.59.0-nightly-cfa4ac66c\", \"--static-root-path\", \"/\", \"--cap-lints\", \"warn\", \"--disable-per-crate-search\"]" "-Zunstable-options" "--config=doc.extern-map.registries.crates-io=\"https://docs.rs/{pkg_name}/{version}/x86_64-unknown-linux-gnu\"" "-j3" "--target" "x86_64-unknown-linux-gnu", kill_on_drop: false }`
.......   removed irrelevant lines from the log .......
[INFO] [stderr]   = note: /usr/bin/ld: /opt/rustwide/target/debug/build/gdal-4a35e4eaea3e24c0/build_script_build-4a35e4eaea3e24c0.build_script_build.636fb01f-cgu.3.rcgu.o: in function `build_script_build::gdal_version_info':
[INFO] [stderr]           /opt/rustwide/cargo-home/registry/src/gh.neting.cc-1ecc6299db9ec823/gdal-0.11.0/build.rs:13: undefined reference to `GDALVersionInfo'
[INFO] [stderr]           collect2: error: ld returned 1 exit status

The section above the ........ in the snippet shows that --cfg docsrs is indeed being passed to rustflags, but it still seems to be picking the wrong flavour of the function in gdal/build.rs.

EDIT: add details on docs build failure

@rmanoka
Copy link
Contributor

rmanoka commented Jan 12, 2022

I seem to have added rustc-args = [...], which worked in previous versions of the rasters crate (that uses gdal 0.7.2).
However, I tried locally (as explained using docs.rs github) using rustdoc-args = [...] and it still fails.

Intersetingly, even the previous version that did build successfully on docs.rs now fails when tried locally. It suggests that this may be a bug in the docs.rs build process.

@spadarian
Copy link
Contributor Author

Apparently, the guys from docs.rs have reported a bug in cargo, which is still blocked on rust-lang/cargo#10206

@rmanoka
Copy link
Contributor

rmanoka commented Apr 20, 2022

The cargo issue above seems to be fixed now; should it work now?

@spadarian
Copy link
Contributor Author

I tried locally and it still fails...

@jdroenner
Copy link
Member

jdroenner commented Apr 20, 2022

i think we had that issue before... maybe docs.rs needs some time to update

spadarian added a commit to spadarian/gdal that referenced this issue May 15, 2022
@rmanoka
Copy link
Contributor

rmanoka commented Jun 21, 2022

The cargo issue is fixed but docs.rs may also need to fix things (ref. rust-lang/docs.rs#1580 , rust-lang/docs.rs#1591).

@pka
Copy link
Member

pka commented Jul 21, 2022

Builds are still failing (https://docs.rs/crate/geozero/0.9.5-beta1/builds/597082)

@rmanoka
Copy link
Contributor

rmanoka commented Jul 23, 2022

I noticed this fix in proc-macro2 crate that has a similar problem. Would it work for us?
https://github.com/dtolnay/proc-macro2/pull/310/files

@spadarian
Copy link
Contributor Author

spadarian commented Jul 24, 2022

It wouldn't work. The compiler would try to compile both branches of the if statement (checking for DOCS_RS), failing to find gdal_sys::GDALVersionInfo.

spadarian added a commit to spadarian/gdal that referenced this issue Jul 24, 2022
@rmanoka
Copy link
Contributor

rmanoka commented Sep 3, 2022

@spadarian @pka can you check your gdal-dependent crates and verify the docs do build? I checked rasters.rs locally and it builds; it doesn't even seem to need the rustc-args configuration anymore.

@pka
Copy link
Member

pka commented Sep 4, 2022

docs.rs build for geozero is working again, thanks!

@spadarian
Copy link
Contributor Author

spadarian commented Sep 8, 2022 via email

@rmanoka
Copy link
Contributor

rmanoka commented Sep 8, 2022

Great! Closing this as completed.

@rmanoka rmanoka closed this as completed Sep 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants