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

cargo check failed but cargo run always work #86551

Open
pickfire opened this issue Jun 22, 2021 · 9 comments
Open

cargo check failed but cargo run always work #86551

pickfire opened this issue Jun 22, 2021 · 9 comments
Labels
C-bug Category: This is a bug. S-needs-repro Status: This issue has no reproduction and needs a reproduction to make progress.

Comments

@pickfire
Copy link
Contributor

I can't reproduce this but it happens every day, 3 days in a row for me. When developing helix, after I checked out other commits using git rebase or git revert, quite a few time I do cargo check, cargo check will always fail even though cargo run works.

Note that this happens in the past for me, but that was after switching features and not as often as getting it daily, but last time it was very rare for me, maybe once a few months like after upgrades or after version updates. But this happen daily just because I checked out different commits.

So the solution is to do cargo clean every time this happen, at least daily for me when working on helix project, note that I don't code so frequently but it happens very frequently whenever I switch commits. Maybe due to workspace? Or maybe due to git conflicts like <<<? https://github.com/helix-editor/helix

I expected to see this happen: if cargo run works, cargo check should work

Instead, this happened: cargo check failed always, then I tried cargo run, it still failed, even after I fixed the errors, cargo check failed but cargo run can work

Meta

rustc --version --verbose:

rustc 1.53.0 (53cb7b09b 2021-06-17)
binary: rustc
commit-hash: 53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b
commit-date: 2021-06-17
host: x86_64-unknown-linux-gnu
release: 1.53.0
LLVM version: 12.0.1

I haven't tried this on nightly. Not quite sure how to get a minimum reproducible bug but it happen quite often. If anything I can do please suggest any methods to help out.

@pickfire pickfire added the C-bug Category: This is a bug. label Jun 22, 2021
@jonas-schievink jonas-schievink added the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Jun 22, 2021
@Aaron1011
Copy link
Member

@pickfire Can you post the output from when cargo check fails

@pickfire
Copy link
Contributor Author

pickfire commented Jun 22, 2021

The output for each occurence is different. But I only have the third day and one from last week, the two day before the third day the output is gone by now.

A week before

error[E0432]: unresolved import `helix_core::register::Registers`
  --> helix-view/src/editor.rs:12:9
   |
12 | pub use helix_core::register::Registers;
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `Registers` in `register`

error: aborting due to previous error

Yesterday (third day)

    Checking helix-lsp v0.2.0 (/home/ivan/src/pickfire/rs/helix/helix-lsp)
    Checking helix-tui v0.2.0 (/home/ivan/src/pickfire/rs/helix/helix-tui)
error[E0432]: unresolved import `helix_core::chars::char_is_line_ending`
 --> helix-lsp/src/client.rs:6:18
  |
6 | use helix_core::{chars::char_is_line_ending, find_root, ChangeSet, Rope};
  |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^ no `char_is_line_ending` in `chars`

error[E0432]: unresolved import `helix_core::line_ending`
  --> helix-tui/src/text.rs:50:17
   |
50 | use helix_core::line_ending::str_is_line_ending;
   |                 ^^^^^^^^^^^ could not find `line_ending` in `helix_core`

error[E0432]: unresolved import `helix_core::line_ending`
 --> helix-tui/src/widgets/reflow.rs:2:17
  |
2 | use helix_core::line_ending::str_is_line_ending;
  |                 ^^^^^^^^^^^ could not find `line_ending` in `helix_core`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0432`.
error: could not compile `helix-lsp`

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

For more information about this error, try `rustc --explain E0432`.
error: build failed

@pickfire
Copy link
Contributor Author

pickfire commented Jun 24, 2021

I faced another issue today. cargo check error after I git rebase master. Even after rebase is done it still have issue. I use rust-analyzer, not sure if it's related.

    Checking helix-term v0.2.0 (/home/ivan/src/pickfire/rs/helix/helix-term)
error[E0432]: unresolved import `helix_view::input`
  --> helix-term/src/commands.rs:18:5
   |
18 |     input::{KeyCode, KeyEvent},
   |     ^^^^^ could not find `input` in `helix_view`

error[E0432]: unresolved import `helix_view::input`
 --> helix-term/src/keymap.rs:7:17
  |
7 | use helix_view::input::{KeyCode, KeyEvent, KeyModifiers};
  |                 ^^^^^ could not find `input` in `helix_view`

error[E0432]: unresolved import `helix_view::input`
  --> helix-term/src/ui/editor.rs:15:17
   |
15 | use helix_view::input::{KeyCode, KeyEvent, KeyModifiers};
   |                 ^^^^^ could not find `input` in `helix_view`

error[E0282]: type annotations needed
   --> helix-term/src/commands.rs:641:26
    |
641 |     cx.on_next_key(move |cx, event| {
    |                          ^^ consider giving this closure parameter a type
    |
    = note: type must be known at this point

error[E0282]: type annotations needed
   --> helix-term/src/keymap.rs:139:35
    |
139 | #[derive(Debug, Clone, PartialEq, Deserialize)]
    |                                   ^^^^^^^^^^^ consider giving this closure parameter a type
    |
    = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0599]: no method named `remove` found for struct `Keymaps` in the current scope
   --> helix-term/src/keymap.rs:345:27
    |
141 | pub struct Keymaps(pub HashMap<Mode, HashMap<KeyEvent, Command>>);
    | ------------------------------------------------------------------ method `remove` not found for this
...
345 |         keys.extend(delta.remove(mode).unwrap_or_default());
    |                           ^^^^^^ method not found in `Keymaps`

error[E0608]: cannot index into a value of type `Keymaps`
   --> helix-term/src/ui/editor.rs:596:32
    |
596 |         if let Some(command) = self.keymaps[&Mode::Insert].get(&event) {
    |                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0608]: cannot index into a value of type `Keymaps`
   --> helix-term/src/ui/editor.rs:634:40
    |
634 |                 if let Some(command) = self.keymaps[&mode].get(&event) {
    |                                        ^^^^^^^^^^^^^^^^^^^

error[E0608]: cannot index into a value of type `Keymaps`
   --> helix-term/src/ui/editor.rs:750:46
    |
750 |                         self.last_insert.0 = self.keymaps[&mode][&key];
    |                                              ^^^^^^^^^^^^^^^^^^^

error: aborting due to 9 previous errors

Some errors have detailed explanations: E0282, E0432, E0599, E0608.
For more information about an error, try `rustc --explain E0282`.
error: could not compile `helix-term`

To learn more, run the command again with --verbose.

@pickfire
Copy link
Contributor Author

Another one today.

    Checking helix-term v0.2.0 (/home/ivan/src/pickfire/rs/helix/helix-term)
error[E0432]: unresolved imports `helix_core::graphemes::ensure_grapheme_boundary`, `helix_core::graphemes::ensure_grapheme_boundary_byte`
  --> helix-term/src/ui/editor.rs:11:17
   |
11 |     graphemes::{ensure_grapheme_boundary, ensure_grapheme_boundary_byte},
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `ensure_grapheme_boundary_byte` in `graphemes`
   |                 |
   |                 no `ensure_grapheme_boundary` in `graphemes`
   |                 help: a similar name exists in the module: `prev_grapheme_boundary`

error[E0603]: struct `Rect` is private
 --> helix-term/src/ui/info.rs:3:18
  |
3 | use tui::layout::Rect;
  |                  ^^^^ private struct
  |
note: the struct `Rect` is defined here
 --> /home/ivan/src/pickfire/rs/helix/helix-tui/src/layout.rs:8:36
  |
8 | use helix_view::graphics::{Margin, Rect};
  |                                    ^^^^

error[E0609]: no field `autoinfo` on type `&mut helix_view::Editor`
    --> helix-term/src/commands.rs:3288:15
     |
3288 |     cx.editor.autoinfo = Some(("hello".to_owned(), String::new()));
     |               ^^^^^^^^ unknown field
     |
     = note: available fields are: `tree`, `documents`, `count`, `selected_register`, `registers` ... and 6 others

error[E0609]: no field `autoinfo` on type `&mut helix_view::Editor`
   --> helix-term/src/ui/editor.rs:782:68
    |
782 |         if let Some((title, body)) = std::mem::take(&mut cx.editor.autoinfo) {
    |                                                                    ^^^^^^^^ unknown field
    |
    = note: available fields are: `tree`, `documents`, `count`, `selected_register`, `registers` ... and 6 others

error: aborting due to 4 previous errors

Some errors have detailed explanations: E0432, E0603, E0609.
For more information about an error, try `rustc --explain E0432`.
error: could not compile `helix-term`

To learn more, run the command again with --verbose.

@pickfire
Copy link
Contributor Author

pickfire commented Jun 30, 2021

Seemed like cargo doc is affected as well, cargo check works but both cargo run and cargo doc does not work. Both have similar errors but not exactly the same. Same thing, it happened after git rebase. I tried removing target/doc/ and did cargo doc again but it have the same issue.

> cargo doc
 Documenting helix-view v0.3.0 (/home/ivan/src/pickfire/rs/helix/helix-view)
    Checking helix-term v0.3.0 (/home/ivan/src/pickfire/rs/helix/helix-term)
error[E0432]: unresolved import `helix_lsp::util::LspFormatting`
  --> helix-view/src/document.rs:19:5
   |
19 | use helix_lsp::util::LspFormatting;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `LspFormatting` in `util`

error: Compilation failed, aborting rustdoc

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0432`.
error: could not document `helix-view`

Caused by:
  process didn't exit successfully: `rustdoc --edition=2018 --crate-type lib --crate-name helix_view helix-view/src/lib.rs -o /home/ivan/src/pickfire/rs/helix/target/doc --cfg 'feature="crossterm"' --cfg 'feature="default"' --cfg 'feature="term"' --error-format=json --json=diagnostic-rendered-ansi -L dependency=/home/ivan/src/pickfire/rs/helix/target/debug/deps --extern anyhow=/home/ivan/src/pickfire/rs/helix/target/debug/deps/libanyhow-a0acf4362debc8da.rmeta --extern bitflags=/home/ivan/src/pickfire/rs/helix/target/debug/deps/libbitflags-2ac7a49e86426b65.rmeta --extern chardetng=/home/ivan/src/pickfire/rs/helix/target/debug/deps/libchardetng-532041c0d3bdc748.rmeta --extern crossterm=/home/ivan/src/pickfire/rs/helix/target/debug/deps/libcrossterm-4fe54d60ca035608.rmeta --extern encoding_rs=/home/ivan/src/pickfire/rs/helix/target/debug/deps/libencoding_rs-36108c5368738efb.rmeta --extern futures_util=/home/ivan/src/pickfire/rs/helix/target/debug/deps/libfutures_util-fb1ecad0003a1568.rmeta --extern helix_core=/home/ivan/src/pickfire/rs/helix/target/debug/deps/libhelix_core-1889099c790a2b7e.rmeta --extern helix_lsp=/home/ivan/src/pickfire/rs/helix/target/debug/deps/libhelix_lsp-c5e990b435ffbb39.rmeta --extern log=/home/ivan/src/pickfire/rs/helix/target/debug/deps/liblog-084cb22155b94a5e.rmeta --extern once_cell=/home/ivan/src/pickfire/rs/helix/target/debug/deps/libonce_cell-e59f925b50d5e08f.rmeta --extern serde=/home/ivan/src/pickfire/rs/helix/target/debug/deps/libserde-2ca165c59121e480.rmeta --extern slotmap=/home/ivan/src/pickfire/rs/helix/target/debug/deps/libslotmap-4b2710a370e66460.rmeta --extern tokio=/home/ivan/src/pickfire/rs/helix/target/debug/deps/libtokio-112fa73ba8304679.rmeta --extern toml=/home/ivan/src/pickfire/rs/helix/target/debug/deps/libtoml-440c89cfa73486c9.rmeta --extern url=/home/ivan/src/pickfire/rs/helix/target/debug/deps/liburl-22fe0e50f79e623a.rmeta --extern which=/home/ivan/src/pickfire/rs/helix/target/debug/deps/libwhich-fbcf7f9d3d2756ae.rmeta --crate-version 0.3.0` (exit status: 1)
warning: build failed, waiting for other jobs to finish...
error[E0425]: cannot find function `move_next_long_word_start` in module `movement`
   --> helix-term/src/commands.rs:449:38
    |
449 |         .transform(|range| movement::move_next_long_word_start(text, range, count));
    |                                      ^^^^^^^^^^^^^^^^^^^^^^^^^
    |
help: a function with a similar name exists
    |
449 |         .transform(|range| movement::move_next_word_start(text, range, count));
    |                                      ^^^^^^^^^^^^^^^^^^^^
help: consider importing this function
    |
1   | use crate::commands::insert::move_next_long_word_start;
    |

error[E0425]: cannot find function `move_prev_long_word_start` in module `movement`
   --> helix-term/src/commands.rs:461:38
    |
461 |         .transform(|range| movement::move_prev_long_word_start(text, range, count));
    |                                      ^^^^^^^^^^^^^^^^^^^^^^^^^
    |
help: a function with a similar name exists
    |
461 |         .transform(|range| movement::move_prev_word_start(text, range, count));
    |                                      ^^^^^^^^^^^^^^^^^^^^
help: consider importing this function
    |
1   | use crate::commands::insert::move_prev_long_word_start;
    |

error[E0425]: cannot find function `move_next_long_word_end` in module `movement`
   --> helix-term/src/commands.rs:473:38
    |
473 |         .transform(|range| movement::move_next_long_word_end(text, range, count));
    |                                      ^^^^^^^^^^^^^^^^^^^^^^^
    |
help: a function with a similar name exists
    |
473 |         .transform(|range| movement::move_next_word_end(text, range, count));
    |                                      ^^^^^^^^^^^^^^^^^^
help: consider importing this function
    |
1   | use crate::commands::insert::move_next_long_word_end;
    |

error[E0412]: cannot find type `LspFormatting` in module `helix_lsp::util`
    --> helix-term/src/commands.rs:1934:51
     |
1934 |     format: impl Future<Output = helix_lsp::util::LspFormatting> + Send + 'static,
     |                                                   ^^^^^^^^^^^^^ not found in `helix_lsp::util`

error[E0599]: no method named `document_mut` found for mutable reference `&mut helix_view::Editor` in the current scope
    --> helix-term/src/commands.rs:1939:35
     |
1939 |         if let Some(doc) = editor.document_mut(doc_id) {
     |                                   ^^^^^^^^^^^^ help: there is an associated function with a similar name: `documents_mut`

error[E0599]: no method named `auto_format` found for mutable reference `&mut helix_view::Document` in the current scope
    --> helix-term/src/commands.rs:1165:23
     |
1165 |         let fmt = doc.auto_format().map(|fmt| {
     |                       ^^^^^^^^^^^ method not found in `&mut helix_view::Document`

error[E0599]: no method named `format_and_save` found for mutable reference `&mut helix_view::Document` in the current scope
    --> helix-term/src/commands.rs:1176:29
     |
1176 |         Ok(tokio::spawn(doc.format_and_save(fmt)))
     |                             ^^^^^^^^^^^^^^^ method not found in `&mut helix_view::Document`

error[E0061]: this function takes 1 argument but 0 arguments were supplied
    --> helix-term/src/commands.rs:1196:35
     |
1196 |         if let Some(format) = doc.format() {
     |                                   ^^^^^^- supplied 0 arguments
     |                                   |
     |                                   expected 1 argument
     |
note: associated function defined here

error[E0308]: mismatched types
    --> helix-term/src/commands.rs:1196:16
     |
1196 |         if let Some(format) = doc.format() {
     |                ^^^^^^^^^^^^   ------------ this expression has type `()`
     |                |
     |                expected `()`, found enum `std::option::Option`
     |
     = note: expected unit type `()`
                     found enum `std::option::Option<_>`

error: aborting due to 9 previous errors

Some errors have detailed explanations: E0061, E0308, E0412, E0425, E0599.
For more information about an error, try `rustc --explain E0061`.
error: build failed
> cargo check
    Checking helix-term v0.3.0 (/home/ivan/src/pickfire/rs/helix/helix-term)
error[E0425]: cannot find function `move_next_long_word_start` in module `movement`
   --> helix-term/src/commands.rs:449:38
    |
449 |         .transform(|range| movement::move_next_long_word_start(text, range, count));
    |                                      ^^^^^^^^^^^^^^^^^^^^^^^^^
    |
help: a function with a similar name exists
    |
449 |         .transform(|range| movement::move_next_word_start(text, range, count));
    |                                      ^^^^^^^^^^^^^^^^^^^^
help: consider importing this function
    |
1   | use crate::commands::insert::move_next_long_word_start;
    |

error[E0425]: cannot find function `move_prev_long_word_start` in module `movement`
   --> helix-term/src/commands.rs:461:38
    |
461 |         .transform(|range| movement::move_prev_long_word_start(text, range, count));
    |                                      ^^^^^^^^^^^^^^^^^^^^^^^^^
    |
help: a function with a similar name exists
    |
461 |         .transform(|range| movement::move_prev_word_start(text, range, count));
    |                                      ^^^^^^^^^^^^^^^^^^^^
help: consider importing this function
    |
1   | use crate::commands::insert::move_prev_long_word_start;
    |

error[E0425]: cannot find function `move_next_long_word_end` in module `movement`
   --> helix-term/src/commands.rs:473:38
    |
473 |         .transform(|range| movement::move_next_long_word_end(text, range, count));
    |                                      ^^^^^^^^^^^^^^^^^^^^^^^
    |
help: a function with a similar name exists
    |
473 |         .transform(|range| movement::move_next_word_end(text, range, count));
    |                                      ^^^^^^^^^^^^^^^^^^
help: consider importing this function
    |
1   | use crate::commands::insert::move_next_long_word_end;
    |

error[E0412]: cannot find type `LspFormatting` in module `helix_lsp::util`
    --> helix-term/src/commands.rs:1934:51
     |
1934 |     format: impl Future<Output = helix_lsp::util::LspFormatting> + Send + 'static,
     |                                                   ^^^^^^^^^^^^^ not found in `helix_lsp::util`

error[E0599]: no method named `document_mut` found for mutable reference `&mut helix_view::Editor` in the current scope
    --> helix-term/src/commands.rs:1939:35
     |
1939 |         if let Some(doc) = editor.document_mut(doc_id) {
     |                                   ^^^^^^^^^^^^ help: there is an associated function with a similar name: `documents_mut`

error[E0599]: no method named `auto_format` found for mutable reference `&mut helix_view::Document` in the current scope
    --> helix-term/src/commands.rs:1165:23
     |
1165 |         let fmt = doc.auto_format().map(|fmt| {
     |                       ^^^^^^^^^^^ method not found in `&mut helix_view::Document`

error[E0599]: no method named `format_and_save` found for mutable reference `&mut helix_view::Document` in the current scope
    --> helix-term/src/commands.rs:1176:29
     |
1176 |         Ok(tokio::spawn(doc.format_and_save(fmt)))
     |                             ^^^^^^^^^^^^^^^ method not found in `&mut helix_view::Document`

error[E0061]: this function takes 1 argument but 0 arguments were supplied
    --> helix-term/src/commands.rs:1196:35
     |
1196 |         if let Some(format) = doc.format() {
     |                                   ^^^^^^- supplied 0 arguments
     |                                   |
     |                                   expected 1 argument
     |
note: associated function defined here

error[E0308]: mismatched types
    --> helix-term/src/commands.rs:1196:16
     |
1196 |         if let Some(format) = doc.format() {
     |                ^^^^^^^^^^^^   ------------ this expression has type `()`
     |                |
     |                expected `()`, found enum `std::option::Option`
     |
     = note: expected unit type `()`
                     found enum `std::option::Option<_>`

error: aborting due to 9 previous errors

Some errors have detailed explanations: E0061, E0308, E0412, E0425, E0599.
For more information about an error, try `rustc --explain E0061`.
error: could not compile `helix-term`

To learn more, run the command again with --verbose.

@pickfire
Copy link
Contributor Author

pickfire commented Jul 3, 2021

I had this issue again. From what I see, in helix. It happens always whenever I did a rebase or cherry-pick. I am not sure how to reproduce a minimum reproducible example.

@pickfire
Copy link
Contributor Author

pickfire commented Jul 29, 2021

Lately I got these issues instead. Same issue but now the warnings are similar. If I removed the rmeta files myself, then it still have the same issue but for other crates.

error[E0514]: found crate `lazy_static` compiled by an incompatible version of rustc
  --> /home/ivan/.cargo/registry/src/github.com-1ecc6299db9ec823/crossbeam-utils-0.8.5/src/sync/sharded_lock.rs:13:5
   |
13 | use lazy_static::lazy_static;
   |     ^^^^^^^^^^^
   |
   = help: please recompile that crate using this compiler (rustc 1.55.0-nightly (32c9b7b09 2021-07-21))
   = note: the following crate versions were found:
           crate `lazy_static` compiled by rustc 1.55.0-nightly (6d820866a 2021-06-29): /home/ivan/src/pickfire/rs/helix/target/debug/deps/liblazy_static-2ed79acc105067d7.rmeta

error: could not compile `crossbeam-utils` due to previous error
warning: build failed, waiting for other jobs to finish...
error[E0514]: found crate `smallvec` compiled by an incompatible version of rustc
  --> /home/ivan/.cargo/registry/src/github.com-1ecc6299db9ec823/parking_lot_core-0.8.3/src/parking_lot.rs:16:5
   |
16 | use smallvec::SmallVec;
   |     ^^^^^^^^
   |
   = help: please recompile that crate using this compiler (rustc 1.55.0-nightly (32c9b7b09 2021-07-21))
   = note: the following crate versions were found:
           crate `smallvec` compiled by rustc 1.55.0-nightly (6d820866a 2021-06-29): /home/ivan/src/pickfire/rs/helix/target/debug/deps/libsmallvec-2a80c8fb8d7317f6.rmeta

error[E0514]: found crate `pin_utils` compiled by an incompatible version of rustc
  --> /home/ivan/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.16/src/lib.rs:34:9
   |
34 | pub use pin_utils::pin_mut;
   |         ^^^^^^^^^
   |
   = help: please recompile that crate using this compiler (rustc 1.55.0-nightly (32c9b7b09 2021-07-21))
   = note: the following crate versions were found:
           crate `pin_utils` compiled by rustc 1.55.0-nightly (6d820866a 2021-06-29): /home/ivan/src/pickfire/rs/helix/target/debug/deps/libpin_utils-849d07e2fcf4214a.rmeta

@kamulos
Copy link

kamulos commented Dec 14, 2021

I was regularly experiencing a similar issue with Rust 1.57.0, where sometimes after switching git branch some of the types and symbols cargo check evaluates were just outdated.

One piece of the puzzle might be, that I recently started switching back and forth from developing on my main system and a Docker container where the folder is mounted without always cleaning the target directory.

This might be incidental, but the times, where this started occurring and where I started sometimes switching to the docker container are pretty close.

@nonlinearthink
Copy link

nonlinearthink commented Oct 27, 2023

I seem to have the same problem, it's cause by use a crate before extern crate in another file:

use your_crate::fn;
extern crate your_crate;

@jieyouxu jieyouxu added S-needs-repro Status: This issue has no reproduction and needs a reproduction to make progress. and removed E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example labels Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. S-needs-repro Status: This issue has no reproduction and needs a reproduction to make progress.
Projects
None yet
Development

No branches or pull requests

6 participants