leptos: Get error about missing "tracing" dependency when trying to use #[component] macro

Describe the bug When using the component attribute macro, get an error saying tracing is a missing dependency.

failed to resolve: use of undeclared crate or module `tracing`
use of undeclared crate or module `tracing`rustc[Click for full compiler diagnostic]

Leptos Dependencies

[dependencies] leptos = “0.5.4” axum = “0.7.2” leptos_axum = “0.5.4”

To Reproduce Steps to reproduce the behavior:

  1. Create a component
  2. Add the macro
  3. See red squiggle

Expected behavior According to the docs, component macro shouldn’t require tracing crate.

Screenshots image

Additional context

enabling the tracing feature for leptos does not fix it

[dependencies]
leptos = { version = "0.5.4", features = ["tracing"] }
axum = "0.7.2"
leptos_axum = "0.5.4"

The view function in lib.rs seems to have a direct dependency on tracing that is not feature gated?

image

Adding tracing as a direct dependency to the cargo.toml fixes the issue

[dependencies]
leptos = "0.5.4"
axum = "0.7.2"
leptos_axum = "0.5.4"
tracing = "0.1.40"

About this issue

  • Original URL
  • State: closed
  • Created 6 months ago
  • Comments: 20 (2 by maintainers)

Most upvoted comments

Oh okay yeah it’s this: https://github.com/leptos-rs/leptos/blob/16cf3c4eafd660ab68a7a8dff1e06096f061ffea/leptos_macro/src/component.rs#L191-L194

Using the tracing::instrument macro requires a root-level tracing dependency that we can’t tell to use some other path (like the one reexported from Leptos) instead.

Gating this on the Leptos tracing feature is a breaking change but we’re releasing a 0.6 soon so it could be rolled into that.

(In the meantime tracing is a great crate, so either just adding it or running in release mode for a while should work.)