Skip to content

Custom rustfmt commands cannot use relative executable paths #4486

@ecstatic-morse

Description

@ecstatic-morse

While trying to make rust-analyzer use the bootstrap version of rustfmt inside rustc, @jonas-schievink discovered that using a relative path to rustfmt won't work:

Ah, looks like it adjusts the working dir dynamically, so it can't find the command with a relative path

https://github.com/rust-analyzer/rust-analyzer/blob/d51c1f62178c383363a2d95e865131d9a7b969d0/crates/rust-analyzer/src/main_loop/handlers.rs#L651-L655

As a workaround, you can specify an absolute path, but I was thinking we could canonicalize the first "shell word" if it looks like a path (e.g., ./rustfmt or build/rustfmt but not rustfmt2). This would require some sort of library that can do shell word-splitting, however. Perhaps there is a better way?

The which crate would be helpful for part of this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-easyS-actionableSomeone could pick this issue up and work on it right now

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions