Stream: t-compiler/wg-rls-2.0

Topic: custom rustfmt


nikomatsakis (Aug 04 2020 at 16:34, on Zulip):

I'm seeing these errors when editing compiler and trying to use the compiler's rustfmt:

[Error - 12:33:50 PM] Request textDocument/formatting failed.
Message: No such file or directory (os error 2)
Code: -32603

matklad (Aug 04 2020 at 16:37, on Zulip):

Hm, is the custom rustfmt there? "No such file or directory" often happens when you execute something which doesn't exist.

matklad (Aug 04 2020 at 16:37, on Zulip):

Wouldn't it be awesome if std::io::Error actually said which path is wrong :-D We need to add some anyhow::context somewhere I guess....

Laurențiu Nicola (Aug 04 2020 at 17:09, on Zulip):

Try strace -etrace=%process -fp $PID_OF_RA

nikomatsakis (Aug 05 2020 at 09:46, on Zulip):

the file is there, yes

nikomatsakis (Aug 05 2020 at 09:46, on Zulip):

but maybe the relative path is causing problems

nikomatsakis (Aug 05 2020 at 09:46, on Zulip):

some more context:

athena. pwd
/home/nmatsakis/versioned/rust-1
athena. cat .vscode/settings.json
{
  "rust-analyzer.checkOnSave.overrideCommand": [
    "./x.py",
    "check",
    "--json-output"
  ],
  "rust-analyzer.rustfmt.overrideCommand": [
    "./build/x86_64-unknown-linux-gnu/stage0/bin/rustfmt"
  ],
  "editor.formatOnSave": true
}
athena. ls "./build/x86_64-unknown-linux-gnu/stage0/bin/rustfmt"
./build/x86_64-unknown-linux-gnu/stage0/bin/rustfmt
nikomatsakis (Aug 05 2020 at 09:47, on Zulip):

I can try strace

nikomatsakis (Aug 05 2020 at 09:47, on Zulip):

though I'm not sure which PID to use :)

nikomatsakis (Aug 05 2020 at 09:48, on Zulip):

hmm I didn't see anything from strace

Jonas Schievink (Aug 05 2020 at 09:49, on Zulip):

ah, yeah, you need to use a relative path now

nikomatsakis (Aug 05 2020 at 09:49, on Zulip):

ah now I did

Jonas Schievink (Aug 05 2020 at 09:49, on Zulip):

err, absolute

nikomatsakis (Aug 05 2020 at 09:49, on Zulip):

oh ok

nikomatsakis (Aug 05 2020 at 09:49, on Zulip):

we should fix that...

matklad (Aug 05 2020 at 09:49, on Zulip):

Ah yeah.... the relative path might be a culprit, we absolutize them relative to worspace root URI, and I am not sure what's that URI would be for VS Code

nikomatsakis (Aug 05 2020 at 09:49, on Zulip):

...and/or update rustc-dev-guide :)

nikomatsakis (Aug 05 2020 at 09:49, on Zulip):

fix = better of course

nikomatsakis (Aug 05 2020 at 09:50, on Zulip):

I at least have a lot of checkouts so it's nice for it to be relative

nikomatsakis (Aug 05 2020 at 09:50, on Zulip):

matklad said:

Ah yeah.... the relative path might be a culprit, we absolutize them relative to worspace root URI, and I am not sure what's that URI would be for VS Code

but this seems like the behavior I wnt

nikomatsakis (Aug 05 2020 at 09:51, on Zulip):

still, strace output:

[pid  7781] execve("./build/x86_64-unknown-linux-gnu/stage0/bin/rustfmt", ["./build/x86_64-unknown-linux-gnu"...], 0x55a7d3de7b80 /* 51 vars */) = -1 ENOENT (No such file or direc
nikomatsakis (Aug 05 2020 at 09:51, on Zulip):

thanks all

matklad (Aug 05 2020 at 09:53, on Zulip):

Yeah, I'll try to look at it today... maybe -- been busy this week, and I have vacation starting tomorrow :D

nikomatsakis (Aug 05 2020 at 09:55, on Zulip):

no stress..

Laurențiu Nicola (Aug 05 2020 at 10:24, on Zulip):

And ls /proc/7781/cwd/build/x86_64-unknown-linux-gnu/stage0/bin/rustfmt?

matklad (Aug 05 2020 at 11:07, on Zulip):

I guess, I've found the explanation: https://github.com/oconnor663/duct.rs/blob/17e30e83a16b202551df4d70d0b2cc174cb53e5d/src/lib.rs#L295-L324

One more thing I know I wish I didn't

matklad (Aug 05 2020 at 11:26, on Zulip):

Should be fixed by https://github.com/rust-analyzer/rust-analyzer/pull/5668

Last update: Sep 27 2020 at 14:30UTC