Skip to content
Latchkey

Rust Build Breaks After "default-features = false" in CI

Setting default-features = false on a dependency turns off its entire default feature set - including features your code relied on. The build now fails on a missing module, type, or method that lived behind a default feature you didn’t re-enable.

What this error means

After someone trims a dependency with default-features = false (often to shrink a binary or support no_std), the build fails with an unresolved import, a missing trait impl, or cannot find for an item that used to be available. Reverting the flag, or re-adding the feature, fixes it.

cargo output
error[E0432]: unresolved import `chrono::serde`
 --> src/model.rs:1:5
  |
1 | use chrono::serde::ts_seconds;
  |     ^^^^^^^^^^^^^ no `serde` in `chrono`
  = note: `chrono` was added with `default-features = false`; the `serde` feature is off

Common causes

A relied-on feature was in the defaults

Many crates put std, serde, or codec support in their default features. Disabling defaults removes those, so code depending on them no longer compiles.

Trimming features without re-adding the needed ones

default-features = false is meant to be paired with an explicit features = [...]. Omitting the features you actually use leaves the dependency too bare.

How to fix it

Re-enable the specific features you need

Keep defaults off but explicitly list the features your code uses.

Cargo.toml
[dependencies]
chrono = { version = "0.4", default-features = false, features = ["serde", "clock"] }

Check the crate’s default feature set

  1. Read the crate’s docs.rs feature-flags page to see what default includes.
  2. Add back exactly the features your code depends on via features = [...].
  3. Run cargo build (and cargo build --no-default-features if you target no_std) to confirm.

How to prevent it

  • Always pair default-features = false with an explicit features = [...].
  • Consult the crate’s default feature list before disabling defaults.
  • Test both default and minimal feature builds in CI.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →