[Errno 32] Broken pipe
On windows, I get what I think is a python error, when trying to format a file. Not sure where it breaks...
What happens when this occurs? Does a popup with the error occur? If you open the sublime console, is there an error in there? Does "Not sure where it breaks" mean there is no stack trace as well?
+1 Errno 32 Broken pipe. ( Windows 10 TP, last buid and last nodejs) Sublime console stack :
Using node.js path on 'windows': C:/Program Files/nodejs/node.exe
Using jscs path on 'windows': C:/Program Files/nodejs/jscs
Unexpected error(<class 'BrokenPipeError'>): [Errno 32] Broken pipe
error: [Errno 32] Broken pipe
Using node.js path on 'windows': C:/Program Files/nodejs/node.exe
Using jscs path on 'windows': C:/Program Files/nodejs/jscs
Unexpected error(<class 'BrokenPipeError'>): [Errno 32] Broken pipe
error: [Errno 32] Broken pipe
I was having this error too.
If I remove node_path from JSCS-Formatter.py and set jscs_path.windows in settings file to %APPDATA%/npm/jscs everything works as expected.
I'm on Windows 7 x64, Node v0.12.2 and JSCS 1.12.0
Thanks a lot @lcdsantos! This worked for me, but I have to set my windows path differently: { "jscs_path": { "windows": "c:/Users/Robin Schmitz/AppData/Roaming/npm/jscs" } } If I'm using "%APPDATA%/npm/jscs" sublime throws an error: cmd "c:/Users/Robin" could not be found. This seems to be because of the space in my username...
I tried setting just to "jscs" and it still works. Since I have jscs installed globally.
Why this isn't the default?
@lcdsantos I tried { "node_path": { "windows": "node.exe" }, "jscs_path": { "windows": "jscs" } } and it works perfectly. GitGutter's default value for binaries is also PATH: { // Custom path to git binary when not in PATH "git_binary": "" } Maybe this should be applied here too.
Interesting. I'm curious if this is currently working for anyone on windows without modification that would be broken by changing the defaults to "node.exe" and "jscs"
The amount of variation in the install locations makes me a bit uneasy with trying to provide a sane default (though the list of install locations is likely finite).
On node v0.12, trying to use the default node_path with just jscs threw an error; will retry to confirm.
Is all the Node stuff really necessary? Can't jscs figure this out by itself? Maybe I'm missing something here...
@mrjoelkemp I didn't change node_path option, just the jscs_path one
Related to #12 in that a better executable path solution is needed for Windows.
None of these options worked for me (WIndows 7 - 64bits) =/
reloading Packages/User/JSCS-Formatter.sublime-settings Using node.js path on 'windows': node.exe Using jscs path on 'windows': jscs Unexpected error(<class 'BrokenPipeError'>): [Errno 32] Broken pipe error: [Errno 32] Broken pipe
reloading Packages/User/JSCS-Formatter.sublime-settings Using node.js path on 'windows': node.exe Using jscs path on 'windows': %APPDATA%/npm/node_modules/jscs Unexpected error(<class 'BrokenPipeError'>): [Errno 32] Broken pipe error: [Errno 32] Broken pipe
@lnfnunes Have you tried making the node path be an empty string? It seems like that has worked for some others.
@TheSavior Tried right now and didn't work! Curiously, this error only occurs when executing from "command palette", when using shortcut key (ctrl+shift+h) it works fine!
reloading Packages/User/JSCS-Formatter.sublime-settings Using node.js path on 'windows': Using jscs path on 'windows': %APPDATA%/npm/node_modules/jscs Unexpected error(<class 'BrokenPipeError'>): [Errno 32] Broken pipe error: [Errno 32] Broken pipe
Should be resolved by #22. Please let me know if this comes up again.
This worked for me. Windows server 2012 r2 using nvm.
{
"jscs_path": {
"windows": "C:/Program Files/nodejs/node_modules/jscs/bin/jscs"
},
"node_path": {
"windows": "node"
}
}
I'm not sure if I have a default installation, but currently I'm using
"windows": "c:/Users/Robin Schmitz/AppData/Roaming/npm/node_modules/jscs/bin/jscs"
The package config is throwing errors with "windows": "%APPDATA%/npm/node_modules/jscs/bin/jscs":
Error message
Using jscs path on 'windows': %APPDATA%/npm/node_modules/jscs/bin/jscs Unexpected error(<class 'Exception'>): Error: module.js:338
throw err;
^
Error: Cannot find module 'C:\Users\Robin'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3
error: Error: module.js:338
throw err;
^
Error: Cannot find module 'C:\Users\Robin'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3
``
Looks like space between the username ("Robin Schmitz") is causing the issue! Error: Cannot find module 'C:\Users\Robin' instead of 'C:\Users\Robin Schmitz'...
@lnfnunes Yes, this must be the reason. @TheSavior Would you please look at this issue again?
Can't you just escape the space with a backslash in your setting override? On May 7, 2015 2:59 AM, "rs3d" [email protected] wrote:
@lnfnunes https://github.com/lnfnunes Yes, this must be the reason. @TheSavior https://github.com/TheSavior Would you please look at this issue again?
— Reply to this email directly or view it on GitHub https://github.com/TheSavior/SublimeJSCSFormatter/issues/14#issuecomment-99749862 .
@mrjoelkemp My settings with spaces are working. Unfortunately the package default config with %APPDATA%, which includes my username, doesn't work.
I don't believe we do any resolution of %APPDATA% at the plugin level.
We could (as part of the plugin post-install maybe?) shell out to resolve %APPDATA% and then escape the spaces in the username. Not sure that the entire username would be returned to us though.
Would you like to try this out in a PR? We could use the help with Windows environments. On May 7, 2015 7:41 AM, "rs3d" [email protected] wrote:
@mrjoelkemp https://github.com/mrjoelkemp My settings with spaces are working. Unfortunately the package default config with %APPDATA%, which includes my username, doesn't work.
— Reply to this email directly or view it on GitHub https://github.com/TheSavior/SublimeJSCSFormatter/issues/14#issuecomment-99829346 .
@mrjoelkemp I'm sorry, but i have no idea about package development and python, but I'm trying to investigate this issue a little bit more.
Might it be, that %APPDATA% consists of backslashes so that the config mixed with forward slashes produces the problem? Sublime-JSHint for an example explains for windows not to use backslashes: https://github.com/victorporof/Sublime-JSHint/blob/master/README.md#oh-noez-command-not-found This could also be a hint: http://stackoverflow.com/a/23520403/2496469
I'm also not sure why node.exe doesn't need a full path but jscs when both are globally installed.
What happens if you try "windows": "\"%APPDATA%/npm/node_modules/jscs/bin/jscs\""
Sublime console outputs: Unexpected error(<class 'BrokenPipeError'>): [Errno 32] Broken pipe error: [Errno 32] Broken pipe
When I execute the cmd "%APPDATA%/npm/node_modules/jscs/bin/jscs" directly, windows is saying that the command ""C:\Users\Robin Schmitz\AppData\Roaming/npm/node_modules/jscs/bin/js cs"" can't be found/or is wrongly typed.
I think that's not the only reason why we get this error. I've traced it back to the get_output python function which utilizes Popen to pipe in the text from the file we are trying to format. The file I tried this with is 1000+ lines long and it just throws this unexplained error, if I truncate the file to less than 125 lines it seems to work.
Currently it's complaining about a lack of a config file, but I'm pretty sure that's not the problem. Could that method be changed to use another more robust library to handle longer strings ?
The functionality for checking for configs is handled by jscs itself. If the problem is this popen stuff, I'd be super happy to see a failing test and fix. I don't have much experience in Python file related stuff.
Actually, I continued testing it out and I figured out it is related to the IS_WINDOWS variable that gets set in the beginning. I am on a windows machine, so it's detecting it as True, but then my files are actually located on a Linux VM and do have LF endings.
So if I change line 143 in JSCS-Formatter.py p = Popen(cmd,stdout=PIPE, stdin=PIPE, stderr=PIPE, cwd=cdir, shell=IS_WINDOWS) to p = Popen(cmd,stdout=PIPE, stdin=PIPE, stderr=PIPE, cwd=cdir, shell=False) it starts to work with any file I give to it.
Now the really weird part, as I was changing around the shell value, it now started working with it being true or false although I didn't change any paths for node or jscs in the config file. So again, stumped on why it was happening and why it's not now. I don't even have a windows username that contains spaces, like some of the other people above. I'll investigate further and report if it starts happening again.
@sylido Is the issue you are having the exact issue that this ticket was opened for? If so, I'll reopen this. Otherwise, we should probably move this to another ticket.
Yes, it is the exact same issue - Broken Pipe 32, but the cause of it seems to be different ?