doomemacs / doomemacs/core

In a rust project, edit Cargo.toml not auto reload rust-analyzer

Open
#5,630 0 comments 3 reactions 0 assignees View on GitHub
is:bug needs-triage
Dominant language
Emacs Lisp
Stars
22.7k
Forks
3.1k
Avg merge
10h 46m
Merged PRs (30d)
4

Description

### What did you expect to happen?

When I modify Cargo.toml, such as add a new trait, it can auto reload rust-analyzer to auto complete the new trait.

### What actually happened?

Nothing happend.

### Describe your attempts to resolve the issue

I tried modify `Cargo.toml` in other editor, such as `vim` and `vanilla Emacs by doom:sandbox` ,it work as expected.
Then I tried `vanilla Doom` , it not work.

### Steps to reproduce

1. Open a termal, `cargo new rust-demo`;
2. Open Emacs, and open `src/main.rs`, then it will open a `rust-analyzer` server;
3. Open `Cargo.toml` file, and add some thing to `[dependencies]`, such as:
```
[package]
name = "rust-demo"
version = "0.1.0"
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
rand = "0.8.4"
```
4. There nothing happend.
5. If you open that file in other editor, such vim, change the `0.8.4` to `0.9.4`, it worked as expect, will throw an error like this:
```
LSP :: rust-analyzer failed to load workspace: Failed to read Cargo metadata from Cargo.toml file /Users/jadestrong/Documents/JadeStrong/rust-in-action/rust-demo/Cargo.toml, cargo 1.55.0 (32da73ab1 2021-08-23): Failed to run `cargo metadata --manifest-path /Users/jadestrong/Documents/JadeStrong/rust-in-action/rust-demo/Cargo.toml`: `cargo metadata` exited with an error: Updating `ustc` index
error: failed to select a version for the requirement `rand = "^0.9.4"`
candidate versions found which didn't match: 0.8.4, 0.8.3, 0.8.2, ...
location searched: `ustc` index (which is replacing registry `crates-io`)
required by package `rust-demo v0.1.0 (/Users/jadestrong/Documents/JadeStrong/rust-in-action/rust-demo)`
perhaps a crate was updated and forgotten to be re-vendored?

Reverting buffer ‘Cargo.toml’.
```
6. Here is `doom/info` :
```
generated Oct 14, 2021 12:01:35
system MacOS 11.6 Darwin 20.6.0 x86_64 ns
emacs 28.0.50 master 988428df7 ~/.emacs.d/ -> ~/.emacs.d/
doom 3.0.0-alpha HEAD -> develop 68c533697 2021-10-07 03:11:03 +0200 ~/.doom.d/ -> ~/dotfiles/home/.doom.d/
shell /usr/local/bin/fish
features ACL GLIB GMP GNUTLS JPEG JSON LIBXML2 MODULES NATIVE_COMP NOTIFY KQUEUE NS PDUMPER PNG RSVG THREADS TIFF TOOLKIT_SCROLL_BARS ZLIB
traits gui server-running envvar-file custom-file
custom warning-suppress-types warning-suppress-log-types safe-local-variable-values rime-librime-root rime-inline-ascii-trigger default-input-method
modules :input (&user chinese2) :completion company ivy :ui deft doom doom-quit hl-todo modeline ophints (popup +defaults) vc-gutter vi-tilde-fringe window-select workspaces :editor (evil +everywhere) file-templates fold format multiple-cursors rotate-text snippets word-wrap :emacs dired electric ibuffer undo vc :checkers syntax :tools docker editorconfig (eval +overlay) lookup lsp magit make taskrunner :os macos :lang data emacs-lisp json (javascript +lsp) lua (markdown +grip) nix (org +pretty +dragndrop +pandoc +roam2 +present) plantuml (python +lsp) (rust +lsp) sh (web +lsp) :config (default +bindings +smartparens)
packages (js-doc) (react-snippets) (evil-matchit) (pinyinlib) (leetcode :recipe (:host github :repo jadestrong/leetcode.el)) (insert-translated-name :recipe (:host github :repo manateelazycat/insert-translated-name)) (company-tabnine :recipe (:host github :repo TommyX12/company-tabnine)) (citre :recipe (:host github :repo universal-ctags/citre :files (*.el))) (eslintd-fix)
```

### System Information

https://pastebin.com/FLQMHu51

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with a Rust project by opening src/main.rs and Cargo.toml in Doom Emacs with the rust +lsp module enabled, then changing a dependency. Start by examining the Doom Rust and LSP configuration; done means rust-analyzer reloads its workspace and recognizes the updated dependency without requiring another editor.

Written by the indexing model from the issue text.

Assessment

Tech stack
emacs-lisp, rust
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.