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 clippy crashes in root of workspace #2105

Closed
sanmai-NL opened this issue Oct 3, 2017 · 9 comments
Closed

Cargo clippy crashes in root of workspace #2105

sanmai-NL opened this issue Oct 3, 2017 · 9 comments
Labels
C-bug Category: Clippy is not doing the correct thing

Comments

@sanmai-NL
Copy link
Contributor

env RUST_BACKTRACE=1 cargo +nightly clippy
thread 'main' panicked at 'could not find parent of path /', /home/sanmai/.cargo/bin/registry/src/git.luolix.top-1ecc6299db9ec823/clippy-0.0.165/src/main.rs:250:51
stack backtrace:
   0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
             at /checkout/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::_print
             at /checkout/src/libstd/sys_common/backtrace.rs:71
   2: std::panicking::default_hook::{{closure}}
             at /checkout/src/libstd/sys_common/backtrace.rs:60
             at /checkout/src/libstd/panicking.rs:381
   3: std::panicking::default_hook
             at /checkout/src/libstd/panicking.rs:397
   4: std::panicking::rust_panic_with_hook
             at /checkout/src/libstd/panicking.rs:577
   5: std::panicking::begin_panic
             at /checkout/src/libstd/panicking.rs:538
   6: std::panicking::begin_panic_fmt
             at /checkout/src/libstd/panicking.rs:522
   7: cargo_clippy::main
   8: __rust_maybe_catch_panic
             at /checkout/src/libpanic_unwind/lib.rs:99
   9: std::rt::lang_start
             at /checkout/src/libstd/panicking.rs:459
             at /checkout/src/libstd/panic.rs:361
             at /checkout/src/libstd/rt.rs:59
  10: __libc_start_main
  11: _start

Meta

cargo +nightly clippy -V
0.0.165

See also #1515

@oli-obk
Copy link
Contributor

oli-obk commented Oct 3, 2017

I cannot reproduce. On which crate are you running it and from which directory?

@sanmai-NL
Copy link
Contributor Author

sanmai-NL commented Oct 3, 2017

The output of pwd is /home/sanmai/devel/gitlab.com/Structure-Systems/SE/Rust. I am running it from a workspace, and it contains unpublished crates. To clarify, the command in this case was not expected to succeed.

env RUST_BACKTRACE=1 cargo +nightly clippy --all

does not fail in the same way.

@oli-obk
Copy link
Contributor

oli-obk commented Oct 3, 2017

So I'm assuming the Cargo.toml is in that folder?

How are the other crates positioned relative to it? We have a workspace test for

  • workspace_root
    • subcrate

And that works from both directories + any subdirectory of either.

@radix
Copy link

radix commented Oct 12, 2017

I'm getting this too, in github.com/radix/pandt. I'm using windows 10 and running it from the root of the repository.

C:\Users\radix\Projects\pandt [master ↑]> cargo clippy
thread 'main' panicked at 'could not find parent of path \\?\C:\', C:\Users\radix\.cargo\registry\src\git.luolix.top-1ecc6299db9ec823\clippy-0.0.165\src/main.rs:250:51

@oli-obk
Copy link
Contributor

oli-obk commented Oct 17, 2017

I wrote a fun comment:

                        // We'll never reach the filesystem root, because to get to this point in the
                        // code
                        // the call to `cargo_metadata::metadata` must have succeeded. So it's okay to
                        // unwrap the current path's parent.

So... I was wrong. I don't know why yet, though.

@sanmai-NL
Copy link
Contributor Author

sanmai-NL commented Oct 17, 2017

@oli-obk: I have .cargo directories at multiple layers, one in the workspace root dir and one in each workspace member dir (and one globally in my home dir). Does this help track down the problem?

@chordowl
Copy link

chordowl commented Nov 22, 2017

Just ran into this crash myself. My (complete!) workspace Cargo.toml looked something like this:

[workspace]

members = [
    "foo",
    "bar",
    "baz",
]

Since @oli-obk said that there was a workspace test, I looked at that and found that the test workspace had a [package] section while mine did not. After prepending that to my workspace Cargo.toml, it doesn't crash anymore, instead saying error: Could not obtain cargo metadata. (presumably because I still have neither [lib] nor [[bin]] sections in my workspace Cargo.toml?? This is pure speculation).

While this makes the crash go away, it doesn't really make sense for me to add a [package] section to my workspace's Cargo.toml since it really isn't a package -- it would be nice if I could run cargo +nightly clippy in my workspace root to just check all its members with clippy. Even without the package prefix, cargo +nightly clippy --all works, so I'm a happy camper either way.

@samueltardieu
Copy link
Contributor

You can also reproduce it with:

% git clone https://github.com/hashmismatch/packed_struct.rs
% cd packed_struct.rs
% cargo clippy
thread 'main' panicked at 'could not find parent of path /', src/main.rs:124:48
note: Run with `RUST_BACKTRACE=1` for a backtrace.

@phansch
Copy link
Member

phansch commented Mar 30, 2018

Looks like this is fixed with 0.0.191 (possibly in #2585). I'm going ahead and close this because the offending code has been removed and is now handled by cargo check.

@sanmai-NL Feel free to re-open if you still get this crash with 0.0.191.

@phansch phansch closed this as completed Mar 30, 2018
@phansch phansch added the C-bug Category: Clippy is not doing the correct thing label Apr 4, 2018
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
Projects
None yet
Development

No branches or pull requests

6 participants