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

proc-macro server no longer supported for toolchains up to v1.76 #18705

Closed
benjamin-nw opened this issue Dec 17, 2024 · 12 comments
Closed

proc-macro server no longer supported for toolchains up to v1.76 #18705

benjamin-nw opened this issue Dec 17, 2024 · 12 comments
Labels
C-support Category: support questions

Comments

@benjamin-nw
Copy link

Hello,

We use the toolchain 1.74 for rust projects and after the latest update to version (0.3.2220) we got an error when starting the server:

ERROR Failed to run proc-macro server from path /home/user/.rustup/toolchains/1.74-x86_64-unknown-linux-gnu/libexec/rust-analyzer-proc-macro-srv, error: Custom { kind: Other, error: "The version of the proc-macro server (2) in your Rust toolchain is too old and no longer supported by your rust-analyzer which requiresversion 4 or higher.\nThis will prevent proc-macro expansion from working. Please consider updating your toolchain or downgrading your rust-analyzer to ensure compatibility with your current toolchain."

After a bit of research, I found this PR #18670 that contains the new error message and it says:

internal: Drop proc-macro server support for ~1.66.0 and older toolchains

The error seems to come from this change, but the drop of support seems to go well beyond the 1.66 version.

After some more testing, I was able to get the error up to v1.76.

ERROR Failed to run proc-macro server from path /home/user/.rustup/toolchains/1.76-x86_64-unknown-linux-gnu/libexec/rust-analyzer-proc-macro-srv, error: Custom { kind: Other, error: "The version of the proc-macro server (3) in your Rust toolchain is too old and no longer supported by your rust-analyzer which requiresversion 4 or higher.\nThis will prevent proc-macro expansion from working. Please consider updating your toolchain or downgrading your rust-analyzer to ensure compatibility with your current toolchain." }

This version was out in February of this year.

The argument in the PR was:

That is toolchains older than ~20 months from today on where this version was released. Reason is to simplify the codebase, and we likely don't even support version that old due to other reasons anymore either

But the version 1.74 is a few months old and now unsupported with this PR.

Do you plan on keeping the server this way ? It could also be cool to have the minimum supported rust toolchain for a given version of the server.

Steps to reproduce

  1. Install rust-analyzer v0.3.2220 to your IDE (here I use VSCodium but any will do)
  2. Create a new project with cargo
    1. cargo new test
    2. cd test
    3. rustup override set 1.76
  3. Open the project in your IDE
  4. The error pops up in the OUTPUT window
@benjamin-nw benjamin-nw added the C-support Category: support questions label Dec 17, 2024
@Veykril
Copy link
Member

Veykril commented Dec 17, 2024

Indeed, the version we dropped support for was implemented in #14572 which is april last year. So that change earliest appeared in stable rust ~3 months later than that (and likely longer as I think that mightve been the time where we didnt keep up with syncs (though 1.76 being the latest to hit this is surpising still, that does sound a bit later than I'd expect).

Either way I seem to have misread the date when I looked at the blame. I am not sure if we want to reverse that, as we don't really support more than a couple of last stable releases (and for 1.74 I assume more than just this is already broken in some capacity by current rust-analyzer). Generally I'd recommend to pin your rust-analyzer to some version when you are working with older toolchains like this (or use the toolchain provided rust-analyzer instead).

@benjamin-nw
Copy link
Author

Thank you for the quick response,

Generally I'd recommend to pin your rust-analyzer to some version

We'll do that for now. We plan on upgrading the compiler version but not in a near future.

(or use the toolchain provided rust-analyzer instead)

I didn't know you could do that, will look into it, thanks !

@wfeii1980
Copy link

VSCode rust-analyzer 0.4.2222

2024-12-18T11:02:42.016391937+08:00 ERROR Failed to run proc-macro server from path /home/wii/.rustup/toolchains/1.75-x86_64-unknown-linux-gnu/libexec/rust-analyzer-proc-macro-srv, error: Custom { kind: Other, error: "The version of the proc-macro server (2) in your Rust toolchain is too old and no longer supported by your rust-analyzer which requiresversion 4 or higher.\nThis will prevent proc-macro expansion from working. Please consider updating your toolchain or downgrading your rust-analyzer to ensure compatibility with your current toolchain." }
[Error - 11:02:43] Server process exited with code 0.

Can you provide the ability to install specific versions of plugins

@manaljain6667
Copy link

I am running toolchain version 1.76.0 and facing the same issue, what is the recommended steps to deal with this

thanks

@Veykril
Copy link
Member

Veykril commented Dec 19, 2024

Generally I'd recommend to pin your rust-analyzer to some version when you are working with older toolchains like this (or use the toolchain provided rust-analyzer instead).

For VSCode you can install specific versions of the extension, or if you wanna use the rustup rust-analyzer you can point it to that serveer via the rust-analyzer.server.path config

@gwalen
Copy link

gwalen commented Dec 20, 2024

It is an annoying issue introduced with the new version. I'm using toolchain version 1.75.0 and also unexpectedly ran into this error, I would consider it a bug.

@chriskrycho
Copy link

rust-analyzer could (and is in various contexts alleged to! But I do not see evidence of that being true in practice) resolve via the rust-toolchain.toml.

In VS Code, a per-project override to use the version managed by rustup looks like this (assuming the default setup on macOS; adjust appropriately to your own OS):

{
   "rust-analyzer.server.path": "/Users/chris/.cargo/bin/rust-analyzer"
}

In Zed, the same:

// Folder-specific settings
//
// For a full list of overridable settings, and general information on folder-specific settings,
// see the documentation: https://zed.dev/docs/configuring-zed#settings-files
{
  "lsp": {
    "rust-analyzer": {
      "binary": {
        "path": "/Users/chris/.cargo/bin/rust-analyzer"
      }
    }
  }
}

If you want to make rust-analyzer default to always doing that, you can set that config in the app-level settings instead. I do not necessarily recommend that, because it’s nice to get more features as rust-analyzer keeps improving, but it has the nice benefit of not breaking in situations like this one!

@Veykril
Copy link
Member

Veykril commented Dec 20, 2024

rust-analyzer could (and is in various contexts alleged to! But I do not see evidence of that being true in practice) resolve via the rust-toolchain.toml.

It already does honor toolchain overrides as long as they target the same folder as your cargo workspace resides in (that is where the corresponding Cargo.toml exists), but to use the toolchain rust-analyzer, the override needs to specify the rust-analyzer component.

@davidbarsky
Copy link
Contributor

the override needs to specify the rust-analyzer component.

These are typically automatically generated, no? Maybe rustup should default to including rust-analyzer in the component list if it doesn't already?

@Veykril
Copy link
Member

Veykril commented Dec 20, 2024

That seems like a very big ask, not everyone uses rust-analyzer.

@Veykril
Copy link
Member

Veykril commented Dec 20, 2024

#18731 reverts this temporarily until we introduce #18730 to give a warning headsup for future (known) supported version drops (and to instruct users on what their options then are)

@chriskrycho
Copy link

but to use the toolchain rust-analyzer, the override needs to specify the rust-analyzer component.

This is helpful; is it documented in the rust-analyzer somewhere? I did not find that anywhere in the docs when I searched just now, but very well may have missed it!

For reference, for folks reading along, see this section of the rustup manual, which includes an example of toolchain.components:

[toolchain]
channel = "nightly-2020-07-10"
components = [ "rustfmt", "rustc-dev" ]
targets = [ "wasm32-unknown-unknown", "thumbv2-none-eabi" ]
profile = "minimal"

As documented here, the components value specifies additional components to install, so I believe the relevant bit here would be to write something like this:

[toolchain]
channel = "1.75.0" # or some other pre-1.76 version
components = ["rust-analyzer"]

That being said, rustup obviously does not document what if any behavior rust-analyzer layers on top of that specification. As it stands I think this thread is the most likely place for someone to learn that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-support Category: support questions
Projects
None yet
Development

No branches or pull requests

7 participants