Skip to content

Can't run tests for dylint library: "could not load library" #1691

@dcastro

Description

@dcastro

I tried creating a new dylint library and run its tests, but the test fails with:

failures:

---- ui stdout ----
normalized stderr:
error: could not load library `$SRC_DIR/target/debug/libtest_lint@nightly-2025-02-20-x86_64-unknown-linux-gnu.so`: $SRC_DIR/target/debug/libtest_lint@nightly-2025-02-20-x86_64-unknown-linux-gnu.so: cannot open shared object file: No such file or directory




The actual stderr differed from the expected stderr.
Actual stderr saved to /tmp/main.stage-id.stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args main.rs`

error: 1 errors occurred comparing output.
status: exit status: 101
command: "/home/dc/.dylint_drivers/nightly-2025-02-20-x86_64-unknown-linux-gnu/dylint-driver" "ui/main.rs" "-L" "/tmp" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-C" "prefer-dynamic" "-o" "/tmp/main.stage-id" "-A" "unused" "--emit=metadata" "-Zui-testing" "-L" "/tmp/main.stage-id.aux"
stdout:
------------------------------------------

------------------------------------------
stderr:
------------------------------------------
error: could not load library `/home/dc/dev/other/test_lint/target/debug/libtest_lint@nightly-2025-02-20-x86_64-unknown-linux-gnu.so`: /home/dc/dev/other/test_lint/target/debug/libtest_lint@nightly-2025-02-20-x86_64-unknown-linux-gnu.so: cannot open shared object file: No such file or directory


------------------------------------------


thread 'ui' panicked at /home/dc/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/compiletest_rs-0.11.2/src/lib.rs:113:22:
Some tests failed
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    ui

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.18s

Steps to reproduce:

cargo binstall cargo-dylint dylint-link
rustup component add rustc-dev
cargo dylint new test_lint                                                                                                                                                                                                                                                          
cd test_lint
cargo test

Full output

Full output
cargo test
  Compiling proc-macro2 v1.0.95
  Compiling unicode-ident v1.0.18
  Compiling libc v0.2.174
  Compiling memchr v2.7.5
  Compiling serde v1.0.219
  Compiling shlex v1.3.0
  Compiling stable_deref_trait v1.2.0
  Compiling regex-syntax v0.8.5
  Compiling pkg-config v0.3.32
  Compiling cfg-if v1.0.1
  Compiling vcpkg v0.2.15
  Compiling version_check v0.9.5
  Compiling typenum v1.18.0
  Compiling writeable v0.6.1
  Compiling serde_json v1.0.140
  Compiling litemap v0.8.0
  Compiling smallvec v1.15.1
  Compiling icu_normalizer_data v2.0.0
  Compiling itoa v1.0.15
  Compiling ryu v1.0.20
  Compiling log v0.4.27
  Compiling icu_properties_data v2.0.1
  Compiling thiserror v2.0.12
  Compiling semver v1.0.26
  Compiling camino v1.1.10
  Compiling hashbrown v0.15.4
  Compiling equivalent v1.0.2
  Compiling same-file v1.0.6
  Compiling anyhow v1.0.98
  Compiling bitflags v2.9.1
  Compiling cpufeatures v0.2.17
  Compiling rustversion v1.0.21
  Compiling winnow v0.7.12
  Compiling toml_write v0.1.2
  Compiling utf8_iter v1.0.4
  Compiling percent-encoding v2.3.1
  Compiling home v0.5.9
  Compiling aho-corasick v1.1.3
  Compiling bstr v1.12.0
  Compiling once_cell v1.21.3
  Compiling ansi_term v0.12.1
  Compiling openssl-probe v0.1.6
  Compiling rustix v1.0.8
  Compiling getrandom v0.3.3
  Compiling walkdir v2.5.0
  Compiling thiserror v1.0.69
  Compiling generic-array v0.14.7
  Compiling utf8parse v0.2.2
  Compiling linux-raw-sys v0.9.4
  Compiling unicode-width v0.2.1
  Compiling pin-project-lite v0.2.16
  Compiling if_chain v1.0.2
  Compiling anstyle v1.0.11
  Compiling compiletest_rs v0.11.2
  Compiling indexmap v2.10.0
  Compiling paste v1.0.15
  Compiling anstyle-query v1.1.3
  Compiling rustc_apfloat v0.2.3+llvm-462a31f5a5ab
  Compiling colorchoice v1.0.4
  Compiling fastrand v2.3.0
  Compiling is_terminal_polyfill v1.70.1
  Compiling jiff v0.2.15
  Compiling either v1.15.0
  Compiling lazy_static v1.5.0
  Compiling diff v0.1.13
  Compiling arrayvec v0.7.6
  Compiling jobserver v0.1.33
  Compiling dirs-sys-next v0.1.2
  Compiling tracing-core v0.1.34
  Compiling num_cpus v1.17.0
  Compiling form_urlencoded v1.2.1
  Compiling filetime v0.2.25
  Compiling getopts v0.2.23
  Compiling regex-automata v0.4.9
  Compiling quote v1.0.40
  Compiling anstyle-parse v0.2.7
  Compiling itertools v0.12.1
  Compiling dirs-next v2.0.0
  Compiling block-buffer v0.10.4
  Compiling crypto-common v0.1.6
  Compiling cc v1.2.29
  Compiling tracing v0.1.41
  Compiling syn v2.0.104
  Compiling anstream v0.6.19
  Compiling term v0.7.0
  Compiling digest v0.10.7
  Compiling tempfile v3.20.0
  Compiling libz-sys v1.1.22
  Compiling openssl-sys v0.9.109
  Compiling libssh2-sys v0.3.1
  Compiling libgit2-sys v0.16.2+1.7.2
  Compiling regex v1.11.1
  Compiling globset v0.4.16
  Compiling sha2 v0.10.9
  Compiling env_filter v0.1.3
  Compiling tester v0.9.1
  Compiling synstructure v0.13.2
  Compiling serde_derive v1.0.219
  Compiling zerovec-derive v0.11.1
  Compiling displaydoc v0.2.5
  Compiling thiserror-impl v2.0.12
  Compiling thiserror-impl v1.0.69
  Compiling rust-embed-utils v8.7.2
  Compiling env_logger v0.11.8
  Compiling zerofrom-derive v0.1.6
  Compiling yoke-derive v0.8.0
  Compiling rust-embed-impl v8.7.2
  Compiling zerofrom v0.1.6
  Compiling rust-embed v8.7.2
  Compiling yoke v0.8.0
  Compiling zerovec v0.11.2
  Compiling zerotrie v0.2.2
  Compiling tinystr v0.8.1
  Compiling potential_utf v0.1.2
  Compiling icu_locale_core v2.0.0
  Compiling icu_collections v2.0.0
  Compiling icu_provider v2.0.0
  Compiling icu_properties v2.0.1
  Compiling icu_normalizer v2.0.0
  Compiling idna_adapter v1.2.1
  Compiling toml_datetime v0.6.11
  Compiling cargo-platform v0.1.9
  Compiling serde_spanned v0.6.9
  Compiling clippy_utils v0.1.87 (https://github.com/rust-lang/rust-clippy?rev=238edf273d195c8e472851ebd60571f77f978ac8#238edf27)
  Compiling idna v1.0.3
  Compiling toml_edit v0.22.27
  Compiling cargo_metadata v0.19.2
  Compiling rustfix v0.8.7
  Compiling url v2.5.4
  Compiling toml v0.8.23
  Compiling dylint_internal v4.1.0
  Compiling git2 v0.18.3
  Compiling dylint_linting v4.1.0
  Compiling dylint v4.1.0
  Compiling dylint_testing v4.1.0
  Compiling test_lint v0.1.0 (/home/dc/dev/other/test_lint)
warning: unused extern crate
--> src/lib.rs:5:1
  |
5 | extern crate rustc_arena;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it
  |
note: the lint level is defined here
--> src/lib.rs:3:9
  |
3 | #![warn(unused_extern_crates)]
  |         ^^^^^^^^^^^^^^^^^^^^

warning: unused extern crate
--> src/lib.rs:6:1
  |
6 | extern crate rustc_ast;
  | ^^^^^^^^^^^^^^^^^^^^^^^ help: remove it

warning: unused extern crate
--> src/lib.rs:7:1
  |
7 | extern crate rustc_ast_pretty;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it

warning: unused extern crate
--> src/lib.rs:8:1
  |
8 | extern crate rustc_data_structures;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it

warning: unused extern crate
--> src/lib.rs:9:1
  |
9 | extern crate rustc_errors;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it

warning: unused extern crate
  --> src/lib.rs:10:1
  |
10 | extern crate rustc_hir;
  | ^^^^^^^^^^^^^^^^^^^^^^^ help: remove it

warning: unused extern crate
  --> src/lib.rs:11:1
  |
11 | extern crate rustc_hir_pretty;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it

warning: unused extern crate
  --> src/lib.rs:12:1
  |
12 | extern crate rustc_index;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it

warning: unused extern crate
  --> src/lib.rs:13:1
  |
13 | extern crate rustc_infer;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it

warning: unused extern crate
  --> src/lib.rs:14:1
  |
14 | extern crate rustc_lexer;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it

warning: unused extern crate
  --> src/lib.rs:15:1
  |
15 | extern crate rustc_middle;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it

warning: unused extern crate
  --> src/lib.rs:16:1
  |
16 | extern crate rustc_mir_dataflow;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it

warning: unused extern crate
  --> src/lib.rs:17:1
  |
17 | extern crate rustc_parse;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it

warning: unused extern crate
  --> src/lib.rs:18:1
  |
18 | extern crate rustc_span;
  | ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it

warning: unused extern crate
  --> src/lib.rs:19:1
  |
19 | extern crate rustc_target;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it

warning: unused extern crate
  --> src/lib.rs:20:1
  |
20 | extern crate rustc_trait_selection;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it

warning: `test_lint` (lib test) generated 16 warnings (run `cargo fix --lib -p test_lint --tests` to apply 16 suggestions)
    Finished `test` profile [unoptimized + debuginfo] target(s) in 5.94s
    Running unittests src/lib.rs (target/debug/deps/test_lint-29d2a9603916f27f)

running 1 test
Building library `test_lint`
  Compiling syn v2.0.104
  Compiling serde v1.0.219
  Compiling bitflags v2.9.1
  Compiling aho-corasick v1.1.3
  Compiling rustc_apfloat v0.2.3+llvm-462a31f5a5ab
  Compiling regex-automata v0.4.9
  Compiling serde_derive v1.0.219
  Compiling thiserror-impl v2.0.12
  Compiling toml_datetime v0.6.11
  Compiling serde_spanned v0.6.9
  Compiling regex v1.11.1
  Compiling toml_edit v0.22.27
  Compiling thiserror v2.0.12
  Compiling toml v0.8.23
  Compiling dylint_linting v4.1.0
  Compiling serde_json v1.0.140
  Compiling cargo-platform v0.1.9
  Compiling camino v1.1.10
  Compiling semver v1.0.26
  Compiling clippy_utils v0.1.87 (https://github.com/rust-lang/rust-clippy?rev=238edf273d195c8e472851ebd60571f77f978ac8#238edf27)
  Compiling cargo_metadata v0.19.2
  Compiling dylint_internal v4.1.0
  Compiling test_lint v0.1.0 (/home/dc/dev/other/test_lint)
warning: unused extern crate
--> src/lib.rs:5:1
  |
5 | extern crate rustc_arena;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it
  |
note: the lint level is defined here
--> src/lib.rs:3:9
  |
3 | #![warn(unused_extern_crates)]
  |         ^^^^^^^^^^^^^^^^^^^^

warning: unused extern crate
--> src/lib.rs:6:1
  |
6 | extern crate rustc_ast;
  | ^^^^^^^^^^^^^^^^^^^^^^^ help: remove it

warning: unused extern crate
--> src/lib.rs:7:1
  |
7 | extern crate rustc_ast_pretty;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it

warning: unused extern crate
--> src/lib.rs:8:1
  |
8 | extern crate rustc_data_structures;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it

warning: unused extern crate
--> src/lib.rs:9:1
  |
9 | extern crate rustc_errors;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it

warning: unused extern crate
  --> src/lib.rs:10:1
  |
10 | extern crate rustc_hir;
  | ^^^^^^^^^^^^^^^^^^^^^^^ help: remove it

warning: unused extern crate
  --> src/lib.rs:11:1
  |
11 | extern crate rustc_hir_pretty;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it

warning: unused extern crate
  --> src/lib.rs:12:1
  |
12 | extern crate rustc_index;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it

warning: unused extern crate
  --> src/lib.rs:13:1
  |
13 | extern crate rustc_infer;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it

warning: unused extern crate
  --> src/lib.rs:14:1
  |
14 | extern crate rustc_lexer;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it

warning: unused extern crate
  --> src/lib.rs:15:1
  |
15 | extern crate rustc_middle;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it

warning: unused extern crate
  --> src/lib.rs:16:1
  |
16 | extern crate rustc_mir_dataflow;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it

warning: unused extern crate
  --> src/lib.rs:17:1
  |
17 | extern crate rustc_parse;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it

warning: unused extern crate
  --> src/lib.rs:18:1
  |
18 | extern crate rustc_span;
  | ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it

warning: unused extern crate
  --> src/lib.rs:19:1
  |
19 | extern crate rustc_target;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it

warning: unused extern crate
  --> src/lib.rs:20:1
  |
20 | extern crate rustc_trait_selection;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it

warning: `test_lint` (lib) generated 16 warnings (run `cargo fix --lib -p test_lint` to apply 16 suggestions)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 2.58s

running 1 test
test [ui] ui/main.rs ... FAILED

failures:

failures:
    [ui] ui/main.rs

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.01s

test ui ... FAILED

failures:

---- ui stdout ----
normalized stderr:
error: could not load library `$SRC_DIR/target/debug/libtest_lint@nightly-2025-02-20-x86_64-unknown-linux-gnu.so`: $SRC_DIR/target/debug/libtest_lint@nightly-2025-02-20-x86_64-unknown-linux-gnu.so: cannot open shared object file: No such file or directory




The actual stderr differed from the expected stderr.
Actual stderr saved to /tmp/main.stage-id.stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args main.rs`

error: 1 errors occurred comparing output.
status: exit status: 101
command: "/home/dc/.dylint_drivers/nightly-2025-02-20-x86_64-unknown-linux-gnu/dylint-driver" "ui/main.rs" "-L" "/tmp" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-C" "prefer-dynamic" "-o" "/tmp/main.stage-id" "-A" "unused" "--emit=metadata" "-Zui-testing" "-L" "/tmp/main.stage-id.aux"
stdout:
------------------------------------------

------------------------------------------
stderr:
------------------------------------------
error: could not load library `/home/dc/dev/other/test_lint/target/debug/libtest_lint@nightly-2025-02-20-x86_64-unknown-linux-gnu.so`: /home/dc/dev/other/test_lint/target/debug/libtest_lint@nightly-2025-02-20-x86_64-unknown-linux-gnu.so: cannot open shared object file: No such file or directory


------------------------------------------


thread 'ui' panicked at /home/dc/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/compiletest_rs-0.11.2/src/lib.rs:113:22:
Some tests failed
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    ui

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 2.65s

error: test failed, to rerun pass `--lib`

Env

$ cd test_lint 

$ cargo --version
cargo 1.87.0-nightly (ce948f461 2025-02-14)

$ rustc --version
rustc 1.87.0-nightly (f280acf4c 2025-02-19)

$ cargo dylint --version
cargo-dylint 4.1.0


$ cat rust-toolchain
[toolchain]
channel = "nightly-2025-02-20"
components = ["llvm-tools-preview", "rustc-dev"]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions