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 not expanded: failed to write request (os error 232) on Windows #16306

Closed
zjp-CN opened this issue Jan 8, 2024 · 27 comments
Closed
Labels
A-proc-macro proc macro Broken Window Bugs / technical debt to be addressed immediately C-bug Category: bug

Comments

@zjp-CN
Copy link

zjp-CN commented Jan 8, 2024

rust-analyzer version: rust-analyzer version: 0.3.1791-standalone (9db5155 2024-01-01)

rustc version: rustc 1.77.0-nightly (595bc6f00 2024-01-05)

relevant settings: none

proc macro Serialize not expanded: failed to write request: 管道正在被关闭。 (os error 232)
rust-analyzer unresolved-proc-macro

OS: Windows11

Reproduce:

cargo new test-ra
cd test-ra
cargo add serde -F derive
// src/main.rs
use serde::Serialize;
#[derive(Serialize)]
pub struct A {}
fn main() {}

Found a related but closed issue: #14991

@zjp-CN zjp-CN added the C-bug Category: bug label Jan 8, 2024
@Veykril
Copy link
Member

Veykril commented Jan 8, 2024

We really need to improve the pipe closed error somehow

@Veykril Veykril added the A-proc-macro proc macro label Jan 8, 2024
@Veykril
Copy link
Member

Veykril commented Jan 8, 2024

Though generally that means the server crashed I think, which has me worried that the upstream server is now built without the sysroot abi after the trouble i had there last week ...

@Veykril
Copy link
Member

Veykril commented Jan 8, 2024

Yup, I broke the sysroot server last week ...

@lnicola lnicola added the Broken Window Bugs / technical debt to be addressed immediately label Jan 8, 2024
@lnicola lnicola pinned this issue Jan 8, 2024
@Veykril
Copy link
Member

Veykril commented Jan 8, 2024

image
apparently I managed to dynamically link the server against rustc internals? 🤨

@Veykril
Copy link
Member

Veykril commented Jan 8, 2024

@onur-ozkan apologies for the cross-repo ping, but do you have an idea what could be going wrong here? Do I need to tell bootstrap to do static linking here somehow? Do you have an idea of how to go on about fixing this (problem being outlined below)?

@Veykril
Copy link
Member

Veykril commented Jan 8, 2024

Oh, nvm now I see whats going on. We changed the tool mode to Rustc which is expected to dynamically link, but the proc-macro server lives in libexec, not bin so we fail to find the dylib! Well that is annoying ...

Unsure how to proceed here then, should we just move the server into the bin directory? Duplicating the libraries into libexec seems like a bad choice given their size, and symlinking isn't an option either I'd assume.

Alternatively, we could try linking in the rustc_driver statically for this, as we dont use as much of it as other tools are

@Veykril
Copy link
Member

Veykril commented Jan 8, 2024

@nevercast
Copy link

Any updates to this? I'm seeing this with wasm_bindgen

@zjp-CN
Copy link
Author

zjp-CN commented Jan 11, 2024

From zulip thread above, the issue may result from this PR merged on 2024-01-05, so I tried pinning the nightly toolchain before that date, and with latest rust-analyzer v0.3.1799 released on 2024-01-08, it turns out to work without the error.
And if your toolchain is on stable, you may not see this error, since that landed before 2024-01-05 (I've tested it on stable toolchain with latest nightly RA).

# rust-toolchain.toml in your project
[toolchain]
channel = "nightly-2024-01-04"

or

# globally override
rustup toolchain install nightly-2024-01-04
rustup default nightly-2024-01-04

P.S. it seems that this issue mainly happens on Windows.

@nevercast
Copy link

Thank you @zjp-CN. I will try that on my Windows machine. If the issue is not present on Linux I may also use that until it lands in latest nightly. Thanks for the quick and detailed response!

@Veykril
Copy link
Member

Veykril commented Jan 11, 2024

Yes, to add context. This issue only exists on the windows toolchain because windows does not support rpaths and the the proc-macro server is now dynamically linked to something outside of its own directory. Latest nightly r-a and next week's stable r-a should just work again.

This was fixed by #16312 (if not please tell)

@Veykril Veykril closed this as completed Jan 11, 2024
@spvky
Copy link

spvky commented Feb 18, 2024

Don't know if this is 100% related but I'm running the stable-x86_64-unknown-linux-gnu toolchain and using rustup update to update to rust 1.76 yesterday introduced this error using the built in LSP in nvim
image

@arnfaldur
Copy link

arnfaldur commented Feb 19, 2024

I have also encountered this exact issue using lsp-mode in emacs on linux. I managed to mitigate it by using an older toolchain (from around last october) but I can't use the old toolchain anymore, reintroducing the problem.

@zjp-CN
Copy link
Author

zjp-CN commented Feb 19, 2024

@spooky-th-ghost I've tested 2024-02-12 nightly RA with 1.76 stable toolchain (released on 2024-02-04) for proc macros, nothing goes wrong.
IIUC the error says your proc-macro server (from toolchain) is newer than RA. What's the verion of your RA?

@Veykril
Copy link
Member

Veykril commented Feb 19, 2024

As was said you'll need to update your rust-analyzer to a newer version./

@arnfaldur
Copy link

I was having issues with making lsp-mode in emacs use the matching rust-analyzer and proc macro expander. I just messed with it until it worked.

@spvky
Copy link

spvky commented Feb 19, 2024

@spooky-th-ghost I've tested 2024-02-12 nightly RA with 1.76 stable toolchain (released on 2024-02-04) for proc macros, nothing goes wrong. IIUC the error says your proc-macro server (from toolchain) is newer than RA. What's the verion of your RA?

I pulled the source yesterday and built and it looks like it's version 0.0.0

@spvky
Copy link

spvky commented Feb 19, 2024

Just downloaded the release of rust-analyzer from today and i'm still getting the same issue on proc-macros

@Veykril
Copy link
Member

Veykril commented Feb 19, 2024

Then it seems like you are still somehow running an outdated server as the release build has the latest server version running.

I pulled the source yesterday and built and it looks like it's version 0.0.0

source builds always have version 0.0.0

@spvky
Copy link

spvky commented Feb 19, 2024

pretty lost at this point, reinstalled rustup and rust analyzer and I'm still getting the error, my current rust-analyzer version is rust-analyzer 0.3.1850-standalone

@Veykril Veykril unpinned this issue Feb 28, 2024
@benfaerber
Copy link

benfaerber commented Mar 15, 2024

I'm having the same issue on Neovim on Pop OS (Linux).
rustc 1.76.0 (07dca489a 2024-02-04)
rust-analyzer 1.76.0 (07dca48 2024-02-04)

proc macro Serialize not expanded: Failed to run proc-macro server from path /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/libexec/rust-analyzer-proc-macro-srv, error: Custom { kind: Other, error: "proc-macro server's api version (3) is newer than rust-analyzer's (2)" }

I've tried everything, reinstalling, rebooting, replacing the rust-analyzer binary with the latest release.

@zjp-CN
Copy link
Author

zjp-CN commented Mar 15, 2024

@benfaerber FYI if you use LSP plugins in neovim that install RA (say mason), it's likely not to use RA installed from rustup, which also cause outdated RA with newer toolchain.

@benfaerber
Copy link

@benfaerber FYI if you use LSP plugins in neovim that install RA (say mason), it's likely not to use RA installed from rustup, which also cause outdated RA with newer toolchain.

OMG I didn't realize that! Thanks for the tip, it fixed it!

@790944715
Copy link

790944715 commented Apr 17, 2024

Is this issue been fixed?
I still encounter this issue with the stable version:

**PS F:\workspace\rust\test-ra> rustup update
info: syncing channel updates for 'stable-x86_64-pc-windows-msvc'
info: checking for self-update

stable-x86_64-pc-windows-msvc unchanged - rustc 1.77.2 (25ef9e3d8 2024-04-09)

info: cleaning up downloads & tmp directories**

Here's the error message, how can I fix this issue in vscode, currently can't find a useful way.
proc macro Parser not expanded: failed to write request: 管道正在被关闭。 (os error 232)

@TheRealSmeddy
Copy link

Updated rust version, restarted the workspace and extensions, seems to be fixed

@Zerowalker
Copy link

Zerowalker commented Jul 17, 2024

EDIT:

Ignore this, for some reason proc macro was disabled in the settings,
no clue why it has worked before though, but enabling it made it work as intended, my bad

I still get this issue:

stable-x86_64-pc-windows-msvc (default)
rustc 1.79.0 (129f3b996 2024-06-10)
---
Version 0.4.2039, Server Version 0.4.2039-standalone (26747bd1e 2024-07-16)
or
Version 0.3.2037, Server Version 0.3.2037-standalone (e9afba57a 2024-07-14)

Have updated rust and reloaded the workspace, even restarted vscode to no avail.

@KiSetsuFu-PuLiN
Copy link

Fixed after update VSCode

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-proc-macro proc macro Broken Window Bugs / technical debt to be addressed immediately C-bug Category: bug
Projects
None yet
Development

No branches or pull requests