# Format document builds path incorrectly for rust-analyzer

**URL:** <https://forum.cursor.com/t/format-document-builds-path-incorrectly-for-rust-analyzer/25013>\
**Category:** Help\
**Created:** [October 28, 2024, 8:45am UTC](https://forum.cursor.com/t/format-document-builds-path-incorrectly-for-rust-analyzer/25013 "2024-10-28T08:45:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![adanielnoel](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/adanielnoel/32/9965_2.png) [@adanielnoel](https://forum.cursor.com/u/adanielnoel)\
**Post date:** [October 28, 2024, 8:45am UTC](https://forum.cursor.com/t/format-document-builds-path-incorrectly-for-rust-analyzer/25013/1 "2024-10-28T08:45:50Z")

</div>

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

```auto
[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.

---

<div class="post-metadata">

**Author:** ![deanrie](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/deanrie/32/1263_2.png) [@deanrie](https://forum.cursor.com/u/deanrie)\
**Post date:** [October 28, 2024, 1:17pm UTC](https://forum.cursor.com/t/format-document-builds-path-incorrectly-for-rust-analyzer/25013/2 "2024-10-28T13:17:34Z")

</div>

Hi @adanielnoel

Is Rust installed on your system using Homebrew?

---

<div class="post-metadata">

**Author:** ![adanielnoel](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/adanielnoel/32/9965_2.png) [@adanielnoel](https://forum.cursor.com/u/adanielnoel)\
**Post date:** [October 28, 2024, 7:45pm UTC](https://forum.cursor.com/t/format-document-builds-path-incorrectly-for-rust-analyzer/25013/3 "2024-10-28T19:45:42Z")

</div>

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.
