Format document builds path incorrectly for rust-analyzer

Getting the following error when trying to format a Rust file:

[Error - 9:15:59 AM] Request textDocument/formatting failed.
  Message: Failed to spawn cd "/Users/<my_username>/documents/repo/repo/backend" && "rustfmt"
  Code: -32603 

The issue is in how the path in the cd command is constructed. It should be "/Users/<my_username>/documents/repo/backend".

This works as expected in VSCode.

Hi @adanielnoel

Is Rust installed on your system using Homebrew?

Hey @deanrie. I’m afraid I was wrong, the path was correctly constructed but rustfmt is not the tool I was looking for. I thought it could be used to format on the fly through a keybinding but it seems to be meant more as a CI toolchain.

I ended up finding the “Prettier - Code formatter (Rust)” extension, which seems to do the job for now.