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

Error reading Clippy's configuration file... #3874

Closed
Diggsey opened this issue Mar 12, 2019 · 11 comments · Fixed by #4845 or #6575
Closed

Error reading Clippy's configuration file... #3874

Diggsey opened this issue Mar 12, 2019 · 11 comments · Fixed by #4845 or #6575
Labels
C-bug Category: Clippy is not doing the correct thing E-help-wanted Call for participation: Help is requested to fix this issue. good-first-issue These issues are a good way to get started with Clippy

Comments

@Diggsey
Copy link

Diggsey commented Mar 12, 2019

... /opt/.cargo/registry/src/github.com-1ecc6299db9ec823/im-12.3.1/clippy.toml: found deprecated field cyclomatic-complexity-threshold. Please use cognitive-complexity-threshold instead.

I use clippy in CI, and started getting this error a few days ago. The error is coming from one of my dependencies, so I don't expect clippy to be checking it to begin with.

Is there a way to stop clippy from checking dependencies / make the error a warning instead?

@flip1995 flip1995 added the C-bug Category: Clippy is not doing the correct thing label Mar 12, 2019
@flip1995
Copy link
Member

Yeah errors of clippy.toml files of dependencies should not be reported at all.

@oli-obk
Copy link
Contributor

oli-obk commented Mar 12, 2019

I just checked. Our code for detecting the final binary doesn't seem to work anymore. All dependencies are run through clippy-driver, not sure when that changed. What we can do in the short term is to change the error to a normal lint so it will get silenced by --cap-lints.

We should make all the span_err or struct_err calls in

pub fn read_conf(reg: &rustc_plugin::Registry<'_>) -> Conf {
forward to buffer_lint (https://doc.rust-lang.org/nightly/nightly-rustc/rustc/session/struct.Session.html#method.buffer_lint).

@Manishearth
Copy link
Member

The driver stuff got completely rewritten recently since rustc changed how drivers work.

@JeanMertz
Copy link
Contributor

I ran into this as well, with a dependency having a clippy.toml file with a deprecated field (cyclomatic-complexity-threshold).

@flip1995 flip1995 added good-first-issue These issues are a good way to get started with Clippy E-help-wanted Call for participation: Help is requested to fix this issue. labels Jun 13, 2019
josojo added a commit to gnosis/dex-services that referenced this issue Jul 15, 2019
josojo added a commit to gnosis/dex-services that referenced this issue Jul 17, 2019
…ctors (#155)

* get_standing_orders_of_slot will always return models::NUM_OF_ACCOUNT entries

* incorporated all inprovement suggestions, just refactoring

* using unsafe to initialize array, as Standingorder does not implement Copy trait

* clean up, sorry

* indentation

* uses array-macro to initialize the arrays

* test

* changing to newer rust version 1.36

* test only

* another test to make rust run on travis server

* just testing travis

* reverting all unnecessary changes

* updating rust to 1.36 in docker images

* making clippy work: see here: rust-lang/rust-clippy#3874

* stupid testing as I can not yet test it locally

* worst testing

* clean up

* just another test

* one more test

* final test

* finally, Felix found the solution
@Nemo157
Copy link
Member

Nemo157 commented Aug 30, 2019

I just ran into this as well because of using a very old pinned version of clippy on one project. Quick repro with an invalid config file, might be a different error path to having invalid keys in there:

> cd $(mktemp -d)                                                                                                                                                                                
> cargo new --lib foo
     Created library `foo` package
> cd foo
> cargo add --git https://gist.github.com/Nemo157/963cf5ae958aabb40dbf35dea7b8a9e2 bar
      Adding bar (unknown version) to dependencies
> cargo +stable clippy --all-targets
    Updating git repository `https://gist.github.com/Nemo157/963cf5ae958aabb40dbf35dea7b8a9e2`
    Checking bar v0.1.0 (https://gist.github.com/Nemo157/963cf5ae958aabb40dbf35dea7b8a9e2#b81c54a5)
error: error reading Clippy's configuration file `/home/wim/.cargo/git/checkouts/963cf5ae958aabb40dbf35dea7b8a9e2-9bdfc6a77ca53f42/b81c54a/clippy.toml`: expected an equals, found an identifier at line 1

@izik1
Copy link
Contributor

izik1 commented Nov 22, 2019

I have also ran into this unfortunate bug due to using an unmaintained project as a dependency.

I can take this under the assumption that it's still a good-first-issue (presumably if nobody has fixed it, it either isn't as easy as it looks, or is very rare)

bors added a commit that referenced this issue Nov 28, 2019
Don't error on clippy.toml of dependencies

Fixes #3874

Checking for `metadata` wasn't enough anymore. `--cap-lints allow` only appears when compiling deps though.

changelog: none
@bors bors closed this as completed in 350f3d6 Nov 29, 2019
@tylerhawkes
Copy link

I just ran into this with clippy on rust 1.49 for the pin-project-lite and cxx dependencies. Did something break again?

Checking pin-project-lite v0.2.1
error: error reading Clippy's configuration file `/rust/cargo/registry/src/github.com-1ecc6299db9ec823/pin-project-lite-0.2.1/.clippy.toml`: unknown field `msrv`, expected one of `blacklisted-names`, `cognitive-complexity-threshold`, `cyclomatic-complexity-threshold`, `doc-valid-idents`, `too-many-arguments-threshold`, `type-complexity-threshold`, `single-char-binding-names-threshold`, `too-large-for-stack`, `enum-variant-name-threshold`, `enum-variant-size-threshold`, `verbose-bit-mask-threshold`, `literal-representation-threshold`, `trivial-copy-size-limit`, `pass-by-value-size-limit`, `too-many-lines-threshold`, `array-size-threshold`, `vec-box-size-threshold`, `max-trait-bounds`, `max-struct-bools`, `max-fn-params-bools`, `warn-on-all-wildcard-imports`, `disallowed-methods`, `third-party` at line 1 column 1

@taiki-e
Copy link
Member

taiki-e commented Jan 6, 2021

@tylerhawkes
I couldn't reproduce the problem you reported in 1.49.
I guess a version of cargo older than 1.41 as the default is actually called (like tokio-rs/tokio#3355 (comment)).
Could you try with toolchain override shorthand (cargo +stable clippy)?

@tylerhawkes
Copy link

I tried it again and still get the same error. Here's the commands I did to reproduce. I'm inside of a podman container, but that shouldn't matter at all. I tried it on my mac and didn't get an error, so this seems to be linux specific. Cross compiling doesn't matter as I get the error whether I'm compiling for x86_64 or aarch64.

cd /tmp
cargo init clippy-msrv
cd clippy-msrv
echo 'cxx = "1.0.27"' >> Cargo.toml
echo 'pin-project-lite = "0.2.1"' >> Cargo.toml
cat Cargo.toml
# Clean out all of the unzipped crates so they have to be unzipped again
cargo cache -a
CARGO_TARGET_DIR=. cargo +1.49.0-x86_64-unknown-linux-gnu clippy
CARGO_TARGET_DIR=. cargo +1.49.0-x86_64-unknown-linux-gnu clippy
CARGO_TARGET_DIR=. cargo clippy

And here is the output of those commands:

tmp> cargo init clippy-msrv
     Created binary (application) package
tmp> cd clippy-msrv
clippy-msrv [master ?]> echo 'cxx = "1.0.27"' >> Cargo.toml
clippy-msrv [master ?]> echo 'pin-project-lite = "0.2.1"' >> Cargo.toml
clippy-msrv [master ?]> cat Cargo.toml
[package]
name = "clippy-msrv"
version = "0.1.0"
authors = ["Tyler Hawkes <tyler.hawkes@vivint.com>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
cxx = "1.0.27"
pin-project-lite = "0.2.1"
clippy-msrv [master ?]> cargo cache -a
Cargo cache '/rust/cargo':

Total:                            958.74 MB
  25 installed binaries:          231.15 MB
  Registry:                       458.22 MB
    3 registry indices:           155.09 MB
    752 crate archives:           103.97 MB
    360 crate source checkouts:   199.16 MB
  Git db:                         269.37 MB
    7 bare git repos:              80.83 MB
    3 git repo checkouts:         188.54 MB

Clearing cache...

Size changed from 958.74 MB to 571.04 MB (-387.70 MB, -40.43%)
clippy-msrv [master ?]> CARGO_TARGET_DIR=. cargo +1.49.0-x86_64-unknown-linux-gnu clippy
    Updating crates.io index
   Compiling cc v1.0.66
   Compiling proc-macro2 v1.0.24
   Compiling unicode-xid v0.2.1
   Compiling syn v1.0.58
   Compiling cxxbridge-flags v1.0.27
    Checking pin-project-lite v0.2.1
error: error reading Clippy's configuration file `/rust/cargo/registry/src/github.com-1ecc6299db9ec823/pin-project-lite-0.2.1/.clippy.toml`: unknown field `msrv`, expected one of `blacklisted-names`, `cognitive-complexity-threshold`, `cyclomatic-complexity-threshold`, `doc-valid-idents`, `too-many-arguments-threshold`, `type-complexity-threshold`, `single-char-binding-names-threshold`, `too-large-for-stack`, `enum-variant-name-threshold`, `enum-variant-size-threshold`, `verbose-bit-mask-threshold`, `literal-representation-threshold`, `trivial-copy-size-limit`, `pass-by-value-size-limit`, `too-many-lines-threshold`, `array-size-threshold`, `vec-box-size-threshold`, `max-trait-bounds`, `max-struct-bools`, `max-fn-params-bools`, `warn-on-all-wildcard-imports`, `disallowed-methods`, `third-party` at line 1 column 1

error: aborting due to previous error

error: could not compile `pin-project-lite`

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failed
clippy-msrv [master ?] 101> CARGO_TARGET_DIR=. cargo +1.49.0-x86_64-unknown-linux-gnu clippy
    Checking pin-project-lite v0.2.1
   Compiling link-cplusplus v1.0.4
   Compiling proc-macro2 v1.0.24
   Compiling syn v1.0.58
   Compiling cxx v1.0.27
error: error reading Clippy's configuration file `/rust/cargo/registry/src/github.com-1ecc6299db9ec823/cxx-1.0.27/.clippy.toml`: unknown field `msrv`, expected one of `blacklisted-names`, `cognitive-complexity-threshold`, `cyclomatic-complexity-threshold`, `doc-valid-idents`, `too-many-arguments-threshold`, `type-complexity-threshold`, `single-char-binding-names-threshold`, `too-large-for-stack`, `enum-variant-name-threshold`, `enum-variant-size-threshold`, `verbose-bit-mask-threshold`, `literal-representation-threshold`, `trivial-copy-size-limit`, `pass-by-value-size-limit`, `too-many-lines-threshold`, `array-size-threshold`, `vec-box-size-threshold`, `max-trait-bounds`, `max-struct-bools`, `max-fn-params-bools`, `warn-on-all-wildcard-imports`, `disallowed-methods`, `third-party` at line 1 column 1

error: error reading Clippy's configuration file `/rust/cargo/registry/src/github.com-1ecc6299db9ec823/pin-project-lite-0.2.1/.clippy.toml`: unknown field `msrv`, expected one of `blacklisted-names`, `cognitive-complexity-threshold`, `cyclomatic-complexity-threshold`, `doc-valid-idents`, `too-many-arguments-threshold`, `type-complexity-threshold`, `single-char-binding-names-threshold`, `too-large-for-stack`, `enum-variant-name-threshold`, `enum-variant-size-threshold`, `verbose-bit-mask-threshold`, `literal-representation-threshold`, `trivial-copy-size-limit`, `pass-by-value-size-limit`, `too-many-lines-threshold`, `array-size-threshold`, `vec-box-size-threshold`, `max-trait-bounds`, `max-struct-bools`, `max-fn-params-bools`, `warn-on-all-wildcard-imports`, `disallowed-methods`, `third-party` at line 1 column 1

error: aborting due to previous error

error: could not compile `pin-project-lite`

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: aborting due to previous error

error: build failed
clippy-msrv [master ?] 101> CARGO_TARGET_DIR=. cargo clippy
    Checking pin-project-lite v0.2.1
   Compiling proc-macro2 v1.0.24
   Compiling link-cplusplus v1.0.4
   Compiling cxx v1.0.27
error: error reading Clippy's configuration file `/rust/cargo/registry/src/github.com-1ecc6299db9ec823/cxx-1.0.27/.clippy.toml`: unknown field `msrv`, expected one of `blacklisted-names`, `cognitive-complexity-threshold`, `cyclomatic-complexity-threshold`, `doc-valid-idents`, `too-many-arguments-threshold`, `type-complexity-threshold`, `single-char-binding-names-threshold`, `too-large-for-stack`, `enum-variant-name-threshold`, `enum-variant-size-threshold`, `verbose-bit-mask-threshold`, `literal-representation-threshold`, `trivial-copy-size-limit`, `pass-by-value-size-limit`, `too-many-lines-threshold`, `array-size-threshold`, `vec-box-size-threshold`, `max-trait-bounds`, `max-struct-bools`, `max-fn-params-bools`, `warn-on-all-wildcard-imports`, `disallowed-methods`, `third-party` at line 1 column 1

error: error reading Clippy's configuration file `/rust/cargo/registry/src/github.com-1ecc6299db9ec823/pin-project-lite-0.2.1/.clippy.toml`: unknown field `msrv`, expected one of `blacklisted-names`, `cognitive-complexity-threshold`, `cyclomatic-complexity-threshold`, `doc-valid-idents`, `too-many-arguments-threshold`, `type-complexity-threshold`, `single-char-binding-names-threshold`, `too-large-for-stack`, `enum-variant-name-threshold`, `enum-variant-size-threshold`, `verbose-bit-mask-threshold`, `literal-representation-threshold`, `trivial-copy-size-limit`, `pass-by-value-size-limit`, `too-many-lines-threshold`, `array-size-threshold`, `vec-box-size-threshold`, `max-trait-bounds`, `max-struct-bools`, `max-fn-params-bools`, `warn-on-all-wildcard-imports`, `disallowed-methods`, `third-party` at line 1 column 1

error: aborting due to previous error

error: could not compile `pin-project-lite`

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: aborting due to previous error

error: build failed

@tylerhawkes
Copy link

My co-workers have also been seeing this. We all share the same podman image and it has CLIPPY_TESTS=true. If I set that environment variable on my mac it also has the same issue.
So after a little googling it looks like that got set because we use sccache and I was toying around with getting it to work with clippy. However, this comment makes it look like clippy is really trying to lint all dependencies and it dies trying to parse the clippy.toml file. It would be nice if stable clippy didn't just die since other crates can include settings that are specific to nightly.

@flip1995
Copy link
Member

flip1995 commented Jan 7, 2021

Ah, you have CLIPPY_TESTS as an env var in your CI/testsuite/...? If that is set to true (and only true, no other value), then Clippy will lint all dependencies, because it is enabled unconditionally. We need this for Clippys testsuite.

Since CLIPPY_TESTS is a reasonable env var for enabling/disabling Clippy tests, we should change the env var, we use internally. This can be done here:

let clippy_tests_set = env::var("CLIPPY_TESTS").map_or(false, |val| val == "true");
and in every other place in the Clippy repo, where this var is used. If no one does it until tomorrow, I'll get to it myself.


I now wonder, why we never had this complaint before 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing E-help-wanted Call for participation: Help is requested to fix this issue. good-first-issue These issues are a good way to get started with Clippy
Projects
None yet
9 participants