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

tracing-subscriber's fmt feature's thread_local dependency breaks tracing-subscriber's MSRV #2632

Open
8573 opened this issue Jun 23, 2023 · 1 comment

Comments

@8573
Copy link

8573 commented Jun 23, 2023

Bug Report

Version

With tracing-subscriber:

$ cargo tree | rg tracing
│   │   │   └── tracing v0.1.35
│   │   │       ├── tracing-attributes v0.1.26 (proc-macro)
│   │   │       └── tracing-core v0.1.31
│   │   └── tracing v0.1.35 (*)
│   │   ├── tracing v0.1.35 (*)
├── tracing v0.1.35 (*)
└── tracing-subscriber v0.3.17
    ├── tracing-core v0.1.31 (*)
    └── tracing-log v0.1.3
        └── tracing-core v0.1.31 (*)

Without tracing-subscriber:

$ cargo tree | rg tracing
│   │   │   └── tracing v0.1.35
│   │   │       ├── tracing-attributes v0.1.26 (proc-macro)
│   │   │       └── tracing-core v0.1.31
│   │   └── tracing v0.1.35 (*)
│   │   ├── tracing v0.1.35 (*)
└── tracing v0.1.35 (*)

Platform

$ uname -a
Linux [hostname removed] 6.1.29-hardened1 #1-NixOS SMP PREEMPT_DYNAMIC Wed May 17 09:54:00 UTC 2023 x86_64 GNU/Linux

Crates

  • tracing-subscriber

Description

If I add tracing-subscriber, with the crate feature fmt enabled, to the dependencies of a crate using Rust 1.58.1 and try to build the crate, the build fails:

   Compiling thread_local v1.1.7
error[E0658]: use of unstable library feature 'thread_local_const_init'
   --> [path removed]/.cargo/registry/src/github.com-1ecc6299db9ec823/thread_local-1.1.7/src/thread_id.rs:132:9
    |
132 |         thread_local! { static THREAD: Cell<Option<Thread>> = const { Cell::new(None) }; }
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: see issue #84223 <https://github.com/rust-lang/rust/issues/84223> for more information
    = note: this error originates in the macro `$crate::__thread_local_inner` (in Nightly builds, run with -Z macro-backtrace for more info)

For more information about this error, try `rustc --explain E0658`.
error: could not compile `thread_local` due to previous error

If I remove tracing-subscriber from the dependencies and rebuild, the build succeeds.

According to #2003 (comment), this thread_local_const_init feature "requires Rust 1.59", whereas tracing-subscriber documents its minimum supported Rust version (MSRV) as 1.56:

//! ## Supported Rust Versions
//!
//! Tracing is built against the latest stable release. The minimum supported
//! version is 1.56. The current Tracing version is not guaranteed to build on
//! Rust versions earlier than the minimum supported version.

I see that tracing-subscriber depends on thread_local ^1.1.4:

thread_local = { version = "1.1.4", optional = true }

According to Lib.rs, thread_local 1.1.4 had MSRV 1.36, whereas thread_local's latest release, 1.1.7, has MSRV 1.59. According to Lib.rs, thread_local versions 1.1.5 and 1.1.6 are yanked. I suppose I could force Cargo to use version 1.1.4; while the later versions include some bug fixes, these appear to be only for bugs that were not in 1.1.4. Indeed, if I run cargo update -p thread_local --precise 1.1.4, the build then succeeds.

I see that tracing-subscriber would not depend on thread_local at all if I were to use only the default crate features and not the fmt feature.

Conclusions

If you take the position that the MSRV applies only to the default crate features, then tracing-subscriber's (or the main tracing crate's) MSRV documentation could say so explicitly.

If you take the position that the adjective "supported" in "minimum supported Rust version" means that it must be possible for users on the MSRV to construct a Cargo.lock that allows them to build successfully, then tracing-subscriber's MSRV documentation could mention that users with Rust older than 1.59 must override the version of thread_local to 1.1.4, such as by running cargo update -p thread_local --precise 1.1.4.

@8573
Copy link
Author

8573 commented Jun 23, 2023

Also, unrelatedly, I'd like to thank you for the amusement given when I first saw https://docs.rs/tracing-attributes/0.1.26/src/tracing_attributes/lib.rs.html#146-147 :-)

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

1 participant