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

Clippy get's installed every time #239

Closed
lukasschlueter opened this issue May 30, 2019 · 14 comments
Closed

Clippy get's installed every time #239

lukasschlueter opened this issue May 30, 2019 · 14 comments
Assignees
Labels
Milestone

Comments

@lukasschlueter
Copy link

Describe the bug
Starting with v0.19.3, running cargo make ci-flow always tries to install the latest clippy from the github repository and doesn't care if clippy is already installed.
This leads to a break as clippy does currently not build for the latest nightly.
Also, according to #236 (comment), it should try to install using rustup if cargo install fails, which also does not seem to happen.
So I think there are actually two bugs:

  1. Cargo make doesn't check if clippy is already installed
  2. If cargo install fails, rustup component add clippy is not getting tried

To Reproduce
Steps to reproduce the behavior:

  1. Install nightly-2019-05-22 which has the clippy component: rustup default nightly-2019-05-22
  2. Add clippy: rustup component add clippy
  3. Run CARGO_MAKE_RUN_CLIPPY=true cargo make ci-flow or cargo make install-clippy for a minimal example

Error Stack

$ cargo make install-clippy
[cargo-make] INFO - cargo make 0.19.3
[cargo-make] INFO - Using Build File: Makefile.toml
[cargo-make] INFO - Task: install-clippy
[cargo-make] INFO - Profile: development
[cargo-make] INFO - Running Task: init
[cargo-make] INFO - Running Task: install-clippy
[cargo-make] INFO - Running Task: install-clippy-github
[cargo-make] INFO - Execute Command: "cargo" "install" "--git" "https://github.com/rust-lang/rust-clippy/" "--force" "clippy"
    Updating git repository `https://github.com/rust-lang/rust-clippy/`
  Installing clippy v0.0.212 (https://github.com/rust-lang/rust-clippy/#b1762e3e)
    Updating crates.io index
   Compiling proc-macro2 v0.4.30
   Compiling unicode-xid v0.1.0
   Compiling cc v1.0.37
   Compiling syn v0.15.34
   Compiling libc v0.2.55
   Compiling autocfg v0.1.4
   Compiling version_check v0.1.5
   Compiling ryu v0.2.8
   Compiling serde v1.0.91
   Compiling cfg-if v0.1.9
   Compiling memchr v2.2.0
   Compiling matches v0.1.8
   Compiling smallvec v0.6.9
   Compiling rustc-demangle v0.1.15
   Compiling semver-parser v0.7.0
   Compiling itoa v0.4.4
   Compiling unicode-width v0.1.5
   Compiling pulldown-cmark v0.5.2
   Compiling regex v1.1.6
   Compiling percent-encoding v1.0.1
   Compiling rustc_tools_util v0.2.0 (https://github.com/rust-lang/rust-clippy/#b1762e3e)
   Compiling either v1.5.2
   Compiling ucd-util v0.1.3
   Compiling lazy_static v1.3.0
   Compiling bitflags v1.0.4
   Compiling quine-mc_cluskey v0.2.4
   Compiling if_chain v1.0.0
   Compiling utf8-ranges v1.0.2
   Compiling unicode-bidi v0.3.4
   Compiling unicode-normalization v0.1.8
   Compiling backtrace v0.3.26
   Compiling getopts v0.2.19
   Compiling error-chain v0.12.1
   Compiling unicase v2.4.0
   Compiling itertools v0.8.0
   Compiling thread_local v0.3.6
   Compiling clippy v0.0.212 (https://github.com/rust-lang/rust-clippy/#b1762e3e)
   Compiling regex-syntax v0.6.6
   Compiling backtrace-sys v0.1.28
   Compiling aho-corasick v0.7.3
   Compiling idna v0.1.5
   Compiling quote v0.6.12
   Compiling serde_derive v1.0.91
   Compiling url v1.7.2
   Compiling semver v0.9.0
   Compiling serde_json v1.0.39
   Compiling toml v0.5.1
   Compiling cargo_metadata v0.7.4
   Compiling clippy_lints v0.0.212 (https://github.com/rust-lang/rust-clippy/#b1762e3e)
error[E0432]: unresolved import `syntax::symbol::kw`
  --> /home/lukas/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/b1762e3/clippy_lints/src/utils/mod.rs:48:22
   |
48 | use syntax::symbol::{kw, Symbol};
   |                      ^^ no `kw` in `symbol`

error[E0432]: unresolved import `syntax::symbol::kw`
 --> /home/lukas/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/b1762e3/clippy_lints/src/lifetimes.rs:9:5
  |
9 | use syntax::symbol::kw;
  |     ^^^^^^^^^^^^^^^^^^ no `kw` in `symbol`

error[E0432]: unresolved import `syntax_pos::symbol::kw`
  --> /home/lukas/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/b1762e3/clippy_lints/src/use_self.rs:11:5
   |
11 | use syntax_pos::symbol::kw;
   |     ^^^^^^^^^^^^^^^^^^^^^^ no `kw` in `symbol`

error[E0433]: failed to resolve: could not find `kw` in `symbol`
  --> /home/lukas/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/b1762e3/clippy_lints/src/const_static_lifetime.rs:50:71
   |
50 |                             if lifetime.ident.name == syntax::symbol::kw::StaticLifetime {
   |                                                                       ^^ could not find `kw` in `symbol`

error[E0433]: failed to resolve: use of undeclared type or module `AssocItemKind`
   --> /home/lukas/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/b1762e3/clippy_lints/src/len_zero.rs:123:23
    |
123 |             && if let AssocItemKind::Method { has_self } = item.kind {
    |                       ^^^^^^^^^^^^^ use of undeclared type or module `AssocItemKind`

error[E0433]: failed to resolve: could not find `AssocKind` in `ty`
   --> /home/lukas/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/b1762e3/clippy_lints/src/len_zero.rs:151:31
    |
151 |                 i.kind == ty::AssocKind::Method
    |                               ^^^^^^^^^ could not find `AssocKind` in `ty`

error[E0433]: failed to resolve: use of undeclared type or module `AssocItemKind`
   --> /home/lukas/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/b1762e3/clippy_lints/src/len_zero.rs:174:23
    |
174 |             && if let AssocItemKind::Method { has_self } = item.kind {
    |                       ^^^^^^^^^^^^^ use of undeclared type or module `AssocItemKind`

error[E0433]: failed to resolve: could not find `AssocKind` in `ty`
   --> /home/lukas/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/b1762e3/clippy_lints/src/len_zero.rs:263:20
    |
263 |         if let ty::AssocKind::Method = item.kind {
    |                    ^^^^^^^^^ could not find `AssocKind` in `ty`

error[E0433]: failed to resolve: could not find `AssocItemKind` in `hir`
  --> /home/lukas/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/b1762e3/clippy_lints/src/new_without_default.rs:98:29
   |
98 |                 if let hir::AssocItemKind::Method { has_self: false } = assoc_item.kind {
   |                             ^^^^^^^^^^^^^ could not find `AssocItemKind` in `hir`

error[E0433]: failed to resolve: use of undeclared type or module `AssocItemKind`
   --> /home/lukas/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/b1762e3/clippy_lints/src/trivially_copy_pass_by_ref.rs:133:20
    |
133 |             if let AssocItemKind::Method { .. } = item.kind {
    |                    ^^^^^^^^^^^^^ use of undeclared type or module `AssocItemKind`

error[E0433]: failed to resolve: could not find `AssocKind` in `ty`
   --> /home/lukas/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/b1762e3/clippy_lints/src/use_self.rs:122:36
    |
122 |             assoc_item.kind == ty::AssocKind::Method
    |                                    ^^^^^^^^^ could not find `AssocKind` in `ty`

error[E0412]: cannot find type `AssocItem` in module `ty`
   --> /home/lukas/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/b1762e3/clippy_lints/src/len_zero.rs:262:57
    |
262 |     fn is_is_empty(cx: &LateContext<'_, '_>, item: &ty::AssocItem) -> bool {
    |                                                         ^^^^^^^^^ not found in `ty`

error[E0412]: cannot find type `Body` in module `mir`
   --> /home/lukas/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/b1762e3/clippy_lints/src/redundant_clone.rs:215:21
    |
215 |     mir: &'tcx mir::Body<'tcx>,
    |                     ^^^^ not found in `mir`
help: possible candidate is found in another module, you can import it into scope
    |
1   | use rustc::hir::Body;
    |

error[E0412]: cannot find type `Body` in module `mir`
   --> /home/lukas/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/b1762e3/clippy_lints/src/redundant_clone.rs:239:16
    |
239 |     mir: &mir::Body<'tcx>,
    |                ^^^^ not found in `mir`
help: possible candidate is found in another module, you can import it into scope
    |
1   | use rustc::hir::Body;
    |

error[E0412]: cannot find type `Body` in module `mir`
   --> /home/lukas/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/b1762e3/clippy_lints/src/redundant_clone.rs:273:16
    |
273 |     mir: &mir::Body<'tcx>,
    |                ^^^^ not found in `mir`
help: possible candidate is found in another module, you can import it into scope
    |
1   | use rustc::hir::Body;
    |

error[E0531]: cannot find unit struct/variant or constant `Str` in module `token`
   --> /home/lukas/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/b1762e3/clippy_lints/src/write.rs:279:28
    |
279 |                     token::Str => break,
    |                            ^^^
help: a unit variant with a similar name exists
    |
279 |                     token::Shr => break,
    |                            ^^^
help: possible candidates are found in other modules, you can import them into scope
    |
1   | use rustc::hir::PrimTy::Str;
    |
1   | use rustc::hir::Str;
    |
1   | use rustc::ty::Str;
    |
1   | use rustc::ty::TyKind::Str;
    |

error[E0631]: type mismatch in function arguments
   --> /home/lukas/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/b1762e3/clippy_lints/src/consts.rs:257:26
    |
257 |                         .map(Symbol::as_str)
    |                          ^^^
    |                          |
    |                          expected signature of `fn(syntax::symbol::LocalInternedString) -> _`
    |                          found signature of `fn(syntax_pos::Symbol) -> _`

error[E0599]: no method named `collect` found for type `std::iter::Map<std::iter::Copied<std::slice::Iter<'_, syntax::symbol::LocalInternedString>>, fn(syntax_pos::Symbol) -> syntax::symbol::LocalInternedString {syntax_pos::Symbol::as_str}>` in the current scope
   --> /home/lukas/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/b1762e3/clippy_lints/src/consts.rs:258:26
    |
258 |                         .collect::<Vec<_>>();
    |                          ^^^^^^^
    |
    = note: the method `collect` exists but the following trait bounds were not satisfied:
            `&mut std::iter::Map<std::iter::Copied<std::slice::Iter<'_, syntax::symbol::LocalInternedString>>, fn(syntax_pos::Symbol) -> syntax::symbol::LocalInternedString {syntax_pos::Symbol::as_str}> : std::iter::Iterator`
            `std::iter::Map<std::iter::Copied<std::slice::Iter<'_, syntax::symbol::LocalInternedString>>, fn(syntax_pos::Symbol) -> syntax::symbol::LocalInternedString {syntax_pos::Symbol::as_str}> : std::iter::Iterator`

error[E0599]: no variant or associated item named `AssocConst` found for type `rustc::hir::def::DefKind` in the current scope
   --> /home/lukas/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/b1762e3/clippy_lints/src/consts.rs:333:66
    |
333 |             Res::Def(DefKind::Const, def_id) | Res::Def(DefKind::AssocConst, def_id) => {
    |                                                                  ^^^^^^^^^^ variant or associated item not found in `rustc::hir::def::DefKind`

error: no variant `Raw` in enum `rustc_mir::interpret::Scalar<_, _>`
   --> /home/lukas/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/b1762e3/clippy_lints/src/consts.rs:475:36
    |
475 |         ConstValue::Scalar(Scalar::Raw { data: d, .. }) => match result.ty.sty {
    |                            --------^^^
    |                            |
    |                            variant not found in `rustc_mir::interpret::Scalar<_, _>`

error[E0026]: variant `rustc_mir::interpret::ConstValue::Slice` does not have fields named `data`, `start`, `end`
   --> /home/lukas/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/b1762e3/clippy_lints/src/consts.rs:493:29
    |
493 |         ConstValue::Slice { data, start, end } => match result.ty.sty {
    |                             ^^^^  ^^^^^  ^^^ variant `rustc_mir::interpret::ConstValue::Slice` does not have these fields

error[E0027]: pattern does not mention fields `0`, `1`
   --> /home/lukas/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/b1762e3/clippy_lints/src/consts.rs:493:9
    |
493 |         ConstValue::Slice { data, start, end } => match result.ty.sty {
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing fields `0`, `1`
    |
    = note: trying to match a tuple variant with a struct variant pattern

error[E0308]: mismatched types
   --> /home/lukas/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/b1762e3/clippy_lints/src/utils/mod.rs:252:50
    |
252 |             for item in mem::replace(&mut items, cx.tcx.arena.alloc_slice(&result)).iter() {
    |                                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `std::rc::Rc`, found &mut [_]
    |
    = note: expected type `std::rc::Rc<std::vec::Vec<rustc::hir::def::Export<rustc::hir::HirId>>>`
               found type `&mut [_]`

error[E0308]: mismatched types
    --> /home/lukas/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/b1762e3/clippy_lints/src/utils/mod.rs:1128:28
     |
1128 |     cx.match_def_path(did, &syms)
     |                            ^^^^^ expected slice, found struct `std::vec::Vec`
     |
     = note: expected type `&[&str]`
                found type `&std::vec::Vec<syntax_pos::Symbol>`

error[E0631]: type mismatch in function arguments
   --> /home/lukas/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/b1762e3/clippy_lints/src/enum_clike.rs:59:64
    |
59  |                     if let Some(Constant::Int(val)) = constant.and_then(miri_to_const) {
    |                                                                ^^^^^^^^ expected signature of `fn(rustc::ty::Const<'_>) -> _`
    |
   ::: /home/lukas/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/b1762e3/clippy_lints/src/consts.rs:472:1
    |
472 | pub fn miri_to_const(result: &ty::Const<'_>) -> Option<Constant> {
    | ---------------------------------------------------------------- found signature of `for<'r, 's> fn(&'r rustc::ty::Const<'s>) -> _`

error[E0599]: no variant or associated item named `AssocConst` found for type `rustc::hir::def::DefKind` in the current scope
   --> /home/lukas/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/b1762e3/clippy_lints/src/non_copy_const.rs:198:65
    |
198 |                 Res::Def(DefKind::Const, _) | Res::Def(DefKind::AssocConst, _) => {},
    |                                                                 ^^^^^^^^^^ variant or associated item not found in `rustc::hir::def::DefKind`

error[E0277]: the trait bound `syntax_pos::Symbol: std::ops::deref::Deref` is not satisfied
    --> /home/lukas/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/b1762e3/clippy_lints/src/types.rs:1095:21
     |
1095 |         if names[0] == sym!(libc) || names[0] == sym::core && *names.last().unwrap() == sym!(c_void) {
     |                     ^^ the trait `std::ops::deref::Deref` is not implemented for `syntax_pos::Symbol`
     |
     = note: required because of the requirements on the impl of `std::cmp::PartialEq<syntax_pos::Symbol>` for `syntax::symbol::LocalInternedString`

error[E0277]: the trait bound `syntax_pos::Symbol: std::ops::deref::Deref` is not satisfied
    --> /home/lukas/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/b1762e3/clippy_lints/src/types.rs:1095:47
     |
1095 |         if names[0] == sym!(libc) || names[0] == sym::core && *names.last().unwrap() == sym!(c_void) {
     |                                               ^^ the trait `std::ops::deref::Deref` is not implemented for `syntax_pos::Symbol`
     |
     = note: required because of the requirements on the impl of `std::cmp::PartialEq<syntax_pos::Symbol>` for `syntax::symbol::LocalInternedString`

error[E0277]: the trait bound `syntax_pos::Symbol: std::ops::deref::Deref` is not satisfied
    --> /home/lukas/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/b1762e3/clippy_lints/src/types.rs:1095:86
     |
1095 |         if names[0] == sym!(libc) || names[0] == sym::core && *names.last().unwrap() == sym!(c_void) {
     |                                                                                      ^^ the trait `std::ops::deref::Deref` is not implemented for `syntax_pos::Symbol`
     |
     = note: required because of the requirements on the impl of `std::cmp::PartialEq<syntax_pos::Symbol>` for `syntax::symbol::LocalInternedString`

error[E0023]: this pattern has 1 field, but the corresponding tuple variant has 2 fields
   --> /home/lukas/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/b1762e3/clippy_lints/src/write.rs:277:41
    |
277 |             if let (TokenTree::Token(_, token::Token::Literal(lit)), _) = token {
    |                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected 2 fields, found 1

error[E0023]: this pattern has 1 field, but the corresponding tuple variant has 2 fields
   --> /home/lukas/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/b1762e3/clippy_lints/src/write.rs:280:21
    |
280 |                     token::StrRaw(_) => {
    |                     ^^^^^^^^^^^^^^^^ expected 2 fields, found 1

error[E0061]: this function takes 5 parameters but 6 parameters were supplied
   --> /home/lukas/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/b1762e3/clippy_lints/src/write.rs:289:22
    |
289 |     let mut parser = parser::Parser::new(&cx.sess.parse_sess, tts, None, false, false, None);
    |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected 5 parameters

error: aborting due to 32 previous errors

Some errors have detailed explanations: E0023, E0026, E0027, E0061, E0277, E0308, E0412, E0432, E0433...
For more information about an error, try `rustc --explain E0023`.
error: failed to compile `clippy v0.0.212 (https://github.com/rust-lang/rust-clippy/#b1762e3e)`, intermediate artifacts can be found at `/tmp/cargo-install8Y7NrT`

Caused by:
  Could not compile `clippy_lints`.

To learn more, run the command again with --verbose.
[cargo-make] ERROR - Error while executing command, exit code: 101
[cargo-make] WARN - Build Failed.

Workaround
For possible bug 1, I found a workaround by adding this to Makefile.toml:

[tasks.install-clippy]
condition_script = [
    "! cargo clippy -V > /dev/null 2>&1"
]

This tries to run cargo clippy -V (getting the version), discard all output (so not to distract when running) and "inverts" the success of the command.

I can open a PR with this if you'd want, but I'm not sure if this is the best solution.
Checking for $CARGO_HOME/bin/cargo-clippy is not guaranteed to work as $CARGO_HOME does not seem to be required.

@sagiegurari
Copy link
Owner

thanks!!! you are right.
i have an internal way to check if a crate is installed, but didn't trigger it.
i'll modify it to work correctly.

@sagiegurari
Copy link
Owner

@lukasschlueter can you check 0.19.4 branch to see if it resolves the issue?

@lukasschlueter
Copy link
Author

Yes, that seems to work, thanks for the quick fix!

@sagiegurari
Copy link
Owner

great, will publish a new version with the fix soon

@thomaseizinger
Copy link

We are also facing this issue and while investigating, I looked at the current default Makefile.

May I suggest a change to this section here?

[tasks.install-clippy]
description = "Installs the clippy code linter."
category = "Test"
run_task = [
{ name = "install-clippy-github", condition = { channels = ["nightly"] } },
{ name = "install-clippy-rustup" }
]

If I understand correctly, this means clippy will always be installed through GitHub if you are on nightly. We not try to install it through rustup first and if that one doesn't work, install it through GitHub?
The rustup installation is way faster (just takes a couple of seconds).

thomaseizinger added a commit to comit-network/comit-rs that referenced this issue May 31, 2019
@sagiegurari
Copy link
Owner

will check it out. problem with rustup and clippy on nightly is that its not available but can have it try it first

@sagiegurari
Copy link
Owner

@thomaseizinger changing to:

install_crate = { crate_name = "clippy", rustup_component_name = "clippy", binary = "cargo-clippy", test_arg = "--help" }

full task definition:

[tasks.install-clippy-any]
description = "Installs the latest clippy code linter via cargo install via rustup or directly from github."
category = "Test"
install_crate = { crate_name = "clippy", rustup_component_name = "clippy", binary = "cargo-clippy", test_arg = "--help" }
install_crate_args = ["--git", "https://github.com/rust-lang/rust-clippy/"]
args = [ "clippy", "--help" ]

[tasks.install-clippy-rustup]
description = "Installs the clippy code linter via rustup."
category = "Test"
install_crate = { rustup_component_name = "clippy", binary = "cargo-clippy", test_arg = "--help" }

[tasks.install-clippy]
description = "Installs the clippy code linter."
category = "Test"
run_task = [
    { name = "install-clippy-any", condition = { channels = ["nightly"] } },
    { name = "install-clippy-rustup" }
]

should resolve it.
i'm running few tests and if they are ok, i'll push a fix and let you verify as well.
once that is done, i'll publish a new release of cargo-make.

@sagiegurari
Copy link
Owner

@thomaseizinger @lukasschlueter I pushed the updated clippy task to the 0.19.4 branch.
if you two could please verify it works for you as expected or if I need to do more changes there?

@lukasschlueter
Copy link
Author

Looks good to me.

@thomaseizinger
Copy link

I am not going to be able to test it until Monday but if that definition tries it in the following order, that seems fine with me:

  1. Available? Don't install.
  2. On nightly & not available? Install through Rustup.
  3. If that fails, install through GitHub.

@sagiegurari
Copy link
Owner

ya that's the order for nightly.
for non nightly it will not use github and fail

@sagiegurari
Copy link
Owner

0.19.4 has been officially released.
you can check it resolves all issues by installing latest release via cargo install.

@thomaseizinger
Copy link

Tested and works!
Thanks for the quick support :)

@sagiegurari
Copy link
Owner

thanks for confirming

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants