Skip to content

rtshark-4.0.0 does not install without default features #33

@bbannier

Description

@bbannier

rtshark-4.0.0 introduced feature quick-xml. This dependency is in fact not optional and one cannot use rtshark without it, e.g., given the a default project with the following Cargo.toml

[package]
name = "r"
version = "0.1.0"
edition = "2024"

[dependencies]
rtshark = { version = "4.0.0", default-features = false }

This fails to build with

$ cargo check
    Checking rtshark v4.0.0
error[E0433]: failed to resolve: use of unresolved module or unlinked crate `quick_xml`
 --> /Users/bbannier/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rtshark-4.0.0/src/xml.rs:1:5
  |
1 | use quick_xml::events::{BytesStart, Event};
  |     ^^^^^^^^^ use of unresolved module or unlinked crate `quick_xml`
  |
  = help: if you wanted to use a crate named `quick_xml`, use `cargo add quick_xml` to add it to your `Cargo.toml`

error[E0432]: unresolved import `quick_xml`
 --> /Users/bbannier/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rtshark-4.0.0/src/rtshark.rs:1:5
  |
1 | use quick_xml::Reader;
  |     ^^^^^^^^^ use of unresolved module or unlinked crate `quick_xml`
  |
  = help: if you wanted to use a crate named `quick_xml`, use `cargo add quick_xml` to add it to your `Cargo.toml`

error[E0433]: failed to resolve: use of unresolved module or unlinked crate `quick_xml`
  --> /Users/bbannier/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rtshark-4.0.0/src/rtshark.rs:31:22
   |
31 |         let parser = quick_xml::Reader::from_reader(buf_reader);
   |                      ^^^^^^^^^ use of unresolved module or unlinked crate `quick_xml`
   |
   = help: if you wanted to use a crate named `quick_xml`, use `cargo add quick_xml` to add it to your `Cargo.toml`

error[E0433]: failed to resolve: use of unresolved module or unlinked crate `quick_xml`
  --> /Users/bbannier/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rtshark-4.0.0/src/rtshark.rs:19:13
   |
19 |     parser: quick_xml::Reader<BufReader<ChildStdout>>,
   |             ^^^^^^^^^ use of unresolved module or unlinked crate `quick_xml`
   |
   = help: if you wanted to use a crate named `quick_xml`, use `cargo add quick_xml` to add it to your `Cargo.toml`

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

This can also be reproduced when trying to build rtshark with --no-default-features,

$ cargo check --no-default-features
    Checking rtshark v4.0.0 (/private/tmp/rtshark)
error[E0433]: failed to resolve: use of unresolved module or unlinked crate `quick_xml`
 --> src/xml.rs:1:5
  |
1 | use quick_xml::events::{BytesStart, Event};
  |     ^^^^^^^^^ use of unresolved module or unlinked crate `quick_xml`
  |
  = help: if you wanted to use a crate named `quick_xml`, use `cargo add quick_xml` to add it to your `Cargo.toml`

error[E0432]: unresolved import `quick_xml`
 --> src/rtshark.rs:1:5
  |
1 | use quick_xml::Reader;
  |     ^^^^^^^^^ use of unresolved module or unlinked crate `quick_xml`
  |
  = help: if you wanted to use a crate named `quick_xml`, use `cargo add quick_xml` to add it to your `Cargo.toml`

error[E0433]: failed to resolve: use of unresolved module or unlinked crate `quick_xml`
  --> src/rtshark.rs:31:22
   |
31 |         let parser = quick_xml::Reader::from_reader(buf_reader);
   |                      ^^^^^^^^^ use of unresolved module or unlinked crate `quick_xml`
   |
   = help: if you wanted to use a crate named `quick_xml`, use `cargo add quick_xml` to add it to your `Cargo.toml`

error[E0433]: failed to resolve: use of unresolved module or unlinked crate `quick_xml`
  --> src/rtshark.rs:19:13
   |
19 |     parser: quick_xml::Reader<BufReader<ChildStdout>>,
   |             ^^^^^^^^^ use of unresolved module or unlinked crate `quick_xml`
   |
   = help: if you wanted to use a crate named `quick_xml`, use `cargo add quick_xml` to add it to your `Cargo.toml`

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

I found that cargo hack is a useful tool to catch such accidental breakage.

$ cargo hack check --each-feature
info: running `cargo check --all-features` on rtshark (1/4)
    Checking rtshark v4.0.0 (/private/tmp/rtshark)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.12s

info: running `cargo check --no-default-features` on rtshark (2/4)
    Checking rtshark v4.0.0 (/private/tmp/rtshark)
error[E0433]: failed to resolve: use of unresolved module or unlinked crate `quick_xml`
 --> src/xml.rs:1:5
  |
1 | use quick_xml::events::{BytesStart, Event};
  |     ^^^^^^^^^ use of unresolved module or unlinked crate `quick_xml`
  |
  = help: if you wanted to use a crate named `quick_xml`, use `cargo add quick_xml` to add it to your `Cargo.toml`

error[E0432]: unresolved import `quick_xml`
 --> src/rtshark.rs:1:5
  |
1 | use quick_xml::Reader;
  |     ^^^^^^^^^ use of unresolved module or unlinked crate `quick_xml`
  |
  = help: if you wanted to use a crate named `quick_xml`, use `cargo add quick_xml` to add it to your `Cargo.toml`

error[E0433]: failed to resolve: use of unresolved module or unlinked crate `quick_xml`
  --> src/rtshark.rs:31:22
   |
31 |         let parser = quick_xml::Reader::from_reader(buf_reader);
   |                      ^^^^^^^^^ use of unresolved module or unlinked crate `quick_xml`
   |
   = help: if you wanted to use a crate named `quick_xml`, use `cargo add quick_xml` to add it to your `Cargo.toml`

error[E0433]: failed to resolve: use of unresolved module or unlinked crate `quick_xml`
  --> src/rtshark.rs:19:13
   |
19 |     parser: quick_xml::Reader<BufReader<ChildStdout>>,
   |             ^^^^^^^^^ use of unresolved module or unlinked crate `quick_xml`
   |
   = help: if you wanted to use a crate named `quick_xml`, use `cargo add quick_xml` to add it to your `Cargo.toml`

Some errors have detailed explanations: E0432, E0433.
For more information about an error, try `rustc --explain E0432`.
error: could not compile `rtshark` (lib) due to 4 previous errors
error: process didn't exit successfully: `/Users/bbannier/.rustup/toolchains/stable-aarch64-apple-darwin/bin/cargo check --manifest-path Cargo.toml --no-default-features` (exit status: 101)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions