Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Windows Build Panel Eats Stdout #23

Closed
caleywoods opened this Issue April 12, 2012 · 27 comments

7 participants

Caley Woods Jamie Hoover ⚔ nefD Morgan Estes Juha Ruotsalainen Kenneth G. Franqueiro Chris2011
Caley Woods
[JSHint file: C:\Users\caley.woods\workspace\whiteboard\public\invoicer_module\js\lineItemCMS.js]
[Finished]

After you pushed the fix to close #22 I tried upgrading sublime-jshint and it still failed. I did a clean reinstall and now when pressing Ctrl+B I see what I pasted at the top of this. When running this particular file through node-jshint I receive some warnings about a semicolon on line#136 but I don't see any errors output here.

I also have a simple js test file I did that when ran through node-jshint tells me I'm using 'foo' twice, but the linter here doesn't show any warnings. I've pasted the sample JS file I was trying below:

function foo(foo, bar) {
    return true;
}
Jamie Hoover ⚔
Owner

Thanks for the detail. Sorry the last fix didn't get you up and running. I'll attempt to replicate this on a Windows VM tomorrow.

Caley Woods

Thanks for helping! Let me know if you need anymore details. I'm running on win7 x64 enterprise

nefD
nefD commented April 17, 2012

Also getting this issue, running SublimeText2 dev build 2195, Windows 7 x64. Was able to use this plugin successfully a month or two and absolutely adored it. Looking forward to using it again!

Also, not sure if this is relevant, but I never can get it installed via the Package Control plugin, so I'm just cloning the git repo into my packages directory.

Jamie Hoover ⚔
Owner

Sorry guys, I wasn't able to look at this until today. I should have an update soon.

Caley Woods

Let me know if you need screenshots or a paste of my PATH variable or anything else.

Jamie Hoover ⚔
Owner

I have reproduced the problem, but still banging my head against the desk after each failed attempt to figure out what is wrong. In the Sublime Text 2 console, I get:

Running jshint.cmd C:\Users\uipoet\Documents\foo.js --reporter "C:\Users\uininja\AppData\Roaming\Sublime Text 2\Packages\JSHint\reporter.js"

Which is correct. When I run the exact same thing in the Command Prompt application, I see the correct output.

Maybe the regular expressions for finding the file and line row/columns aren't working the same in Windows? Still investigating...

Jamie Hoover ⚔
Owner

Alas, I have determined this to be a bug in the Windows version of Sublime Text 2. The code is executing, but the output from JSHint is not making it to the build output window. Please follow along with me on the Sublime forum post about the issue.

Forum Post About this Bug

Caley Woods

Thank you a billion times over for spending your free time trying to figure this out. I do open source a lot so I know that it's often a thankless job, so... Thanks!

If you have some way that I could donate I would as a token of my appreciation. I'll be sure and follow the forum post. I don't use sublime on Mac (vim user) so I can't try it there or I'd be happy to!

Jamie Hoover ⚔
Owner

Kind words are thanks enough. :)

Caley Woods

@uipoet Is this JSHint doing this in ST2 or perhaps a function of Sublime Linter I already have installed?

linter

nefD
nefD commented April 18, 2012

I just did notice (not sure how I didn't notice this before) that if I Ctrl+B build a javascript file without using this JSHint plugin, it is using the JSL command line linter to proper parse and output results (even with the latest dev build), so surely it's possible..

Jamie Hoover ⚔
Owner

Caley, I installed clean versions of Node.js and Sublime Text 2 in a Windows 7 VM and was able to reproduce the problem. There is some difference in the way Node.js emits messages to stdout from inside of Sublime Text 2 that is being ignored in Windows. All works perfectly outside of Sublime Text 2. In fact, if I change to code to pipe the output to a file, I see the expected errors. The bug is with Sublime Text 2 ignoring the output from Node.js.

nefD, I installed via the Package Control plugin without issue. Not sure why you had to manually install.

If either of you see this issue corrected in the forums or find a solution yourselves, please let me know or submit a pull request. :)

Caley Woods

Jamie,

Can you create a branch or tell me what piece of code to modify in order pipe the output to a file? My thought for the time being is to pipe it to an HTML file and just leave it open and CTRL+B and then refresh the HTML page.

Jamie Hoover ⚔
Owner

Caley,

C:\Users\caley.woods\AppData\Roaming\Sublime Text 2\Packages\JSHint\JSHint.sublime-build

"windows": {
  "cmd": ["jshint \"${file}\" --reporter \"${packages}\\JSHint\\reporter.js\" > yourfile.txt"]
}

This should pipe the output to a file in the same directory as the file being run through JSHint. Opening the file automatically in Windows is beyond my knowledge. JSHint.sublime-build will be overridden after every push that I make, so you may want to fork the code, first.

Caley Woods

I think DOS supports opening it with the open command or just by calling the file name, I'll have to double check.

Edit

I double checked. it doesn't support the open command but you can open it just by calling the filename. It will use the system configured default to open the file, likely notepad for .txt and iexplore for HTML files (unless you've specifically configured your system otherwise.

As much as it pains me to admit it, I've been working on Windows machines since I was 12 (27 now) so perhaps my knowledge of it could be of use to you. Windows wouldn't be terrible if we could just get a good POSIX toolchain setup from the get go :(

So I believe in that file you talked about if you do:

"windows": {
  "cmd": ["jshint \"${file}\" --reporter \"${packages}\\JSHint\\reporter.js\" > yourfile.txt && yourfile.txt"]
}

yourfile.txt should open up in Notepad automagically for you. && works the same in DOS/Windows as it does in *nix/mac (in this case only opening the file if the dumping of stdout to yourfile.txt was successful). Also of note is that using > will recreate the file each time (or at least truncate the contents and replace it with the new STDOUT) versus using >> would append new results to the end of the file.

Jamie Hoover ⚔
Owner
uipoet commented May 03, 2012

Until the Sublime Text 2 for Windows bug is fixed, as @caleywoods points out, you can change the cmd line to get a temporary file created for manually viewing warnings/errors from jshint. The temporary file will be created in the same directory as the current file being checked by jshint:

"cmd": ["jshint.cmd", "$file", "--reporter", "$packages\\JSHint\\reporter.js", ">temp.txt"]

Sublime Text 2 does not run this command exactly as the shell would, so I couldn't figure out a way to at least have the file be automatically opened as suggested.

Morgan Estes

I'm not sure this is a ST2 bug. I built sublime-recess using your plugin as a starting point and it echos directly to the built-in console every time without fail. Perhaps it's an issue with how stdout is being called?

I'm learning as I go so I don't know enough to speak intelligently about the internals, but I'm working on putting all the pieces together to see where they diverge on output.

Morgan Estes

I noticed that the build window in ST2 has a different output than when I run the exact same command from the Windows command line.

It looks to me that when running the cmd within the build it doesn't display the results as per the reporter.js file dictates, but does things it's own way. I can't find yet where it's getting its instructions from for the output to the build window, but it's not the reporter file!

Jamie Hoover ⚔
Owner
uipoet commented May 03, 2012

When using jshint without the reporter, no output in the ST2 console. When passing no file to jshint, help information is output in the ST2 console. JSHint uses process.stdout.write() and for some unexplained reason is either ignored or instantly deleted from the ST2 console. Very rarely, I see the first line only of the output.

This chump is stumped. I continue to monitor: http://www.sublimetext.com/forum/viewtopic.php?f=3&t=5375&p=29414#p29414 but I'm not holding my breath, since it was reported back in February and has yet to be addressed.

Morgan Estes

One thing I figured out this morning is that even if --reporter is specified, node-jshint doesn't use it -- it keeps going back to its default reporter.

I've confirmed this by specifying the path to your custom reporter, then modifying the default jshint reporter in %appdata%\npm\node_modules\jshint\lib\reporters\default.js to append my own text to the str variable. Even with the reporter specified in the build command, jshint still used the default reporter.

I'd say this is an issue with node-jshint not handling the path correctly (see https://github.com/jshint/node-jshint/blob/master/lib/cli.js#L94) when it's outside the npm path.

There still may be a fix available, but for now I'd say either install node-jshint locally in your project folder where you keep your .js files, or overwrite node-jshint's default.js with the contents of your reporter.js.

Jamie Hoover ⚔
Owner
uipoet commented May 07, 2012

Having node-jshint installed locally makes no difference for me. The reporter is working, because I can pipe the output to a file and see the correct output. It's just not being shown in Sublime Text 2. ...Packages/Default/exec.py isn't passing the output from jshint is my guess. But I'm not familiar enough with Python to be sure.

Jamie Hoover ⚔ uipoet referenced this issue from a commit May 11, 2012
MacPorts Support
Adds default MacPorts path to build. Updates README accordingly.

Updates README to disclose issue #23, hopefully preventing more redundant issues being created.
845bb15
Tom Gasson tomgasson referenced this issue from a commit in tomgasson/sublime-jshint July 16, 2012
Tom Gasson windows workaround for #23
Only the first stdout message makes it to the build results, so we
buffer all the console.logs and print them at once with
process.stdout.write
254daa1
Sam Hauglustaine smhg referenced this issue in darrenderidder/Sublime-JSLint September 24, 2012
Closed

No output with exit code=1 #4

Juha Ruotsalainen

This is so dumb...

Have you started Sublime via the start menu or from the command line?

See: http://stackoverflow.com/questions/10438508/error6-while-trying-to-use-sublime-text-to-msbuild

I just did some quick tests, and it really seems that if I start Sublime from command line, none of the builders work, all report Error 6 handle is invalid. But if I start Sublime from menu, it works.

Please note that I'm using PowerShell, and there I can successfully start a 'JSHint enabled' Sublime by using Start-Process cmdlet, i.e. "start sublime_text ....."

Jamie Hoover ⚔ uipoet closed this April 12, 2013
Jamie Hoover ⚔
Owner

Just released a new version that makes better use of standard console logging via Node.js.

Kenneth G. Franqueiro

Is this supposed to work on Windows at this point? When I installed this package just yesterday it still seemed to be showing only the first error in the build report. It seems like #31 attempted to fix this in the past, but that code has since been clobbered?

FWIW it seems totally possible to get this working just fine across OSes using the default jshint reporter, although the output isn't as concise: kfranqueiro/sublime-jshint@8a871b8

Jamie Hoover ⚔
Owner

Thank you @kfranqueiro for pointing out this regression. I have reimplemented buffering the output to a single console.log call, since multiple ones are ignored in Windows for some reason.

Chris2011

So I have the same Problem when I use a grunt build, I only see this output inside of sublime text 2:
Running "tslint:files" (tslint) task
[Finished in 1.1s]

But when I invoke grunt inside my command line of windows, I can see the errors from tslint. Is there an option which I have forgotten or is this a "bug" under windows?

Chris2011

Anything new about that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.