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 fails to run with "error[E0463]: can't find crate for std" #3523

Closed
matthiaskrgr opened this issue Dec 10, 2018 · 13 comments
Closed

clippy fails to run with "error[E0463]: can't find crate for std" #3523

matthiaskrgr opened this issue Dec 10, 2018 · 13 comments
Labels
C-question Category: Questions I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@matthiaskrgr
Copy link
Member

On my project I run clippy on travis ci
https://github.com/matthiaskrgr/cargo-cache/blob/master/.travis.yml#L87
A few days ago clippy started failing to run with

error[E0463]: can't find crate for `std`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0463`.
error: Could not compile `serde`.
warning: build failed, waiting for other jobs to finish...

without me changing anything on the config.

On december 8 it was still working fine
https://travis-ci.org/matthiaskrgr/cargo-cache/jobs/465214963
On december 9 it started failing to run when being installed from the git repo
https://travis-ci.org/matthiaskrgr/cargo-cache/jobs/465490462

Any ideas what could be the cause of this?

@phansch phansch added C-question Category: Questions I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️ labels Dec 10, 2018
@sinkuu
Copy link
Contributor

sinkuu commented Dec 10, 2018

I assume this is caused by #3257. rustc_driver's default sysroot is based on env::current_exe() (usually ~/.rustup/toolchains/*/bin/clippy-driver), so it does not work for ~/.cargo/bin/clippy-driver which your travis script installs when the rustup component is unavailable.

@matthiaskrgr
Copy link
Member Author

Ugh so tl;dr: clippy no longer works if manually installed from the git repo? :(

@aldanor
Copy link

aldanor commented Dec 11, 2018

Just hit this as well, this is extremely confusing.

matthiaskrgr added a commit to matthiaskrgr/rust-clippy that referenced this issue Dec 11, 2018
This reverts commit 041c49c, reversing
changes made to 1df5766.

This broke clippy working when installed from the git repo via cargo install.

Fixes rust-lang#3523
Reopens rust-lang#2874
@matthiaskrgr
Copy link
Member Author

I can't even call it directly from the target dir (target/debug/cargo-clippy)

./target/debug/cargo-clippy 
    Checking matches v0.1.8
error[E0463]: can't find crate for `std`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error: Could not compile `matches`.

It's hard to believe we had no regression tests to catch this earlier.

@phansch
Copy link
Member

phansch commented Dec 14, 2018

It looks like the integration tests do: https://travis-ci.org/rust-lang/rust-clippy/jobs/467976025#L863 but they fail to fail :/

@matthiaskrgr
Copy link
Member Author

Oh wow ...

@ghost
Copy link

ghost commented Dec 17, 2018

It looks like the change isn't going to be reverted. Let's think about alternatives.

How about a feature flag to restore the old behaviour? If you're building it yourself you can just enable the feature.

@oli-obk
Copy link
Contributor

oli-obk commented Dec 17, 2018

Does it work if you pass --sysroot manually?

If so, you can use RUSTFLAGS=--sysroot=foo cargo clippy on your manually installed clippy.

Autodetection of the sysroot has always been a hack (and has gotten more and more hacks to support every kind of setup out there).

Maybe we should give cargo some sort of support for installing crates into the sysroot?

@ghost
Copy link

ghost commented Dec 19, 2018

That works for me.

@matthiaskrgr
Copy link
Member Author

I'm going to revert this tomorrow on the following grounds:

  • it has been two weeks since the regression was introduced without a message from the original author
  • the regression breaks several use cases and the --sysroot hack requires manual intervention and does not fix the issue inside clippy
  • the PR broke 13 of our 15 ci jobs which means we may introduce more regressions without noticing without a fix
  • since the PR broke ci, it should have never been merged but we failed to notice due to the way it broke the ci.
  • no actual drop-in fix has been supplied yet

@oli-obk
Copy link
Contributor

oli-obk commented Dec 19, 2018

the regression breaks several use cases and the --sysroot hack requires manual intervention and does not fix the issue inside clippy
no actual drop-in fix has been supplied yet

the --sysroot hack is much less of a hack than what we had before. If anything we should make cargo clippy obtain the sysroot and pass it on to the invocation of clippy-driver instead of having clippy-driver do arbitrary things

since the PR broke ci, it should have never been merged but we failed to notice due to the way it broke the ci.

I thought CI was fixed, sorry. I'm prioritizing this

@mati865
Copy link
Contributor

mati865 commented Dec 19, 2018

@oli-obk CI silently failed because of it's a bit hacky as well: #3552

@matthiaskrgr
Copy link
Member Author

No, ci is still not fixed. There's a PR that tweaks ci to catch this in the future though.

bors added a commit that referenced this issue Dec 19, 2018
Revert "Merge pull request #3257 from o01eg/remove-sysroot"

This reverts commit 041c49c, reversing
changes made to 1df5766.

The PR broke running a cargo-install'd clippy.
The installed clippy would not be able to find a crate for std.

Fixes #3523
Reopens #2874
bors added a commit that referenced this issue Dec 19, 2018
…i-obk

Make integration tests fail on 'E0463'

cc #3523
bors added a commit that referenced this issue Dec 19, 2018
…i-obk

Make integration tests fail on 'E0463'

cc #3523
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-question Category: Questions I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

6 participants