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

Enable std/alloc without other features like chrono #550

Closed
M1cha opened this issue Feb 20, 2023 · 4 comments
Closed

Enable std/alloc without other features like chrono #550

M1cha opened this issue Feb 20, 2023 · 4 comments

Comments

@M1cha
Copy link

M1cha commented Feb 20, 2023

If you're fixed to an incompatible version of chrono or just want to save on code size, you don't really want any of that enabled. You might still want to use the utils for (de-)serializing things like Vecs though.

@jonasbb
Copy link
Owner

jonasbb commented Feb 20, 2023

Is is already the case. The only things enabled by alloc and std are the features of the same name in serde. For the other crates the features use "?" to not pull new dependencies in.

alloc = [
"serde/alloc",
"base64?/alloc",
"chrono_0_4?/alloc",
"hex?/alloc",
"serde_json?/alloc",
"time_0_3?/alloc",
]
std = [
"alloc",
"serde/std",
# Enables `Local` type
"chrono_0_4?/clock",
"chrono_0_4?/std",
"indexmap_1?/std",
"time_0_3?/serde-well-known",
"time_0_3?/std",
]

@jonasbb jonasbb closed this as not planned Won't fix, can't repro, duplicate, stale Feb 20, 2023
@M1cha
Copy link
Author

M1cha commented Feb 20, 2023

Unfortunately this doesn't seem to be working though.
A binary with this dependency section:

[dependencies]
chrono = "= 0.4.19"
serde_with = { version = "2.2", default_features = false, features = ["std"] }

fails to compile with:

error: failed to select a version for `chrono`.
    ... required by package `serde_with v2.2.0`
    ... which satisfies dependency `serde_with = "^2.2"` (locked to 2.2.0) of package `tmp v0.1.0 (/tmp/tmp)`
versions that meet the requirements `^0.4.20` are: 0.4.23, 0.4.22, 0.4.21, 0.4.20

all possible versions conflict with previously selected packages.

  previously selected package `chrono v0.4.19`
    ... which satisfies dependency `chrono = "=0.4.19"` (locked to 0.4.19) of package `tmp v0.1.0 (/tmp/tmp)`

failed to select a version for `chrono` which could resolve this conflict

@jonasbb
Copy link
Owner

jonasbb commented Feb 20, 2023

This is caused by rust-lang/cargo#10801 and pinning chrono to a single version. Pinning to a specific version works very poorly, and you will run into more problems like this. If you only add serde_with as a dependency, you will see that chrono will not be compiled.

You should drop the version pinning of chrono. Alternatively, you can use a different version of serde_with like <=2.0.0.

@M1cha
Copy link
Author

M1cha commented Feb 20, 2023

I can't unpin chrono right now due to this issue.
Thanks for the hint about Cargo.lock.

serde_with 2.0 seems to work just fine.
Even though this situation is not ideal, it's not caused by serde_with directly and thus not something that can be fixed by this project.

Thanks a lot for the clarification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants