rust-analyzer: Possible crash in `rust-project.json` project after #14111

rust-analyzer version: (eg. output of “rust-analyzer: Show RA Version” command, accessible in VSCode via <kbd>Ctrl/⌘</kbd>+<kbd>Shift</kbd>+<kbd>P</kbd>)

❯ rust-analyzer --version
rust-analyzer 0.0.0 (f1b257f4e 2023-01-27)

Installed from the latest commit 3bc33c7e9f041c5aef69a5c33b3d29d19a341ece in master.

rustc version: (eg. output of rustc -V)

rustc 1.67.0 (fc594f156 2023-01-24)

relevant settings: (eg. client settings, or environment variables like CARGO, RUSTC, RUSTUP_HOME or CARGO_HOME)

When opening projects in Emacs using lsp-mode and rust-analyzer, the server starts up, I can see flycheck diagnostics, but after a few seconds I get

Server rust-analyzer:6427 exited (check corresponding stderr buffer for details). Do you want to restart it? (y or n)

The *Messages* buffer shows:

LSP :: Connected to [rust-analyzer:7609/starting REDACTED].
LSP :: rust-analyzer:7609 initialized successfully in folders: (REDACTED)
LSP :: rust-analyzer has exited (abort trap: 6)
user-error: Beginning of history; no preceding item [2 times]
Server rust-analyzer:7609 exited (check corresponding stderr buffer for details). Do you want to restart it? (y or n) n
Invalid preview key: [67108910]

*rust-analyzer::stderr* shows:

Error: Custom { kind: InvalidData, error: Error("unknown variant `ApiVersionCheck`, expected `ListMacros` or `ExpandMacro`", line: 1, column: 18) }

Process rust-analyzer stderr finished

The server IO log buffer has a bunch of:

[Trace - 06:08:54 PM] Received response 'nil - (17)' in 0ms.
Result: {
  "code": -32800,
  "message": "canceled by client"
}

Context

I did several things to try to figure out what was causing this and found:

  • This crash only happens with projects internal to my company. If I pull the rust-analyzer repo or any other public Rust repo, everything works without issue. My company uses a custom build tool, so this made me wonder if it was something related to that. However…
  • I opened the same internal projects using VS Code and RA and everything worked without issue.
  • I opened the internal projects in Helix with RA and RA crashed.

This has been happening since the beginning of the week (probably Monday).

Also, the log

Error: Custom { kind: InvalidData, error: Error("unknown variant `ApiVersionCheck`, expected `ListMacros` or `ExpandMacro`", line: 1, column: 18) }

only appeared today. Since Monday, the *rust-analyzer::stderr* buffer previously showed:

Process rust-analyzer stderr finished

and no other information.

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 1
  • Comments: 28 (22 by maintainers)

Most upvoted comments

I tried master again just now and everything is working. Not sure what the issue was. I also upgraded to macOS Ventura, so I’m not sure if that affected anything.

It’s unrelated to @andrewbanchich’s crash, which is unrelated to the error message in the issue title. It’s also unrelated to the error message. Please file a new issue.

I’m seeing the same error in VS code:

rust-analyzer version: 0.3.1394-standalone (0b32b65ca 2023-02-05) rustc 1.66.1 (90743e729 2023-01-10)

The rust analyzer language server output shows the error immediately upon loading any rust project.

@andrewbanchich sorry, I copy-pasted the wrong SHA. I meant daa0138, because you said:

More specifically, daa0138e4c159d5753e41a447201b6191437276e crashes but 9a6294d7038e7eab00beafdf64ec4aa50a4c66a2 works.

@lnicola To clarify, it crashes, but that SHA only displays Process rust-analyzer stderr finished. It does not display the proc macro error message.

From my initial post:

This has been happening since the beginning of the week (probably Monday). Also, the log

Error: Custom { kind: InvalidData, error: Error(“unknown variant ApiVersionCheck, expected ListMacros or ExpandMacro”, line: 1, column: 18) }

only appeared today. Since Monday, the rust-analyzer::stderr buffer previously showed:

Process rust-analyzer stderr finished

and no other information.

I don’t think the crashes are due to the proc macro work.

I don’t think the crashes are due to the commit that introduced that error message.

@YuanYuYuan, yeah, if it doesn’t show up in NVim, you can safely ignore it. Well, you can ignore it anyway.

The unknown variant ApiVersionCheck message should not appear in 1d32a7b7c66450c792dafe162b229d40ab6a1cc8, as it didn’t exist until 6133e27b836efd04176d9381e1ae02038be01284, so I’m not sure what’s supposed to be happening.