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

Rust 1.38 confused about which version of crate to use #111

Open
AndyGauge opened this issue Sep 19, 2019 · 8 comments
Open

Rust 1.38 confused about which version of crate to use #111

AndyGauge opened this issue Sep 19, 2019 · 8 comments

Comments

@AndyGauge
Copy link
Contributor

AndyGauge commented Sep 19, 2019

On the cookbook, I started receiving errors regarding rand, which indicated the crate version was .4, which was true on a dependency of a dependency. In my case I was depending on tempdir, which depended on rand .4. I also had a dependency for postgres .3 which had a dependency for a dependency for rand .4

Travis would use the .4 rand version on nightly, and the same thing happened locally when I ran cargo test with nightly. I removed those dependencies and rust skeptic ran using the right rand crate.

I'm seeing the same thing with percent_encoding. I'm getting errors on nightly that indicate AsciiSet and CONTROLS are not present, which is true of percent_encoding 1 which is depended by url 1.7.2 depended by cookie depended by reqwest. The test failures are consistent, and only on nightly.

Not even sure if this is a problem with rust-skeptic or if anyone else has seen this.

@AndyGauge
Copy link
Contributor Author

Here's the command that fails

rustc /tmp/rust-skeptic.3JaXGrFrkNNc/test.rs --verbose --crate-type=bin -L /mnt/c/git/rust-cookbook/target/debug -L /mnt/c/git/rust-cookbook/target/debug/deps --target x86_64-unknown-linux-gnu --extern log4rs=/mnt/c/git/rust-cookbook/target/debug/deps/liblog4rs-35917f533b36fa76.rlib --extern byteorder=/mnt/c/git/rust-cookbook/target/debug/deps/libbyteorder-bfd6a33591b0bf92.rlib --extern tar=/mnt/c/git/rust-cookbook/target/debug/deps/libtar-8608925c42f72eeb.rlib --extern glob=/mnt/c/git/rust-cookbook/target/debug/deps/libglob-0e644cf38ed1cb01.rlib --extern percent_encoding=/mnt/c/git/rust-cookbook/target/debug/deps/libpercent_encoding-5d280a6e28dac6b1.rlib --extern mime=/mnt/c/git/rust-cookbook/target/debug/deps/libmime-ecb979ba73e099e8.rlib --extern env_logger=/mnt/c/git/rust-cookbook/target/debug/deps/libenv_logger-31673ad04a8134bf.rlib --extern error_chain=/mnt/c/git/rust-cookbook/target/debug/deps/liberror_chain-47436aabe7acf87b.rlib --extern semver=/mnt/c/git/rust-cookbook/target/debug/deps/libsemver-2ff3915a7a8c5ea7.rlib --extern chrono=/mnt/c/git/rust-cookbook/target/debug/deps/libchrono-47d63b428bf87ea7.rlib --extern base64=/mnt/c/git/rust-cookbook/target/debug/deps/libbase64-4c46cf44aadfdb88.rlib --extern ndarray=/mnt/c/git/rust-cookbook/target/debug/deps/libndarray-e4a5ce1e76c2deef.rlib --extern data_encoding=/mnt/c/git/rust-cookbook/target/debug/deps/libdata_encoding-9ed6bc91d2ca7a06.rlib --extern skeptic=/mnt/c/git/rust-cookbook/target/debug/deps/libskeptic-1f2ff72d5bc6de09.rlib --extern tempfile=/mnt/c/git/rust-cookbook/target/debug/deps/libtempfile-68ab961c69df87ea.rlib --extern rand=/mnt/c/git/rust-cookbook/target/debug/deps/librand-049df2cb6fcbc04f.rlib --extern serde_derive=/mnt/c/git/rust-cookbook/target/debug/deps/libserde_derive-6a163acfe8ae4176.so --extern csv=/mnt/c/git/rust-cookbook/target/debug/deps/libcsv-8561f880abd2340a.rlib --extern image=/mnt/c/git/rust-cookbook/target/debug/deps/libimage-2e30043dc83a4982.rlib --extern ring=/mnt/c/git/rust-cookbook/target/debug/deps/libring-323d82064da3db20.rlib --extern syslog=/mnt/c/git/rust-cookbook/target/debug/deps/libsyslog-0f3c8aa5caad17ee.rlib --extern threadpool=/mnt/c/git/rust-cookbook/target/debug/deps/libthreadpool-7b8f335bbb6f07c2.rlib --extern unicode_segmentation=/mnt/c/git/rust-cookbook/target/debug/deps/libunicode_segmentation-14596116ea3f1da9.rlib --extern postgres=/mnt/c/git/rust-cookbook/target/debug/deps/libpostgres-755efb724c36ee21.rlib --extern num=/mnt/c/git/rust-cookbook/target/debug/deps/libnum-087494f833b8bd66.rlib --extern rusqlite=/mnt/c/git/rust-cookbook/target/debug/deps/librusqlite-566241e7fab8a387.rlib --extern rayon=/mnt/c/git/rust-cookbook/target/debug/deps/librayon-048c707cbfca3baf.rlib --extern memmap=/mnt/c/git/rust-cookbook/target/debug/deps/libmemmap-3fb4012446d2d6e9.rlib --extern same_file=/mnt/c/git/rust-cookbook/target/debug/deps/libsame_file-f6aee20220205724.rlib --extern toml=/mnt/c/git/rust-cookbook/target/debug/deps/libtoml-2199bf943b5c1573.rlib --extern cc=/mnt/c/git/rust-cookbook/target/debug/deps/libcc-f29683721ac677d9.rlib --extern serde_json=/mnt/c/git/rust-cookbook/target/debug/deps/libserde_json-80bcf31fead57a44.rlib --extern num_cpus=/mnt/c/git/rust-cookbook/target/debug/deps/libnum_cpus-2632c7ef5c4da14a.rlib --extern regex=/mnt/c/git/rust-cookbook/target/debug/deps/libregex-9d8bcbcae43c7280.rlib --extern crossbeam=/mnt/c/git/rust-cookbook/target/debug/deps/libcrossbeam-0b4b2b9e8c2dabc2.rlib --extern serde=/mnt/c/git/rust-cookbook/target/debug/deps/libserde-31de100fe0a18fe7.rlib --extern bitflags=/mnt/c/git/rust-cookbook/target/debug/deps/libbitflags-28c99b04f1f6c714.rlib --extern lazy_static=/mnt/c/git/rust-cookbook/target/debug/deps/liblazy_static-874726ace88510f1.rlib --extern clap=/mnt/c/git/rust-cookbook/target/debug/deps/libclap-0b6b015bd1f801c5.rlib --extern log=/mnt/c/git/rust-cookbook/target/debug/deps/liblog-64fc7b3ac8e1c167.rlib --extern petgraph=/mnt/c/git/rust-cookbook/target/debug/deps/libpetgraph-8e1ed44adb3ddcea.rlib --extern walkdir=/mnt/c/git/rust-cookbook/target/debug/deps/libwalkdir-050d9b19da2ee3cd.rlib --extern ansi_term=/mnt/c/git/rust-cookbook/target/debug/deps/libansi_term-8df2a45010f3f8a0.rlib --extern nalgebra=/mnt/c/git/rust-cookbook/target/debug/deps/libnalgebra-4d757f6dba29c50a.rlib --extern reqwest=/mnt/c/git/rust-cookbook/target/debug/deps/libreqwest-b224f1507d5e7c4f.rlib --extern url=/mnt/c/git/rust-cookbook/target/debug/deps/liburl-6f32df3ff8242f5b.rlib --extern select=/mnt/c/git/rust-cookbook/target/debug/deps/libselect-78ac6669fb23cb1b.rlib --extern flate2=/mnt/c/git/rust-cookbook/target/debug/deps/libflate2-4ed854488ccb675f.rlib -o /tmp/rust-skeptic.3JaXGrFrkNNc/out.exe

I'm assuming the --extern percent_encoding=/mnt/c/git/rust-cookbook/target/debug/deps/libpercent_encoding-5d280a6e28dac6b1.rlib should be the other rlib in that directory.

@AndyGauge
Copy link
Contributor Author

Here's a sample program exhibiting the problem:
https://github.com/AndyGauge/Skeptic-issue-111

@AndyGauge AndyGauge changed the title Nightly Rust confused about which version of crate to use Rust 1.38 confused about which version of crate to use Oct 2, 2019
@AndyGauge
Copy link
Contributor Author

As of Rust 1.38 (September 23) this issue is on stable.

@budziq
Copy link
Owner

budziq commented Oct 2, 2019

Hi @AndyGauge thanks for the report and sorry for late reply. I'll try to look into it although I cannot give any realistic ETA at the moment :(

@AndyGauge
Copy link
Contributor Author

Glad to hear from you! Hope everything is well with the family. Thanks for checking into it.

@djc
Copy link
Collaborator

djc commented Oct 8, 2019

We're also seeing this with err-derive. cargo clean works around the problem.

@AndyGauge
Copy link
Contributor Author

AndyGauge commented Jun 4, 2020

I can see what is causing this but haven't figured out a solution yet.

When cargo compiles dependencies, it adds some information into the target/{BUILD}/.fingerprint directory. Skeptic uses the json file to determine which crate to use. By looking at the source code, it would appear that at some point in time, local: { precalculated: "version" } was available to determine which version the compiled library (stored in deps/crate-hash). Now this value is no longer available, Skeptic proceeds because the value is an Option but when it comes time to compare 2 rlibs, they are equal . Sometimes the hash is alphabetically correct so everything works, and sometimes the wrong version is used.

@djc
Copy link
Collaborator

djc commented Mar 17, 2021

I cannot reproduce this with the repository from https://github.com/AndyGauge/Skeptic-issue-111 -- the tests pass for me with current skeptic. Not sure if people are still seeing this?

jamesgraves added a commit to jamesgraves/rust-cookbook that referenced this issue Feb 16, 2022
Moving away from using skeptic. Instead code will live as regular
Rust source code example files in their own directory, and the
Markdown will just include those source files.

The main reason for doing this is to avoid a bug in skeptic that
will try to compile test functions against the incorrect version
of a dependent crate.

See:

budziq/rust-skeptic#111

rust-lang-nursery#630

With this change, the rand examples will just depend upon a few
other crates.  Also, for testing or general evaluation, a user
may clone this entire repository, just go into the examples and
run and modify them easily.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants