Arnavion / k8s-openapi

Rust definitions of the resource types in the Kubernetes client API
Apache License 2.0
379 stars 41 forks source link

Build script fails for v0.12.0 #100

Closed toksdotdev closed 3 years ago

toksdotdev commented 3 years ago

I've been getting compilation error for the recent release of v0.12.0 with the following error

--- stderr
  thread 'main' panicked at '
  None of the v1_* features are enabled on the k8s-openapi crate.

  The k8s-openapi crate requires a feature to be enabled to indicate which version of Kubernetes it should support.

  If you're using k8s-openapi in a binary crate, enable the feature corresponding to the minimum version of API server that you want to support. It may be possible that your binary crate does not directly depend on k8s-openapi. In this case, add a dependency on k8s-openapi, then enable the corresponding feature.

  If you're using k8s-openapi in a library crate, add a dev-dependency on k8s-openapi and enable one of the features there. This way the feature will be enabled when buildings tests and examples of your library, but not when building the library itself. It may be possible that your library crate does not directly depend on k8s-openapi. In this case, add a dev-dependency on k8s-openapi, then enable the corresponding feature.

  Library crates *must not* enable any features in their direct dependency on k8s-openapi, only in their dev-dependency. The choice of Kubernetes version to support should be left to the final binary crate, so only the binary crate should enable a specific feature. If library crates also enable features, it can cause multiple features to be enabled simultaneously, which k8s-openapi does not support.

  If you want to restrict your library crate to support only a single specific version or range of versions of Kubernetes, please use the k8s_* version-specific macros to emit different code based on which feature gets enabled in the end.', /Users/justdoit/.cargo/registry/src/github.com-1ecc6299db9ec823/k8s-openapi-0.11.0/build.rs:10:42

Although, something I noticed is that it keeps running the v0.11.0's build.rs.

Here is an extract from my Cargo.toml

[dependencies]
kube = { version = "0.56.0"}
kube-runtime = "0.56.0"
k8s-openapi = { version = "0.12.0", default-features = false, features = ["v1_21"] }

I've also attempted removing v0.11.0 from the cache directory, but it keeps installing it back.

I also noticed that during my build, it compiles for both v0.11.0 and v0.12.0 as shown below, which is weird because I didn't add v0.11.0 to my Cargo.toml.

Compiling k8s-openapi v0.11.0   -----------------> here
Compiling pin-project-internal v0.4.28 
Compiling k8s-openapi v0.12.0  -----------------> here

As an attempt to debug what is wrong, I downgraded back to v0.11.0, with features = ["v1_20"], and the build script executes successfully.

clux commented 3 years ago

kube or kube-runtime has not been updated to support the new k8s-openapi version yet, however an initial change is in master.

Please either pin your kube versions to git master, or wait a little bit with upgrading k8s-openapi with kube.

EDIT: kube and kube-runtime at 0.57.0 will now work.

Arnavion commented 3 years ago

As clux said, kube is pulling in the k8s-openapi 0.11 dep. Your error is coming from 0.11's build script, not 0.12's, because by switching your crate's dep on k8s-openapi to 0.12 you've stopped enabling any version features for the 0.11 dep of kube. If your goal is to use k8s-openapi with kube, then you're restricted to using the version of k8s-openapi matching kube's dep anyway.