containers / podlet

Generate Podman Quadlet files from a Podman command, compose file, or existing object
https://crates.io/crates/podlet
Mozilla Public License 2.0
422 stars 12 forks source link

Fails to compile v0.2.4 and v0.2.3. Error[E0308]: mismatched types #69

Closed adhadse closed 5 months ago

adhadse commented 6 months ago

I was tying to install podlet with rustc (1.77.0) and encountered this error.

cargo install podlet --version 0.2.3
  Downloaded podlet v0.2.3
  Downloaded 1 crate (344.7 KB) in 2.29s
    Updating crates.io index
  Installing podlet v0.2.3
    Updating crates.io index
  Downloaded bytes v1.6.0
  Downloaded k8s-openapi v0.20.0
  Downloaded 2 crates (3.3 MB) in 1.02s (largest was `k8s-openapi` at 3.3 MB)
   Compiling proc-macro2 v1.0.79
   Compiling unicode-ident v1.0.12
   Compiling autocfg v1.1.0
   Compiling pin-project-lite v0.2.13
   Compiling libc v0.2.153
   Compiling syn v1.0.109
   Compiling cfg-if v1.0.0
   Compiling serde v1.0.197
   Compiling crossbeam-utils v0.8.19
   Compiling parking v2.2.0
   Compiling once_cell v1.19.0
   Compiling futures-core v0.3.30
   Compiling memchr v2.7.1
   Compiling tracing-core v0.1.32
   Compiling version_check v0.9.4
   Compiling hashbrown v0.14.3
   Compiling num-traits v0.2.18
   Compiling equivalent v1.0.1
   Compiling typenum v1.17.0
   Compiling generic-array v0.14.7
   Compiling concurrent-queue v2.4.0
   Compiling quote v1.0.35
   Compiling syn v2.0.55
   Compiling indexmap v2.2.6
   Compiling futures-io v0.3.30
   Compiling ident_case v1.0.1
   Compiling toml_datetime v0.6.5
   Compiling strsim v0.10.0
   Compiling winnow v0.5.40
   Compiling fnv v1.0.7
   Compiling event-listener v4.0.3
   Compiling slab v0.4.9
   Compiling event-listener-strategy v0.4.0
   Compiling event-listener v5.2.0
   Compiling io-lifetimes v1.0.11
   Compiling lazy_static v1.4.0
   Compiling event-listener v2.5.3
   Compiling fastrand v2.0.2
   Compiling event-listener-strategy v0.5.0
   Compiling sharded-slab v0.1.7
   Compiling async-lock v3.3.0
   Compiling aho-corasick v1.1.3
   Compiling getrandom v0.2.12
   Compiling memoffset v0.7.1
   Compiling polling v2.8.0
   Compiling futures-lite v2.3.0
   Compiling toml_edit v0.19.15
   Compiling thread_local v1.1.8
   Compiling utf8parse v0.2.1
   Compiling atomic-waker v1.1.2
   Compiling regex-syntax v0.8.2
   Compiling cc v1.0.90
   Compiling waker-fn v1.1.1
   Compiling tinyvec_macros v0.1.1
   Compiling itoa v1.0.10
   Compiling async-task v4.7.0
   Compiling rustix v0.37.27
   Compiling fastrand v1.9.0
   Compiling ryu v1.0.17
   Compiling bitflags v1.3.2
   Compiling futures-lite v1.13.0
   Compiling tinyvec v1.6.0
   Compiling darling_core v0.14.4
   Compiling zvariant_utils v1.0.1
   Compiling proc-macro-crate v1.3.1
   Compiling backtrace v0.3.71
   Compiling piper v0.2.1
   Compiling regex-automata v0.4.6
   Compiling anstyle-parse v0.2.3
   Compiling tracing-subscriber v0.3.18
   Compiling rand_core v0.6.4
   Compiling block-buffer v0.10.4
   Compiling crypto-common v0.1.6
   Compiling async-channel v2.2.0
   Compiling async-lock v2.8.0
   Compiling async-fs v1.6.0
   Compiling async-io v1.13.0
   Compiling byteorder v1.5.0
   Compiling static_assertions v1.1.0
   Compiling colorchoice v1.0.0
   Compiling ppv-lite86 v0.2.17
   Compiling async-trait v0.1.79
   Compiling serde_derive v1.0.197
   Compiling tracing-attributes v0.1.27
   Compiling enumflags2_derive v0.7.9
   Compiling gimli v0.28.1
   Compiling zvariant_derive v3.15.2
   Compiling darling_macro v0.14.4
   Compiling anstyle v1.0.6
   Compiling linux-raw-sys v0.3.8
   Compiling darling v0.14.4
   Compiling derive_builder_core v0.13.1
   Compiling anstyle-query v1.0.2
   Compiling log v0.4.21
   Compiling tracing v0.1.40
   Compiling thiserror v1.0.58
   Compiling adler v1.0.2
   Compiling rust_decimal v1.34.3
   Compiling serde_json v1.0.114
   Compiling eyre v0.6.12
   Compiling miniz_oxide v0.7.2
   Compiling blocking v1.5.1
   Compiling derive_builder_macro v0.13.1
   Compiling addr2line v0.21.0
   Compiling tracing-error v0.2.0
   Compiling anstream v0.6.13
   Compiling regex v1.10.4
   Compiling rand_chacha v0.3.1
   Compiling thiserror-impl v1.0.58
   Compiling digest v0.10.7
   Compiling unicode-normalization v0.1.23
   Compiling ordered-float v2.10.1
   Compiling socket2 v0.4.10
   Compiling object v0.32.2
   Compiling minimal-lexical v0.2.1
   Compiling futures-task v0.3.30
   Compiling futures-sink v0.3.30
   Compiling percent-encoding v2.3.1
   Compiling unicode-bidi v0.3.15
   Compiling arrayvec v0.7.4
   Compiling strsim v0.11.0
   Compiling k8s-openapi v0.20.0
   Compiling unsafe-libyaml v0.2.11
   Compiling cpufeatures v0.2.12
   Compiling clap_lex v0.7.0
   Compiling owo-colors v3.5.0
   Compiling pin-utils v0.1.0
   Compiling rustc-demangle v0.1.23
   Compiling indenter v0.3.3
   Compiling heck v0.5.0
   Compiling clap_derive v4.5.3
   Compiling color-spantrace v0.2.1
   Compiling futures-util v0.3.30
   Compiling clap_builder v4.5.2
   Compiling sha1 v0.10.6
   Compiling idna v0.5.0
   Compiling enumflags2 v0.7.9
   Compiling zvariant v3.15.2
   Compiling serde-value v0.7.0
   Compiling chrono v0.4.35
   Compiling serde_yaml v0.9.33
   Compiling form_urlencoded v1.2.1
   Compiling zbus_names v2.6.1
   Compiling nom v7.1.3
   Compiling zbus_macros v3.15.2
   Compiling nix v0.26.4
   Compiling rand v0.8.5
   Compiling derive_builder v0.13.1
   Compiling derivative v2.2.0
   Compiling serde_repr v0.1.18
   Compiling async-recursion v1.1.0
   Compiling async-executor v1.8.0
   Compiling async-broadcast v0.5.1
   Compiling xdg-home v1.1.0
   Compiling ordered-stream v0.2.0
   Compiling base64 v0.21.7
   Compiling hex v0.4.3
   Compiling bytes v1.6.0
   Compiling docker-compose-types v0.7.2
   Compiling duration-str v0.7.1
   Compiling url v2.5.0
   Compiling clap v4.5.3
   Compiling color-eyre v0.6.3
   Compiling ipnet v2.9.0
   Compiling shlex v1.3.0
   Compiling zbus v3.15.2
   Compiling podlet v0.2.3
error[E0308]: mismatched types
   --> /home/adhadse/.cargo/registry/src/index.crates.io-6f17d22bba15001f/podlet-0.2.3/src/cli/container/quadlet.rs:598:25
    |
598 |               log_driver: service
    |  _________________________^
599 | |                 .logging
600 | |                 .as_mut()
601 | |                 .map(|logging| mem::take(&mut logging.driver)),
    | |______________________________________________________________^ expected `Option<String>`, found `Option<Option<String>>`
    |
    = note: expected enum `std::option::Option<std::string::String>`
               found enum `std::option::Option<std::option::Option<std::string::String>>`
help: consider using `Option::expect` to unwrap the `std::option::Option<std::option::Option<std::string::String>>` value, panicking if the value is an `Option::None`
    |
601 |                 .map(|logging| mem::take(&mut logging.driver)).expect("REASON"),
    |                                                               +++++++++++++++++

For more information about this error, try `rustc --explain E0308`.
error: could not compile `podlet` (bin "podlet") due to 1 previous error
error: failed to compile `podlet v0.2.3`, intermediate artifacts can be found at `/tmp/cargo-installfPsIOj`.
To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.

Similar case happens with version 0.2.4 as well.

k9withabone commented 6 months ago

Yeah, the docker-compose-types library keeps making breaking changes without respecting semver. I'm currently working on a replacement (compose_spec_rs) which is almost ready. Use cargo install --locked podlet for now.

adhadse commented 6 months ago

I instead opted for build and install of binstall and install podlet with binstall instead. Worked!

stephanbuys commented 6 months ago

@k9withabone I'm open to additional maintainers for the crate, I have very little free time and am perhaps a little over-enthusiastic with accepting contributions.

k9withabone commented 6 months ago

@stephanbuys The semver breaking wasn't the only reason I decided to start a new library. The compose_spec library has a bit of a different focus compared to docker-compose-types. It only supports the Compose specification instead of trying to simultaneously support past versions of docker compose as well. Also, it does full parsing and validation of fields with defined formats as opposed to just deserializing to a String or other basic type. Part of that is ensuring correctness, as much as possible, via types, like using enums for fields which conflict with each other. I also want the library to eventually support other things defined in the Compose specification like interpolation and merging.

The new library is almost ready for its first release if you want to take a look at it. To get docker-compose-types into a similar form would have basically required a complete rewrite, so it made more sense to make a new library.