flycheck / flycheck-rust

Better Rust/Cargo support for Flycheck

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Getting couldn't read "src/main.rs": No such file or directory (os error 2)

simao opened this issue · comments

flycheck-rust reports this error whenever I open a rust file.

The file src/main.rs exists and is the file I am currently opening. Do I miss some config here?

I am using only rust-mode and flycheck-rust from melpa, with:

(require 'sm-flycheck)

(add-hook 'rust-mode-hook 'flycheck-mode)
(add-hook 'flycheck-mode-hook #'flycheck-rust-setup)
(add-hook 'rust-mode-hook 'subword-mode)

Thanks

Are you per chance on Windows?

I cannot yet reproduce. Can you give me the output of flycheck-verify-setup (C-c ! v)? And maybe the steps to reproduce from a vanilla emacs -Q?

Curious. flycheck-verify-setup lists rust-cargo as unregistered, so it should not run. Something in your config is defining flycheck-checkers before flycheck loads. That's a first issue.

For the emacs -Q run, it looks like cargo rustc cannot compile your project. What does cargo rustc --verbose returns if you run it manually in your project?

Hmm so cargo rustc --verbose run does not report any error when run manually, but does when running through flycheck?

Can you report what M-x flycheck-compile does in the buffer visiting src/main.rs? If prompted for a checker name, input rust-cargo.

rust-cargo is just the name of the rust checker Flycheck uses to call cargo.

Okay, can you run manually in your project:

  1. cargo rustc --bin s --message-format=json --verbose -- -Z no-trans
  2. cargo rustc --bin s --message-format=json --verbose

And also let me know rustc --version and cargo --version?

Right! So you are using Rust 1.14, and we recently moved to to require 1.15 (see flycheck/flycheck#1201). Sorry for the inconvenience.

If you update to the latest stable Rust, it should work for you. Sorry for the long back-and-forth.

Good to know. Happy hacking :)