vscode-clang-format icon indicating copy to clipboard operation
vscode-clang-format copied to clipboard

Error write EPIPE using clang-format with visual studio code (Assumption: user settings ignored, default value added to each workspace)

Open cyberman54 opened this issue 6 years ago • 40 comments
trafficstars

Since latest update of VSC on Windows 10 i get a VSC popup with error "write EPIPE" when trying to format a file.

cyberman54 avatar Apr 06 '19 12:04 cyberman54

Same problem here. The dev console prints:

ERR spawn clang-format ENOENT: Error: spawn clang-format ENOENT
	at Process.ChildProcess._handle.onexit (internal/child_process.js:229:19)
	at onErrorNT (internal/child_process.js:406:16)
	at process._tickCallback (internal/process/next_tick.js:63:19)

screen

Tested with the latest version 1.9.0.

Version: 1.33.1 (user setup) Commit: 51b0b28134d51361cf996d2f0a1c698247aeabd8 Date: 2019-04-11T08:27:14.102Z Electron: 3.1.6 Chrome: 66.0.3359.181 Node.js: 10.2.0 V8: 6.6.346.32 OS: Windows_NT x64 10.0.17763

@xaverh Any idea? :)

domske avatar May 10 '19 17:05 domske

same issue here but on windows 7, https://i.imgur.com/W7oekKa.png

worked great until a recent update of VSC

@domske dev console? i can't find any dev console, but i found a "debug console", which is empty, is it the same thing? https://i.imgur.com/im2f5a5.png

divinity76 avatar May 26 '19 13:05 divinity76

@divinity76 No, VS Code is a web-application running on Chromium (like Chrome). You can access the Developer Tools (dev console) by the Help-Menu or press CTRL + SHIFT + I. Now you see the JavaScript console.

domske avatar May 26 '19 16:05 domske

@domske thanks, found it. i get the same error as you, it seems.

  ERR spawn clang-format ENOENT: Error: spawn clang-format ENOENT
	at Process.ChildProcess._handle.onexit (internal/child_process.js:229:19)
	at onErrorNT (internal/child_process.js:406:16)
	at process._tickCallback (internal/process/next_tick.js:63:19)

Version: 1.34.0 (system setup) Commit: a622c65b2c713c890fcf4fbf07cf34049d5fe758 Date: 2019-05-15T21:59:37.030Z Electron: 3.1.8 Chrome: 66.0.3359.181 Node.js: 10.2.0 V8: 6.6.346.32 OS: Windows_NT x64 6.1.7601

divinity76 avatar May 26 '19 17:05 divinity76

I am also facing same issue.

blurredart avatar Jun 09 '19 03:06 blurredart

I get the same error after install extension Shader languages support for VS Code

ERR spawn clang-format ENOENT: Error: spawn clang-format ENOENT
	at Process.ChildProcess._handle.onexit (internal/child_process.js:229:19)
	at onErrorNT (internal/child_process.js:406:16)
	at process._tickCallback (internal/process/next_tick.js:63:19)

also get warning when save 'glsl' file

 WARN Error: write EPIPE
	at afterWriteDispatched (internal/stream_base_commons.js:75:25)
	at writeGeneric (internal/stream_base_commons.js:70:3)
	at Socket._writeGeneric (net.js:758:5)
	at Socket._write (net.js:770:8)
	at doWrite (_stream_writable.js:410:12)
	at writeOrBuffer (_stream_writable.js:394:5)
	at Socket.Writable.write (_stream_writable.js:294:11)
	at Socket.Writable.end (_stream_writable.js:579:10)
	at Socket.end (net.js:534:31)
	at doFormatDocument.Promise (c:\Users\DoubleZ\.vscode\extensions\xaver.clang-format-1.9.0\out\src\extension.js:178:25)
	at new Promise (<anonymous>)
	at ClangDocumentFormattingEditProvider.doFormatDocument (c:\Users\DoubleZ\.vscode\extensions\xaver.clang-format-1.9.0\out\src\extension.js:152:16)
	at ClangDocumentFormattingEditProvider.provideDocumentFormattingEdits (c:\Users\DoubleZ\.vscode\extensions\xaver.clang-format-1.9.0\out\src\extension.js:20:21)
	at define.provideDocumentFormattingEdits.a.asPromise (d:\Program\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:578:40)
	at t.asPromise.Promise (d:\Program\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:53:320)
	at new Promise (<anonymous>)
	at Object.t.asPromise (d:\Program\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:53:292)
	at D.provideDocumentFormattingEdits (d:\Program\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:578:11)
	at define.$provideDocumentFormattingEdits._withAdapter.e (d:\Program\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:593:633)
	at j._withAdapter (d:\Program\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:588:126)
	at j.$provideDocumentFormattingEdits (d:\Program\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:593:611)
	at d._doInvokeHandler (d:\Program\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:644:1006)
	at d._invokeHandler (d:\Program\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:644:698)
	at d._receiveRequest (d:\Program\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:643:293)
	at d._receiveOneMessage (d:\Program\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:642:141)
	at define.constructor._protocol.onMessage.e (d:\Program\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:640:400)
	at u.fire (d:\Program\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:47:720)
	at a (d:\Program\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:176:766)
	at e (d:\Program\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:176:812)
	at u.fire (d:\Program\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:47:720)
	at n.constructor.e.onMessage.e (d:\Program\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:748:721)
	at u.fire (d:\Program\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:47:720)
	at a (d:\Program\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:176:766)
	at e (d:\Program\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:176:812)
	at u.fire (d:\Program\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:47:720)
	at y._receiveMessage (d:\Program\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:185:670)
	at define.constructor._socketDisposables.push._socketReader.onMessage.e (d:\Program\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:182:981)
	at u.fire (d:\Program\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:47:720)
	at f.acceptChunk (d:\Program\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:179:532)
	at define.constructor._register._socket.onData.e (d:\Program\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:178:869)
	at Socket.t (d:\Program\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:187:141)
	at Socket.emit (events.js:182:13)
	at addChunk (_stream_readable.js:279:12)
	at readableAddChunk (_stream_readable.js:264:11)
	at Socket.Readable.push (_stream_readable.js:219:10)
	at Pipe.onread (net.js:636:20)

Version: 1.35.1 (user setup) Commit: c7d83e57cd18f18026a8162d042843bda1bcf21f Date: 2019-06-12T14:30:02.622Z Electron: 3.1.8 Chrome: 66.0.3359.181 Node.js: 10.2.0 V8: 6.6.346.32 OS: Windows_NT x64 10.0.18362

SourceZh avatar Jun 17 '19 08:06 SourceZh

same

Neo42 avatar Jul 22 '19 07:07 Neo42

Same problem here

Bascy avatar Aug 22 '19 18:08 Bascy

I get this 'Write EPIPE' error as well after installing vscode-cudacpp extension (in addition to Clang-Format of course). Disabling vscode-cudacpp fixes the 'write EPIPE' issue for me (but then I have no context coloring other or support for *.cu files).

elbrandt avatar Sep 03 '19 21:09 elbrandt

+1

EXPLOR3R avatar Sep 12 '19 03:09 EXPLOR3R

Closing vscode completely and reopening it got rid of that error for me.

JakeHadley avatar Sep 13 '19 14:09 JakeHadley

Same here, with the same stacktrace as SourceZh posted Restarting vscode doesnt help

Bascy avatar Sep 18 '19 18:09 Bascy

I had to install LLVM from http://releases.llvm.org/download.html (for me Windows (64-bit)), after that formatting works. I had the same problem with "write EPIPE"

baststar avatar Oct 13 '19 14:10 baststar

@baststar thanks, works like a charm! I wonder why VSCode cannot provide more meaningful message here 🤔

okainov avatar Oct 15 '19 09:10 okainov

i don't think this issue is ready to be closed just yet, a workaround has been found, yes, but it's still an issue that people have to read through 15 messages in a github bugreport to find a workaround solution

divinity76 avatar Oct 15 '19 19:10 divinity76

Works after installing LLVM, but then deleting the clang-format.exe from the LLVM installation causes write EPIPE again. It appears to not be honouring the "clang-format.executable" setting (I have a custom build).

  ERR spawn C:\Program Files\LLVM\bin\clang-format.exe ENOENT: Error: spawn C:\Program Files\LLVM\bin\clang-format.exe ENOENT
	at Process.ChildProcess._handle.onexit (internal/child_process.js:264:19)
	at onErrorNT (internal/child_process.js:456:16)
	at processTicksAndRejections (internal/process/task_queues.js:84:9)

Clearly it should be attempting to spawn my clang-format.exe here, not the one in LLVM.

Edit: scratch that, it had added a default value to my workspace settings which was overriding my user settings.

LAK132 avatar Jan 06 '20 00:01 LAK132

@cyberman54 why did you close the issue? It's still valid and workaround doesn't mean the proper solution. Please keep it open util the proper fix is implemented.

okainov avatar Jan 08 '20 09:01 okainov

reopened as requested.

cyberman54 avatar Jan 08 '20 11:01 cyberman54

@LAK132 may have highlighted an important bit … In my case, it appeared to be adding a default workspace value (/absolute/path/to/clang-format) when first installed / run, rather than inheriting from the user setting (which I edited the settings.json for directly). Repeatedly editing the settings via UI (not directly the JSON) eventually allowed this to work for me, but I cannot explain why.

henrygab avatar Jan 08 '20 18:01 henrygab

+1

CarlosModinez avatar Jan 24 '20 01:01 CarlosModinez

In my case, after adding the absolute path to settings.json "write EPIPE" disappeared For example my settings.json: { "C_Cpp.intelliSenseEngine": "Default", "workbench.startupEditor": "newUntitledFile", "arduino.enableUSBDetection": true, "arduino.defaultBaudRate": 9600, "diffEditor.ignoreTrimWhitespace": false, "clang-format.executable": "c:/Users/%username%/.vscode/extensions/ms-vscode.cpptools-0.26.3/LLVM/bin/clang-format", "[cpp]": { "editor.defaultFormatter": "xaver.clang-format" } }

Markot77 avatar Feb 18 '20 07:02 Markot77

After a fresh install of VSC on a new computer i again ran into this issue. It's still not solved. I can confirm that the above stated workaround is functional:

I had to install LLVM from http://releases.llvm.org/download.html (for me Windows (64-bit)), after that formatting works. I had the same problem with "write EPIPE"

cyberman54 avatar Feb 25 '20 11:02 cyberman54

One possible reason is, the vsc and clang-format are installed under different privilege or user. The simple way to prove this is: execute clang-format in vsc's terminal. If error reports, it means you may run into permission issue and you have to run vsc as administrator.

axinging avatar Feb 26 '20 00:02 axinging

@cyberman54 -- can you update the title?

Recommended new title:

"User settings ignored, default value added to each workspace (Error write EPIPE)"

Does anyone know if someone is already leading the investigation on this?

Summary of findings:

I wrote:

In my case, it appeared to be adding a default workspace value (/absolute/path/to/clang-format) when first installed / run, rather than inheriting from the user setting (which I edited the settings.json for directly).

@LAK132 edited his post to say:

Edit: scratch that, it had added a default value to my workspace settings which was overriding my user settings.

@elbrandt earlier noted that this affects more than clang-format:

I get this 'Write EPIPE' error as well after installing vscode-cudacpp extension (in addition to Clang-Format of course). Disabling vscode-cudacpp fixes the 'write EPIPE' issue for me (but then I have no context coloring other or support for *.cu files).

@axinging -- All installs in my case were using the same user account, although clang may have been installed for all users (administrative permissions). Can you help me understand your statement below, as I am unsure how this might cause VSC to ignore user settings, and thus add default settings to each workspace?

One possible reason is, the vsc and clang-format are installed under different privilege or user. The simple way to prove this is: execute clang-format in vsc's terminal. If error reports, it means you may run into permission issue and you have to run vsc as administrator.

henrygab avatar Feb 26 '20 17:02 henrygab

@henrygab I think there are multiple issues here with different root cause. Current title is quite clear reflecting the quite common use case when people get this error when using clang-format. I personally don't really care about "user settings", the issue was in clang+vs code. Also see the most upvoted answer here which gives the right solution to install LLVM.

okainov avatar Feb 26 '20 20:02 okainov

@henrygab I think the best option moving forward would be to open a separate issue for the auto added default workspace settings. I've had a quick look and I think I might know what's causing it, but I haven't had a chance to fire it up in a debugger yet.

LAK132 avatar Feb 26 '20 20:02 LAK132

Hello everybody. I had that error in ubuntu. After i install format-clang. I fixed it by: open terminal, and install: sudo apt install clang-format hope that may usefully, thanks

tonganh avatar Mar 12 '20 12:03 tonganh

Thanks @tonganh !

rushabhdharia avatar Mar 30 '20 05:03 rushabhdharia

I also fixed it by adding the absolute path of clang-format.executable (on Windows).

Here are the step:

  • Ctrl+, to open the settings
  • Search for "clang-format executable path"
  • Put the absolute path the executable (something like C:/Users/%username%/.vscode/extensions/ms-vscode.cpptools-0.26.3/LLVM/bin/clang-format)

I believe it's because the clang-format command is not in the PATH 🤔.

It's said on the front page: https://github.com/xaverh/vscode-clang-format-provider

This extension will attempt to find clang-format on your PATH. Alternatively, the clang-format executable can be specified in your vscode settings.json file: [...]

hugoattal avatar May 01 '20 14:05 hugoattal

Solved on Windows by installing Clang: For 32-bit: Clang for Windows (32-bit) For 64-bit: Clang for Windows (64-bit) Checkout this tutorial for more details: https://www.codepool.biz/vscode-format-c-code-windows-linux.html

Otman404 avatar May 09 '20 01:05 Otman404