eclipse / paho.mqtt.rust

paho.mqtt.rust
Other
516 stars 102 forks source link

Build fails on windows-latest (which is now windows-2022) #147

Closed stefangalowicz closed 1 year ago

stefangalowicz commented 2 years ago

The image windows-latest used to point to windows-2019, now it's windows-2022. This breaks the build of paho-mqtt-sys. Changing back to windows-2019 explicitly fixes the issue.

The change was announced here: https://github.com/actions/virtual-environments/issues/4856

The error message:

[...]
   Compiling crossbeam-channel v0.5.2
error: failed to run custom build command for `paho-mqtt-sys v0.6.0`

Caused by:
  process didn't exit successfully: `D:\a\anon\anon\repo\target\release\build\paho-mqtt-sys-0350774f96c83411\build-script-build` (exit code: 101)
  --- stdout
  debug:Running the bundled build for Paho C
  debug:Building for Windows
  debug:Building with MSVC
  cargo:rerun-if-changed=build.rs

  --- stderr
  fatal: not a git repository (or any of the parent directories): .git
  thread 'main' panicked at '

  couldn't determine visual studio generator
  if VisualStudio is installed, however, consider running the appropriate vcvars script before building this crate
  ', C:\Users\runneradmin\.cargo\registry\src\github.com-1ecc6299db9ec823\cmake-0.1.45\src\lib.rs:797:25
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: build failed
Error: Process completed with exit code 1.
phuongtran7 commented 2 years ago

I got the same problem. It seems that the error comes from the cmake crate, which paho-mqtt-sys relies on. It should be fixed in newer version of the cmake crate I think. Currently, my workaround is just clone this into local, change the version of cmake crate in the Cargo.toml of paho-mqtt-sys to 0.1.48, something like this:

cmake = { version = "0.1.48", optional = true }

Then just point to the local directory in the main application Cargo.toml. However, I only tested this workaround on Windows. Not sure about others.

fpagliughi commented 2 years ago

That's unfortunate. The last few versions of the cmake crate require a fairly recent version of cmake, which is newer than the version in a lot of Linux distributions. So, just upgrading the cmake dependency in paho-mqtt-sys would break the build for a lot of Linux systems at this point.

See: https://github.com/alexcrichton/cmake-rs/issues/131

phuongtran7 commented 2 years ago

I think this issue only occurs if VS22 is installed. I might be wrong as I haven't tested it yet, but seems that the current 1.0.45 version of the cmake crate doesn't recognize VS22.

I don't know whether there is a way to force using the newer version of the cmake crate when having VS22 in Cargo.toml. When I tried to use the patch feature or specify the version of the crate, it didn't work unfortunately.

fpagliughi commented 2 years ago

That would definitely make sense. But would it be fixed by installing a new version of CMake that came out after VS22, and supports it?

fpagliughi commented 2 years ago

I believe the cmake crate just runs whatever version of the CMake binary that’s installed on the system.

phuongtran7 commented 2 years ago

I just tried that and unfortunately, it still didn't work. The cmake crate panic in the visual_studio_generator() when it encountered VS22. The current installed CMake is 3.23, so it should support VS22.

fpagliughi commented 2 years ago

Oh, yeah. I guess on Windows the cmake crate needs to tell CMake which generator to use. That stinks. We'll have to look into whether the --parallel issue can be fixed upstream in the cmake crate. Either that or just break the build for older CMake's on the next release of this library.

JosuGZ commented 1 year ago

I got the same problem. It seems that the error comes from the cmake crate, which paho-mqtt-sys relies on. It should be fixed in newer version of the cmake crate I think. Currently, my workaround is just clone this into local, change the version of cmake crate in the Cargo.toml of paho-mqtt-sys to 0.1.48, something like this:

cmake = { version = "0.1.48", optional = true }

Then just point to the local directory in the main application Cargo.toml. However, I only tested this workaround on Windows. Not sure about others.

This works for me too.

fpagliughi commented 1 year ago

This fix should ship with v0.12

fpagliughi commented 1 year ago

Actually the backward-compatible fix was released in cmake v0.1.49. I updated the -sys crate to v0.7.2 with this fix. It is compatible with the main crate v0.11. So the fix should be available now on crates.io. Just do a cargo update.