Skip to content

Cargo test is not loading dynamic library (macos) #6623

@josephg

Description

@josephg

Problem

The rust foundationdb bindings depend on libfdb_c.dylib in /usr/local/lib. cargo test fails because it can't find the library, but when I invoke the compiled library directly it works.

This is a regression - it works fine in stable. It only fails in cargo from nightly.

$ cargo test
    Finished dev [unoptimized + debuginfo] target(s) in 1.06s
     Running target/debug/deps/foundationdb-997674909324b5af
dyld: Library not loaded: libfdb_c.dylib
  Referenced from: /Users/josephg/src/ff2-rs/target/debug/deps/foundationdb-997674909324b5af
  Reason: image not found
error: process didn't exit successfully: `/Users/josephg/src/ff2-rs/target/debug/deps/foundationdb-997674909324b5af` (signal: 6, SIGABRT: process abort signal)

But if I invoke the executable directly:

$ /Users/josephg/src/ff2-rs/target/debug/deps/foundationdb-997674909324b5af
running 19 tests
test fdb_api::tests::test_max_api ... ok
test subspace::tests::pack_unpack ... ok
...

test result: ok. 19 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

Tested on:

  • cargo 1.33.0-nightly (907c0fe 2019-01-20) / nightly toolchain 2019-01-20 (fails)
  • cargo 1.34.0-nightly (2458180 2019-01-27) / nightly toolchain 2019-02-02 (fails)
  • cargo 1.32.0 (8610973 2019-01-02) (works)

I haven't tested this on linux or windows.

Probably related to #3366

Steps

  1. Either install foundationdb from here, or just download libfdb_c.dylib and place it in /usr/local/lib
  2. git clone https://github.com/bluejekyll/foundationdb-rs.git. I've been reproducing this problem using the current master (Clikengo/foundationdb-rs@95d49a1)
  3. cargo test. The test binary should launch, then run or complain about not being able to connect to your cluster.

Notes

I tried adding cargo:rustc-link-search=/usr/local/lib in foundationdb-sys's build.rs file, but that seems to have no effect.

I'm not sure how to inspect cargo's testing environment (environment variables / command line options / etc).

fdb issue: Clikengo/foundationdb-rs#112

Metadata

Metadata

Assignees

Labels

C-bugCategory: bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions