Locating source of IO error in my code

⚓ Rust    📅 2025-10-20    👤 surdeus    👁️ 2      

surdeus

when I run my tests with RUST_BACKTRACE=1 (or =full), I get this output:

Error: Aggregate signature error: IO error: No such file or directory (os error 2)

Caused by:
    0: IO error: No such file or directory (os error 2)
    1: No such file or directory (os error 2)

Stack backtrace:
   0: anyhow::error::<impl core::convert::From<E> for anyhow::Error>::from
             at /home/dotdev/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/anyhow-1.0.99/src/backtrace.rs:27:14
   1: <core::result::Result<T,F> as core::ops::try_trait::FromResidual<core::result::Result<core::convert::Infallible,E>>>::from_residual
             at /home/dotdev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/result.rs:2022:27
   2: signers_file::tests::test_propose_signers_file_with_master_signer
             at ./src/lib.rs:2949:9
   3: signers_file::tests::test_propose_signers_file_with_master_signer::{{closure}}
             at ./src/lib.rs:2935:58
   4: core::ops::function::FnOnce::call_once
             at /home/dotdev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:250:5
   5: core::ops::function::FnOnce::call_once
             at /rustc/17067e9ac6d7ecb70e50f92c1944e545188d2359/library/core/src/ops/function.rs:250:5
   6: test::__rust_begin_short_backtrace
             at /rustc/17067e9ac6d7ecb70e50f92c1944e545188d2359/library/test/src/lib.rs:638:18
   ...

but ./src/lib.rs:2949:9 is the call to a function I write in the lib under test, which then further calls other functions I wrote, possibly in another local crate that I import in Cargo.toml.
In the end I don't know which line of my code causes the error.

How can I know which line of my library's code causes the problem?
I'm using dbg!(), but I suspect there's a more efficient way. What is it?

7 posts - 3 participants

Read full topic

🏷️ Rust_feed