rust-lang / rust-mode

Emacs configuration for Rust
Apache License 2.0
1.11k stars 179 forks source link

no library targets found in package `current_project` #483

Open Bkeinn opened 1 year ago

Bkeinn commented 1 year ago

I am very new to emacs and are trying to set it up for rust development. When I am in a *.rs file and M-x rust-mode this error pops up:

Suspicious state from syntax checker rust-cargo: Flycheck checker rust-cargo returned 101, but its output contained no errors: error: no library targets found in package `learn_async`

Try installing a more recent version of rust-cargo, and please open a bug report if the issue persists in the latest release.  Thanks!

I updated cargo rust with: rustup update and updated all my packages with paradox. Emacs: Doom OS: Fedora config.el:

[...]
(after! rustic
  (setq lsp-rust-server 'rust-analyzer))

(use-package lsp-mode
  :ensure
  :commands lsp
  :custom
  ;; what to use when checking on-save. "check" is default, I prefer clippy
  (lsp-rust-analyzer-cargo-watch-command "clippy")
  (lsp-eldoc-render-all t)
  (lsp-idle-delay 0.6)
  ;; enable / disable the hints as you prefer:
  (lsp-rust-analyzer-server-display-inlay-hints t)
  (lsp-rust-analyzer-display-lifetime-elision-hints-enable "skip_trivial")
  (lsp-rust-analyzer-display-chaining-hints t)
  (lsp-rust-analyzer-display-lifetime-elision-hints-use-parameter-names nil)
  (lsp-rust-analyzer-display-closure-return-type-hints t)
  (lsp-rust-analyzer-display-parameter-hints nil)
  (lsp-rust-analyzer-display-reborrow-hints nil)
  :config
  (add-hook 'lsp-mode-hook 'lsp-ui-mode))

(use-package lsp-ui
  :ensure
  :commands lsp-ui-mode
  :custom
  (lsp-ui-peek-always-show t)
  (lsp-ui-sideline-show-hover t)
  (lsp-ui-doc-enable nil))

(rustic and lsp mode both don't work either but I am starting with rust-mode, because it told me to open a new issue)

psibi commented 1 year ago

What is the rust version you are using (rustc --version) ?

Also, what happens if you do cargo build from your project in a terminal ?

Bkeinn commented 1 year ago

rustc 1.66.0 (69f9c33d7 2022-12-12) cargo build:

Compiling learn_async v0.1.0 (/home/heimchen/Documents/Programing/Rust/learn_async)
    Finished dev [unoptimized + debuginfo] target(s) in 1.08s

LSP seams to work in vim

psibi commented 1 year ago

Ah, I see. Looking into this further - this could be a flycheck issue:

Can you see if installing and configuring flycheck-rust would resolve the issue: https://github.com/flycheck/flycheck-rust ?

Bkeinn commented 1 year ago

Flycheck-rust was already installed. I reinstalled and nothing changed.

psibi commented 1 year ago

Did you also have this in your init.el:

(with-eval-after-load 'rust-mode
  (add-hook 'flycheck-mode-hook #'flycheck-rust-setup))

If that doesn't work, then I would suggest you to try re-installing all the packages and check again.

If even that doesn't work, probabaly can make your project public so that I can test your project directly (A new sample project works fine for me in both rust-mode as well as rustic) ?

brotzeit commented 1 year ago

If you want to use doom-emacs you should stick with the doom approach. rust-mode(only indirectly through rustic) and paradox are not used by doom. I would suggest that you try to get a minimal doom-emacs config working and then start adding additional config options. There are lots of tutorials that help you with it.

Another possibility would be to try emacs without doom-emacs. You can take a look at https://github.com/rksm/emacs-rust-config and try if it works for you. Configs like these(and of course doom) are used by many other people so the chance is good that it should be working for you, if you stick to the defaults.