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

Cannot compile due to chrono issue #1451

Closed
DMaxter opened this issue Mar 29, 2024 · 7 comments · Fixed by #1458
Closed

Cannot compile due to chrono issue #1451

DMaxter opened this issue Mar 29, 2024 · 7 comments · Fixed by #1458
Labels
bug Something isn't working dependencies upgrades to dependencies

Comments

@DMaxter
Copy link

DMaxter commented Mar 29, 2024

Current and expected behavior

When setting the dependencies as in the README, I get this error:

error[E0412]: cannot find type `TimeDelta` in crate `chrono`
   --> /home/daniel/.cargo/registry/src/index.crates.io-6f17d22bba15001f/kube-client-0.89.0/src/client/auth/mod.rs:177:28
    |
177 | pub const TEN_SEC: chrono::TimeDelta = const_unwrap!(Duration::try_seconds(10));
    |                            ^^^^^^^^^ not found in `chrono`

error[E0412]: cannot find type `TimeDelta` in crate `chrono`
   --> /home/daniel/.cargo/registry/src/index.crates.io-6f17d22bba15001f/kube-client-0.89.0/src/client/auth/mod.rs:179:26
    |
179 | const SIXTY_SEC: chrono::TimeDelta = const_unwrap!(Duration::try_seconds(60));
    |                          ^^^^^^^^^ not found in `chrono`

error[E0599]: no function or associated item named `try_seconds` found for struct `chrono::Duration` in the current scope
   --> /home/daniel/.cargo/registry/src/index.crates.io-6f17d22bba15001f/kube-client-0.89.0/src/client/auth/mod.rs:177:64
    |
177 | pub const TEN_SEC: chrono::TimeDelta = const_unwrap!(Duration::try_seconds(10));
    |                                                                ^^^^^^^^^^^ function or associated item not found in `Duration`
    |
note: if you're trying to build a new `chrono::Duration` consider using one of the following associated functions:
      chrono::Duration::weeks
      chrono::Duration::days
      chrono::Duration::hours
      chrono::Duration::minutes
      and 8 others
   --> /home/daniel/.cargo/registry/src/index.crates.io-6f17d22bba15001f/chrono-0.4.24/src/oldtime.rs:77:5
    |
77  |     pub fn weeks(weeks: i64) -> Duration {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
86  |     pub fn days(days: i64) -> Duration {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
95  |     pub fn hours(hours: i64) -> Duration {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
104 |     pub fn minutes(minutes: i64) -> Duration {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: there is an associated function `seconds` with a similar name
    |
177 | pub const TEN_SEC: chrono::TimeDelta = const_unwrap!(Duration::seconds(10));
    |                                                                ~~~~~~~

error[E0599]: no function or associated item named `try_seconds` found for struct `chrono::Duration` in the current scope
   --> /home/daniel/.cargo/registry/src/index.crates.io-6f17d22bba15001f/kube-client-0.89.0/src/client/auth/mod.rs:179:62
    |
179 | const SIXTY_SEC: chrono::TimeDelta = const_unwrap!(Duration::try_seconds(60));
    |                                                              ^^^^^^^^^^^ function or associated item not found in `Duration`
    |
note: if you're trying to build a new `chrono::Duration` consider using one of the following associated functions:
      chrono::Duration::weeks
      chrono::Duration::days
      chrono::Duration::hours
      chrono::Duration::minutes
      and 8 others
   --> /home/daniel/.cargo/registry/src/index.crates.io-6f17d22bba15001f/chrono-0.4.24/src/oldtime.rs:77:5
    |
77  |     pub fn weeks(weeks: i64) -> Duration {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
86  |     pub fn days(days: i64) -> Duration {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
95  |     pub fn hours(hours: i64) -> Duration {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
104 |     pub fn minutes(minutes: i64) -> Duration {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: there is an associated function `seconds` with a similar name
    |
179 | const SIXTY_SEC: chrono::TimeDelta = const_unwrap!(Duration::seconds(60));
    |                                                              ~~~~~~~

Some errors have detailed explanations: E0412, E0599.
For more information about an error, try `rustc --explain E0412`.
error: could not compile `kube-client` (lib) due to 4 previous errors

Possible solution

No response

Additional context

No response

Environment

Not relevant as it didn't even compile

Configuration and features

k8s-openapi = { version = "0.21.1", features = ["latest"] }
kube = "0.89.0"

even with

k8s-openapi = { git = "https://github.com/Arnavion/k8s-openapi", rev = "3920325bc3d89d234f39b166628c388de99cd9a0" }
kube = { git = "https://github.com/kube-rs/kube", rev = "ff5a9e4d1348b1129123a5df24331ea6047468f9" }

it is not possible, but the error is because Cargo can't find a version that satisfies both kube and k8s-openapi

Affected crates

kube-client

Would you like to work on fixing this bug?

maybe

@DMaxter DMaxter added the bug Something isn't working label Mar 29, 2024
@clux
Copy link
Member

clux commented Mar 29, 2024

try upgrading chrono first, we did do some stuff with chrono to avoid new lint warnings

@DMaxter
Copy link
Author

DMaxter commented Mar 29, 2024

How can I upgrade chrono if it's being pulled automatically by both crates?

@clux
Copy link
Member

clux commented Mar 29, 2024

I assume you have a pin for it in your lock file. The chrono::TimeDelta struct does exist in the last version.

@clux
Copy link
Member

clux commented Mar 29, 2024

so I think what happens here is that chrono::TimeDelta was missing in chrono 0.4.33 (a semver compatible version) and added in 0.4.34. So when you upgrade kube/k8s-openapi cargo doesn't force you to also upgrade chrono because chrono have not indicated they have added anything by making a semver-minor (and we accidentally started relying on a new feature without knowing it was a new feature).

If you run cargo update chrono it will fix the issue and bump the pin in your lockfile (without needing an explicit dependency on chrono in your Cargo.toml).

@clux clux closed this as completed Mar 29, 2024
@clux clux added the dependencies upgrades to dependencies label Mar 29, 2024
@DMaxter
Copy link
Author

DMaxter commented Mar 29, 2024

Thank you, completely forgot about the lockfile

@roy-work
Copy link

roy-work commented Apr 2, 2024

kube-client specifies,

chrono = { version = "0.4.32", default-features = false }

As @clux says above, TimeDelta isn't added until 0.4.34.

kube-client could just depend on 0.4.34 — it isn't compatible with 0.4.32, so specifying that as a version doesn't make much practical sense as it'll never work, and if you specify 0.4.34 then cargo will just do the right thing & realize the locked version will never work. I.e., you should never need to remember the lockfile.

It'd be nice if kube-rs would just consider this a bug, to avoid all downstream users from having to manually handle this.

(chrono here is pre-1.0, so backwards-compatible versions — i.e., adding a feature — wouldn't bump the minor. Cargo's consideration of 0.x.y versions is slightly different than the SemVer.org spec.)

clux added a commit that referenced this issue Apr 2, 2024
0.4.32 won't work anymore. for #1451

Signed-off-by: clux <sszynrae@gmail.com>
@clux
Copy link
Member

clux commented Apr 2, 2024

That's a good point, thank you. I'll bump the entry for it.

@clux clux linked a pull request Apr 2, 2024 that will close this issue
clux added a commit that referenced this issue Apr 2, 2024
set a more sensible minimum chrono version

0.4.32 won't work anymore. for #1451

Signed-off-by: clux <sszynrae@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working dependencies upgrades to dependencies
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants