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

rustfmt not formatting in Legacy mode #270

Closed
mwrock opened this Issue Jun 9, 2017 · 12 comments

Comments

Projects
None yet
4 participants
@mwrock

mwrock commented Jun 9, 2017

Version of VSCode: 1.13.0
Version of the extension: 0.13.14
OS: Windows 10

This just started happening a couple days ago. When I select "Format Document" to format my rust code, nothing happens. Even if I purposely misformat the code. However running rustfmt from the command line will format the document.

Further, I don't see any output debugging in the output window.

Can anyone recommend any steps to further troubleshoot the issue?

@mwrock

This comment has been minimized.

Show comment
Hide comment
@mwrock

mwrock Jun 9, 2017

Just managed to reproduce this on another environment that was just working. It appears to be relared to rustfmt 0.8.4. Things stop working after upgrading to that version.

mwrock commented Jun 9, 2017

Just managed to reproduce this on another environment that was just working. It appears to be relared to rustfmt 0.8.4. Things stop working after upgrading to that version.

@nambrot

This comment has been minimized.

Show comment
Hide comment
@nambrot

nambrot Jun 9, 2017

Same here

nambrot commented Jun 9, 2017

Same here

@CryZe

This comment has been minimized.

Show comment
Hide comment
@CryZe

CryZe Jun 9, 2017

Contributor

rustfmt doesn't support Windows anymore

Contributor

CryZe commented Jun 9, 2017

rustfmt doesn't support Windows anymore

@mwrock

This comment has been minimized.

Show comment
Hide comment
@mwrock

mwrock Jun 9, 2017

0.8.4 runs fine on windows commandline

mwrock commented Jun 9, 2017

0.8.4 runs fine on windows commandline

@CryZe

This comment has been minimized.

Show comment
Hide comment
@CryZe

CryZe Jun 9, 2017

Contributor

Your crate must either be very small (not a lot of submodules), so you are not hitting the bug, or you are not actually running 0.8.4 in the command line. Anyways, basically rustfmt 0.8.4 canonicalizes paths, which syntex doesn't support. But syntex isn't getting updated anymore, so rustfmt will soon use nightly-only libsyntax: http://www.ncameron.org/blog/rustfmt-changes/

Contributor

CryZe commented Jun 9, 2017

Your crate must either be very small (not a lot of submodules), so you are not hitting the bug, or you are not actually running 0.8.4 in the command line. Anyways, basically rustfmt 0.8.4 canonicalizes paths, which syntex doesn't support. But syntex isn't getting updated anymore, so rustfmt will soon use nightly-only libsyntax: http://www.ncameron.org/blog/rustfmt-changes/

@CryZe

This comment has been minimized.

Show comment
Hide comment
@CryZe

CryZe Jun 9, 2017

Contributor

The fix until then is to downgrade to 0.8.3.

Contributor

CryZe commented Jun 9, 2017

The fix until then is to downgrade to 0.8.3.

@mwrock

This comment has been minimized.

Show comment
Hide comment
@mwrock

mwrock Jun 9, 2017

ok. I might be avoiding it because I was just running it against single files

mwrock commented Jun 9, 2017

ok. I might be avoiding it because I was just running it against single files

@CryZe

This comment has been minimized.

Show comment
Hide comment
@CryZe

CryZe Jun 9, 2017

Contributor

Oh yeah, that should work. I think it's cargo fmt, that first collects all the paths, canonicalizes them and then runs rustfmt on each one.

Contributor

CryZe commented Jun 9, 2017

Oh yeah, that should work. I think it's cargo fmt, that first collects all the paths, canonicalizes them and then runs rustfmt on each one.

@CryZe

This comment has been minimized.

Show comment
Hide comment
@CryZe

CryZe Jun 9, 2017

Contributor

Maybe we should shoot them a PR that reverts this behavior (maybe only on windows via a feature gate) and it can be reintroduced in the nightly only 0.9 where it should work.

Contributor

CryZe commented Jun 9, 2017

Maybe we should shoot them a PR that reverts this behavior (maybe only on windows via a feature gate) and it can be reintroduced in the nightly only 0.9 where it should work.

@CryZe

This comment has been minimized.

Show comment
Hide comment
@CryZe

CryZe Jun 15, 2017

Contributor

They released a new version. While rustfmt itself now works, it breaks the vscode-rust plugin :(

Contributor

CryZe commented Jun 15, 2017

They released a new version. While rustfmt itself now works, it breaks the vscode-rust plugin :(

@CryZe

This comment has been minimized.

Show comment
Hide comment
@CryZe

CryZe Jun 15, 2017

Contributor
Cannot read property 'replace' of undefined: TypeError: Cannot read property 'replace' of undefined
    at patches.map.patch (C:\Users\Christopher\.vscode\extensions\kalitaalexey.vscode-rust-0.3.14\out\src\components\formatting\formatting_manager.js:204:62)
    at Array.map (native)
    at FormattingManager.parseDiff (C:\Users\Christopher\.vscode\extensions\kalitaalexey.vscode-rust-0.3.14\out\src\components\formatting\formatting_manager.js:196:35)
    at cp.execFile (C:\Users\Christopher\.vscode\extensions\kalitaalexey.vscode-rust-0.3.14\out\src\components\formatting\formatting_manager.js:70:41)
    at ChildProcess.exithandler (child_process.js:230:5)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at maybeClose (internal/child_process.js:885:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
Contributor

CryZe commented Jun 15, 2017

Cannot read property 'replace' of undefined: TypeError: Cannot read property 'replace' of undefined
    at patches.map.patch (C:\Users\Christopher\.vscode\extensions\kalitaalexey.vscode-rust-0.3.14\out\src\components\formatting\formatting_manager.js:204:62)
    at Array.map (native)
    at FormattingManager.parseDiff (C:\Users\Christopher\.vscode\extensions\kalitaalexey.vscode-rust-0.3.14\out\src\components\formatting\formatting_manager.js:196:35)
    at cp.execFile (C:\Users\Christopher\.vscode\extensions\kalitaalexey.vscode-rust-0.3.14\out\src\components\formatting\formatting_manager.js:70:41)
    at ChildProcess.exithandler (child_process.js:230:5)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at maybeClose (internal/child_process.js:885:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
@KalitaAlexey

This comment has been minimized.

Show comment
Hide comment
@KalitaAlexey

KalitaAlexey Jun 15, 2017

Member

@CryZe, Could you provide a fix please?

Member

KalitaAlexey commented Jun 15, 2017

@CryZe, Could you provide a fix please?

CryZe added a commit to CryZe/vscode-rust that referenced this issue Jun 27, 2017

Fix rustfmt not working on Windows
rustfmt 0.9.0 uses canonicalized paths, which look like this on Windows:
`\\?\C:\Some\Path\file.rs`. These paths don't compare properly to the
.rs.fmt files that vscode-rust is working with. Through a ton of ugly Uri
hacks, I was able to turn them into paths that can be properly compared to
the ones in rustfmt's diffs. This is super ugly and might not even work on
macOS or Linux, so it needs some testing there.

Fixes #270

@KalitaAlexey KalitaAlexey closed this in #311 Jun 28, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment