fedimint / fedimint

Federated E-Cash Mint
https://fedimint.org/
MIT License
577 stars 223 forks source link

Issues running `cargo clippy` #436

Closed justinmoon closed 2 years ago

justinmoon commented 2 years ago

When I run cargo clippy inside nix develop environment on m1 mac, I get a bunch of errors like this:

error[E0514]: found crate `bls12_381` compiled by an incompatible version of rustc
  --> crypto/tbs/src/serde_impl/mod.rs:48:19
   |
48 |     impl_serde_g!(bls12_381::G2Affine, 96);
   |                   ^^^^^^^^^
   |
   = help: please recompile that crate using this compiler (rustc 1.63.0 (4b91a6ea7 2022-08-08)) (consider running `cargo clean` first)
   = note: the following crate versions were found:
           crate `bls12_381` compiled by rustc 1.62.1 (e092d0b6b 2022-07-16): /Users/justin/fedimint/fedimint/target/debug/deps/libbls12_381-64d0036134c989fd.rmeta

cargo and cargo-clippy are both point to nix-store. Here are the versions -- oddly they appear off to me, but both different version numbers from rustc reported in the error. Not sure if these version numbers are supposed to be exactly the same.

$ cargo --version
cargo 1.62.1 (a748cf5a3 2022-06-08)
$ cargo-clippy --version
clippy 0.1.62 (e092d0b6 2022-07-16)

Here's the full log of all errors

justinmoon commented 2 years ago

Also, if I run cargo clippy outside nix with my global installations I don't have any problems ...

justinmoon commented 2 years ago

Hmm. When I uninstalled my global cargo-clippy then problem went away ...

dpc commented 2 years ago

If you happen to hit it next time, please check echo $PATH and then we can check the order in which different instances of this binary are listed in it. My understanding is that the one for the project should come before the global one, so there shouldn't be any problem. But apparently there is.

NicolaLS commented 2 years ago

in nix develop

/nix/store/szc9mx70l0lk32rbyixpq5mska4fzj61-pkg-config-wrapper-0.29.2/bin:/nix/store/lrqki9ns52qhjnvp7g2szvfiz53saygp-rust-stable-with-components-2022-07-19/bin:/nix/store/l6lj8akfl6yw32rhpv9a2i72qykjk7i8-rust-analyzer-nightly-8e38833/bin:/nix/store/ka84p6yzi0a3xr63pjm3jqb53f00k695-cargo-llvm-cov-0.4.14/bin:/nix/store/0nfwa74pb61dfvjcnhjs3vjz71mrlv1v-cargo-udeps-0.1.27/bin:/nix/store/ny7z85kjhlny6q9mr09q5xh9h551hcba-tmux-3.2a/bin:/nix/store/y93p13ga0gzb2lmnmzh13r8s1cq5qdf1-tmuxinator-3.0.1/bin:/nix/store/svn29yxczk7d6fb4glf3yxnway41qd5s-ruby2.7.6-erubis-2.7.0/bin:/nix/store/ba6c4q5y4ga3lxr3k7kxllq1cz7ihlls-ruby2.7.6-thor-1.0.1/bin:/nix/store/c1xxw2ksc2fbwr06qqr5nhgj1np19ksh-ruby2.7.6-xdg-2.2.5/bin:/nix/store/k2b0sbgw1qv3m7vaq1ny2wxdc5z9wh97-nixpkgs-fmt-1.2.0/bin:/nix/store/1ww7j2d11ck652p79szy1p4az1ghyair-shellcheck-0.8.0-bin/bin:/nix/store/sxmgcghdirm16a9wfpzrrzlqj52fby0i-rnix-lsp-0.2.5/bin:/nix/store/546g5q80px64chggnfs1sbn1m2nd31qw-bash-language-server-3.0.2/bin:/nix/store/rkcjmvvqmxb91cpb7an4amjsnj5qq5bw-bc-1.07.1/bin:/nix/store/1af4cixag6kzpin0iajx09aphkp2snx8-bitcoind-23.0/bin:/nix/store/xyrdsgamphh607x23srw6dgks5884yx7-clightning-0.11.1/bin:/nix/store/6b4xh3911c0gdiwkfbiirafra1mblvw9-jq-1.6-bin/bin:/nix/store/bk8r9yav718rw4b9hrja2zggnxb9labm-libressl-3.4.3-nc/bin:/nix/store/dk5lnlbfz4vgyywifl4zaa988p9ixa2n-perl-5.34.1/bin:/nix/store/qlbkagc633r7qhxfwgb0rmfdrj8dmvbi-procps-3.3.16/bin:/nix/store/iffl6dlplhv22i2xy7n1w51a5r631kmi-bash-5.1-p16/bin:/nix/store/knssayvl4p7gfapib4wcfhzy14169kva-patchelf-0.14.5/bin:/nix/store/ag2bpk0lzjvj409znklrz5krkpc5imzs-gcc-wrapper-11.3.0/bin:/nix/store/as1xzrm2921pnxx4jvxj39jn4v88wdy1-gcc-11.3.0/bin:/nix/store/h0cnbmfcn93xm5dg2x27ixhag1cwndga-glibc-2.34-210-bin/bin:/nix/store/7jr7pr4c6yb85xpzay5xafs5zlcadkhz-coreutils-9.0/bin:/nix/store/wp7kc5y840ldi5sd8j81fj4dabccff2d-binutils-wrapper-2.38/bin:/nix/store/rq6bh3qfrqnyqwik0w3q6w180zg3w2pa-binutils-2.38/bin:/nix/store/f8k7b1dgcq99252dymsm40jhc63id29h-clang-wrapper-11.1.0/bin:/nix/store/ymvsha3wzsyx64ci8z5awkfifvjfmdz8-clang-11.1.0/bin:/nix/store/ha3f2z6zjnynpsvsjd46xac7mp495njg-binutils-wrapper-2.38/bin:/nix/store/4d1djd98s1ph0f3aprybgks87390qmyg-openssl-1.1.1q-bin/bin:/nix/store/0ddn1n4jnkv8nzr660rqy6iqrmrqvy5q-rust-stable-with-std-2022-07-19/bin:/nix/store/0znb5mdky7p744837rwhhxdxmv71zj1w-clippy-preview-stable-2022-07-19/bin:/nix/store/j0vvi9a0imi07pgjhg1vq7k7yb0wvrbd-compiler-rt-libc-11.1.0/bin:/nix/store/7jr7pr4c6yb85xpzay5xafs5zlcadkhz-coreutils-9.0/bin:/nix/store/140f6s4nwiawrr3xyxarmcv2mk62m62y-findutils-4.9.0/bin:/nix/store/35swvg68q1j3m9fbhcdnqwk9mlm8plvn-diffutils-3.8/bin:/nix/store/lgvd2fh4cndlv8mnyy49jp1nplpml3xp-gnused-4.8/bin:/nix/store/qd9jxc0q00cr7fp30y6jbbww20gj33lg-gnugrep-3.7/bin:/nix/store/w3p77mkdy3pigg12iyha8y9dqakhjsxn-gawk-5.1.1/bin:/nix/store/jm7czg4lgfhiphkyjwn1k1i8liqqizgi-gnutar-1.34/bin:/nix/store/vqpkbr3isafl4867app44w636zrkr9wp-gzip-1.12/bin:/nix/store/fkwcqfw3gcspmpmxqxqnxjja74sg207g-bzip2-1.0.6.0.2-bin/bin:/nix/store/4gkcrzpn31sb12fnzclyfzhpd8xh8l6x-gnumake-4.3/bin:/nix/store/iffl6dlplhv22i2xy7n1w51a5r631kmi-bash-5.1-p16/bin:/nix/store/c0hmdlwdd85gzmilafg4gzzdb2vpg176-patch-2.7.6/bin:/nix/store/kyg5qxx0nl5hfjx0kgw120b85i4l6i8y-xz-5.2.5-bin/bin:/home/sus/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/home/sus/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/home/sus/.local/bin:/home/sus/bin:/home/sus/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/usr/lib64/ccache:/home/sus/.cargo/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/opt/clion/bin:/opt/clion/bin:/opt/clion/bin:/opt/clion/bin:/opt/clion/bin:/opt/clion/bin

normal:

/home/sus/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/home/sus/.local/bin:/home/sus/bin:/home/sus/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/usr/lib64/ccache:/home/sus/.cargo/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/opt/clion/bin:/opt/clion/bin:/opt/clion/bin:/opt/clion/bin

@dpc

dpc commented 2 years ago

cargo preferes ~/.cargo/bin/ over $PATH and that seems like the root cause. https://github.com/rust-lang/cargo/blob/471b80df64ce80e80c45a0add0eb902f1e15d271/src/bin/cargo/main.rs#L223

dpc commented 2 years ago

https://github.com/rust-lang/cargo/issues/11020 upstream cargo issue to figure out a solution.