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

error[E0425]: cannot find function set_boxed_logger in crate log when building with Bazel/cargo-raze #839

Open
yesudeep opened this issue Jul 23, 2020 · 7 comments
Labels
crate/log Related to the `tracing-log` crate kind/bug Something isn't working

Comments

@yesudeep
Copy link

yesudeep commented Jul 23, 2020

Bug Report

Version

❯ cargo tree | grep tracing
│   ├── tracing v0.1.17
│   │   ├── tracing-attributes v0.1.9
│   │   └── tracing-core v0.1.11
│   ├── tracing-futures v0.2.4
│   │   └── tracing v0.1.17 (*)
│   └── tracing-subscriber v0.2.8
│       ├── tracing-core v0.1.11 (*)
│       ├── tracing-log v0.1.1
│       │   └── tracing-core v0.1.11 (*)
│       └── tracing-serde v0.1.1
│           └── tracing-core v0.1.11 (*)

I see that tracing-log has a dependency on the log package as well:

❯ cargo tree | grep log
│   │   │   ├── log v0.4.11
│       ├── tracing-log v0.1.1
│       │   ├── log v0.4.11 (*)

Platform

Darwin hostname 19.6.0 Darwin Kernel Version 19.6.0: Sun Jul  5 00:43:10 PDT 2020; root:xnu-6153.141.1~9/RELEASE_X86_64 x86_64

Description

I'm trying out an example from the tokio documentation that uses mini-redis:

use mini_redis::{client, Result};

#[tokio::main]
pub async fn main() -> Result<()> {
    let mut client = client::connect("127.0.0.1:6379").await?;
    client.set("hello", "world".into()).await?;
    let result = client.get("hello").await?;
    println!("got value from the server; result={:?}", result);
    Ok(())
}

I get the following error:

❯ bazel run //codelab/rs/scratch:scratch
INFO: Analyzed target //codelab/rs/scratch:scratch (100 packages loaded, 2130 targets configured).
INFO: Found 1 target...
INFO: From Compiling Rust lib tracing_log v0.1.1 (5 files):
error[E0425]: cannot find function `set_boxed_logger` in crate `log`
   --> external/raze__tracing_log__0_1_1/src/log_tracer.rs:247:14
    |
247 |         log::set_boxed_logger(logger)?;
    |              ^^^^^^^^^^^^^^^^ not found in `log`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0425`.
ERROR: /Volumes/ether/bazel/f88229076ec69f23676bcfea768ed1a5/external/raze__tracing_log__0_1_1/BUILD.bazel:28:13: output 'external/raze__tracing_log__0_1_1/libtracing_log-717297689.rlib' was not created
ERROR: /Volumes/ether/bazel/f88229076ec69f23676bcfea768ed1a5/external/raze__tracing_log__0_1_1/BUILD.bazel:28:13: not all outputs were created or valid
Target //codelab/rs/scratch:scratch failed to build
INFO: Elapsed time: 5.278s, Critical Path: 0.77s
INFO: 4 processes: 4 darwin-sandbox.
FAILED: Build did NOT complete successfully
FAILED: Build did NOT complete successfully

I was expecting the example to compile successfully.

Thank you! :)

@hawkw
Copy link
Member

hawkw commented Jul 23, 2020

Can you reproduce this outside of Bazel, with just Cargo? It would be nice to know whether this is a Bazel-specific issue, or if it effects all builds. Thanks!

@hawkw hawkw added crate/log Related to the `tracing-log` crate kind/bug Something isn't working labels Jul 23, 2020
@yesudeep
Copy link
Author

yesudeep commented Jul 23, 2020

I wasn't able to reproduce this with a plain Cargo-based directory.
You are correct. This appears to be Bazel/cargo-raze related.
I'll try to dig deeper and add more information here as I find.

@hawkw
Copy link
Member

hawkw commented Jul 23, 2020

Thanks for checking!

I think this is likely related to feature flags in some way --- the set_boxed_logger function in log requires log's "std" feature to be enabled. tracing-subscriber enables "log/std" through its tracing-log dependency, which exposes its own feature flag to enable the log crate's feature:

tracing-log = { path = "../tracing-log", version = "0.1", optional = true, default-features = false, features = ["log-tracer", "std"] }

My guess is that either cargo-raze or Bazel's Rust rules are not able to handle this chain of features correctly?

@hawkw hawkw changed the title error[E0425]: cannot find function set_boxed_logger in crate log error[E0425]: cannot find function set_boxed_logger in crate log when building with Bazel/cargo-raze Jul 23, 2020
@austintheriot
Copy link

If you find this by googling the error message like I did:

This issue was caused for me by Windows 10 Malwarebytes antivirus blocking a build script from running during compilation. Every time I ran a build, it would quarantine the file that was wanting to run a build for one of the dependencies. I had to add the crate directory to the allow list in order for the build to finish successfully. Not sure which script in particular it was, since I already added it to the allow list--sorry for lack of details there.

@aherrmann
Copy link

I bumped into a similar issue as described by @austintheriot above and to my understanding it is caused when log's build script is not run and cannot set the atomic_cas config, which is required next to the std feature to expose the symbol.

aherrmann added a commit to facebook/buck2 that referenced this issue Oct 11, 2022
Resolves the error
```
error[E0425]: cannot find function `set_boxed_logger` in crate `log`
   --> third-party/rust/vendor/tracing-log-0.1.3/src/log_tracer.rs:292:14
    |
292 |         log::set_boxed_logger(logger)?;
    |              ^^^^^^^^^^^^^^^^ not found in `log`
```
caused by the `build.rs` script not running and [not
setting](https://github.com/rust-lang/log/blob/d6707108c6959ac7b60cdb60a005795ece6d82d6/build.rs#L14)
the `atomic_cas` configuration which [is
needed](https://github.com/rust-lang/log/blob/d6707108c6959ac7b60cdb60a005795ece6d82d6/src/lib.rs#L1262)
for `set_boxed_logger`.
See also [related
issue](tokio-rs/tracing#839 (comment)).
aherrmann added a commit to facebook/buck2 that referenced this issue Oct 13, 2022
Resolves the error
```
error[E0425]: cannot find function `set_boxed_logger` in crate `log`
   --> third-party/rust/vendor/tracing-log-0.1.3/src/log_tracer.rs:292:14
    |
292 |         log::set_boxed_logger(logger)?;
    |              ^^^^^^^^^^^^^^^^ not found in `log`
```
caused by the `build.rs` script not running and [not
setting](https://github.com/rust-lang/log/blob/d6707108c6959ac7b60cdb60a005795ece6d82d6/build.rs#L14)
the `atomic_cas` configuration which [is
needed](https://github.com/rust-lang/log/blob/d6707108c6959ac7b60cdb60a005795ece6d82d6/src/lib.rs#L1262)
for `set_boxed_logger`.
See also [related
issue](tokio-rs/tracing#839 (comment)).
@psalaberria002
Copy link

@aherrmann did you figure out a solution? I am getting the same error.

error[E0425]: cannot find function `set_boxed_logger` in crate `log`
   --> external/crate_index__tracing-log-0.1.3/src/log_tracer.rs:292:14
    |
292 |         log::set_boxed_logger(logger)?;
    |              ^^^^^^^^^^^^^^^^ not found in `log`

error: aborting due to previous error

@aherrmann
Copy link

@psalaberria002 Yes, the solution for my use case was to make sure that the build.rs script runs and sets the atomic_cas configuration option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crate/log Related to the `tracing-log` crate kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants