rust-windowing / winit

Window handling library in pure Rust
https://docs.rs/winit/
Apache License 2.0
4.84k stars 903 forks source link

winit 0.28.7 cause docs.rs build failure #3173

Closed abey79 closed 1 year ago

abey79 commented 1 year ago

Several projects depending on winit 0.28.7 (including mine) appear to fail to build on https://docs.rs due to a winit error:

Examples:

The following error occurs:

winit-0.28.7/src/platform_impl/mod.rs:67:1
[INFO] [stderr]    |
[INFO] [stderr] 67 | compile_error!("The platform you're compiling for is not supported by winit");
[INFO] [stderr]    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

It may be be caused by x11_platform failing to be set on headless linux hosts.

I observed a similar behaviour running cargo doc on ubuntu-latest GitHub Actions runner. In this case, the workaround was to use macos-latest for cargo doc.

king0952 commented 1 year ago

Add these lines in Cargo.toml, it currently works for me:

[dependencies.winit]
# version = "*"
version = "=0.28.7"
features = ["default"]

And then cargo update

  Updating crates.io index
  Removing android-activity v0.5.0
  Removing as-raw-xcb-connection v1.0.0
  Removing atomic-waker v1.1.2
  Removing block-sys v0.2.0
  Removing block2 v0.3.0
Downgrading calloop v0.12.3 -> v0.10.6
  Removing calloop-wayland-source v0.2.0
  Removing core-graphics v0.23.1
  Removing cursor-icon v1.0.0
  Removing foreign-types v0.5.0
  Removing foreign-types-macros v0.2.3
  Removing foreign-types-shared v0.3.1
  Removing gethostname v0.3.0
  Removing icrate v0.0.4
Downgrading memmap2 v0.9.0 -> v0.5.10
  Removing ndk v0.8.0
  Removing ndk-sys v0.5.0+25.2.9519653
    Adding nix v0.25.1
  Removing num_enum v0.7.0
  Removing num_enum_derive v0.7.0
  Removing objc-sys v0.3.1
  Removing objc2 v0.4.1
  Removing objc2-encode v3.0.0
  Removing polling v3.2.0
  Removing raw-window-handle v0.6.0
Downgrading sctk-adwaita v0.7.0 -> v0.5.4
Downgrading smithay-client-toolkit v0.18.0 -> v0.16.1
Downgrading tiny-skia v0.11.2 -> v0.8.4
Downgrading tiny-skia-path v0.11.2 -> v0.8.4
    Adding vec_map v0.8.2
  Removing wayland-backend v0.3.2
Downgrading wayland-client v0.31.1 -> v0.29.5
    Adding wayland-commons v0.29.5
  Removing wayland-csd-frame v0.3.0
Downgrading wayland-cursor v0.31.0 -> v0.29.5
Downgrading wayland-protocols v0.31.0 -> v0.29.5
  Removing wayland-protocols-plasma v0.2.0
  Removing wayland-protocols-wlr v0.2.0
  Removing wayland-scanner v0.31.0
Downgrading wayland-sys v0.31.1 -> v0.29.5
  Removing web-time v0.2.2
  Removing winit v0.29.2
  Removing x11rb v0.12.0
  Removing x11rb-protocol v0.12.0
  Removing xkbcommon-dl v0.4.1
  Removing xkeysym v0.2.0
abey79 commented 1 year ago

This didn't help unfortunately: https://github.com/abey79/vsvg/pull/59

kchibisov commented 1 year ago

you need to enable one of the platforms in winit to build.

abey79 commented 1 year ago

you need to enable one of the platforms in winit to build.

How would I go about that? Everything generally just works for building/testing/etc. Building docs specifically fails, and in the case of docs.rs, I obviously don't have any control on the environment.

kchibisov commented 1 year ago

Are you sure that you have features enabled for winit when building? You should pass either x11 or wayland when building for linux platform. Just regular docs to build fine.

abey79 commented 1 year ago

Running on my project's CI, I've explicitly added "x11" and "default" in my Cargo.toml. All the builds work, except cargo docs, even though all builds are running on ubuntu-latest.

kchibisov commented 1 year ago

Maybe you disable features when building docs? Winit itself builds its docs just fine and we also build its docs just fine.