Skip to content

Crate not found in integration tests if crate-type = ["cdylib"] #6659

@ckaran

Description

@ckaran

Problem
I am developing code that needs to work with python, which requires me to have a crate type of cdylib. It turns out that when you follow the recommendation to use a tests directory, the code within the directory cannot find the crate, failing with an error like the following:

   Compiling cargo_issue_6659 v0.1.0 (/home/cfkaran2/Desktop/cargo_issue_6659)
     Running `rustc --edition=2018 --crate-name tester tests/tester.rs --color always --emit=dep-info,link -C debuginfo=2 --test -C metadata=0525a91fc572753f -C extra-filename=-0525a91fc572753f --out-dir /home/cfkaran2/Desktop/cargo_issue_6659/target/debug/deps -C incremental=/home/cfkaran2/Desktop/cargo_issue_6659/target/debug/incremental -L dependency=/home/cfkaran2/Desktop/cargo_issue_6659/target/debug/deps`
     Running `rustc --edition=2018 --crate-name cargo_issue_6659 src/lib.rs --color always --emit=dep-info,link -C debuginfo=2 --test -C metadata=b9fa70b838dfddae -C extra-filename=-b9fa70b838dfddae --out-dir /home/cfkaran2/Desktop/cargo_issue_6659/target/debug/deps -C incremental=/home/cfkaran2/Desktop/cargo_issue_6659/target/debug/incremental -L dependency=/home/cfkaran2/Desktop/cargo_issue_6659/target/debug/deps`
error[E0463]: can't find crate for `rustc_issue_report_cdylib`
 --> tests/tester.rs:1:1
  |
1 | extern crate rustc_issue_report_cdylib;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error: Could not compile `cargo_issue_6659`.

Caused by:
  process didn't exit successfully: `rustc --edition=2018 --crate-name tester tests/tester.rs --color always --emit=dep-info,link -C debuginfo=2 --test -C metadata=0525a91fc572753f -C extra-filename=-0525a91fc572753f --out-dir /home/cfkaran2/Desktop/cargo_issue_6659/target/debug/deps -C incremental=/home/cfkaran2/Desktop/cargo_issue_6659/target/debug/incremental -L dependency=/home/cfkaran2/Desktop/cargo_issue_6659/target/debug/deps` (exit code: 1)
warning: build failed, waiting for other jobs to finish...
error: build failed

Steps

  1. Checkout the repository at https://github.com/ckaran/cargo_issue_6659.
  2. Follow the instructions in the README.md

Possible Solution(s)

None known.

Notes

$ cargo -V -vvv
cargo 1.32.0 (8610973aa 2019-01-02)
release: 1.32.0
commit-hash: 8610973aaf48615ba7dc9a38a9a2795ba6f36a31
commit-date: 2019-01-02

$ rustc -Vv
rustc 1.32.0 (9fda7c223 2019-01-16)
binary: rustc
commit-hash: 9fda7c2237db910e41d6a712e9a2139b352e558b
commit-date: 2019-01-16
host: x86_64-unknown-linux-gnu
release: 1.32.0
LLVM version: 8.0

$ uname -a
Linux EMANE 4.15.0-45-generic #48-Ubuntu SMP Tue Jan 29 16:28:13 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

$ lsb_release --all
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.2 LTS
Release:    18.04
Codename:   bionic

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-crate-typesArea: crate-type declaration (lib, staticlib, dylib, cdylib, etc.)A-documenting-cargo-itselfArea: Cargo's documentationS-triageStatus: This issue is waiting on initial triage.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions