ditinc / linter-cflint

:shirt: CFLint plugin for Atom Linter
MIT License
4 stars 7 forks source link

Unexpected error #24

Open jinglesthula opened 7 years ago

jinglesthula commented 7 years ago

I just updated to the latest and when I enable the package I get an Atom notification that says:

"An unexpected error occured with linter-cflint. See the debug log for details."

I googled a while to see if I could find where either Atom or this package stored log files, as well as browsed through .atom and the linter-cflint package directory therein but couldn't spot anything that looked like a log file.

If anyone knows how to locate the relevant log file I'll add more info to add any additional details. At this point it's obviously not even clear if it's an Atom issue or a package issue.

ryaneberly commented 7 years ago

The latest linter-cflint, or do you mean CFLint 1.1.0?

jinglesthula commented 7 years ago

Sorry - the linter-cflint package itself

sjmatta commented 7 years ago

View -> Developer -> Toggle Developer Tools should bring up the console and show you the logs.

Are your atom-linter and related package up to date?

jinglesthula commented 7 years ago

Yes, all Atom packages (core and 3rd-party) are up to date. I cracked open the console and see "Error: not found: javac.exe" from main.js:149, leading me to believe it's my Java Path in the package settings. I've tried all the following to no effect (after making sure each file exists on my system at that path):

C:\Program Files\Java\jdk1.7.0_17\bin\java.exe C:\Program Files\Java\jdk1.7.0_17\bin\javac.exe C:\Program Files\Java\jdk1.7.0_17\jre\lib\rt.jar (this one from a recommendation I googled)

All 3 produce the same error on the console.

It's looking more like a personal problem related to configuration than a problem with the package. If anyone else thinks so, I'm good with closing this issue. (And if you can point me in the right direction on the Java Path setting, I'd be obliged 👍 ).

KamasamaK commented 7 years ago

That's a strange error since main.js doesn't even have 149 lines. Also, I'm not sure why it would be trying to use javac.exe as the package doesn't compile any Java code.

KamasamaK commented 6 years ago

So it looks like the reason it was looking for javac.exe is because that is what find-java-home does by default. You can set the option allowJre: true to have it use java.exe instead, which I would recommend doing since CFLint does not require the JDK to run.

jinglesthula commented 6 years ago

I'm just now getting back to trying this out. Where would I set allowJre: true? I tried putting a .cflintrc file in my project root with { "allowJre: true } and restarted Atom but still get the same error. On the linter-cflint package settings page there are only options for the Config File and the Java Path.

smidgen commented 6 years ago

Had the same error, couldn't get CFLint working without a long in-depth debug session. Eventually I fixed it by replacing lib/main.js line 91:

let { javaPath, configFile } = this;

with this:

let javaPath   = atom.config.get('linter-cflint.javaPath')
   ,configFile = atom.config.get('linter-cflint.configFile');

Not being familiar with Atom plugin development, I am not sure if this is the best solution, but I can say that there's definitely a variable scope bug in that line. My fix allows the linter-cflint plugin to actually read and use the Java Path setting I entered in the Atom Settings tab.

I set the following value for (Ctrl+, -> Packages -> linter-cflint -> Settings -> Java Path / Path to Java 7+ executable (JRE or JDK)): C:/Program Files/Java/jre1.8.0_181/bin/java.exe

Edit: Running Windows 10 with Atom 1.31.2 x64 and linter-cflint 0.15.0.

jinglesthula commented 5 years ago

I was able to get it working eventually. I believe I had to go install the jdk, then (because I'm on Windows this is how I did it - other OS's follow your own methods of setting env vars) set JAVA_HOME env variable to C:\Program Files\Java\jdk1.7.0_17 in Control Panel > System > Advanced settings.

I kind of forgot that I got it working, but hopefully that helps someone. I did notice when I got it running that it slowed my machine to a crawl, so I had to disable it.

Danver97 commented 5 years ago

Followed what @jinglesthula did but I got this:

[exec] Process exited with no-zero code, stdout:  
(anonymous) @ C:\Users\christian\.atom\packages\linter-cflint\node_modules\sb-exec\lib\index.js:59
Error: Process exited with non-zero code: 1
    at ChildProcess.<anonymous> (C:\Users\christian\.atom\packages\linter-cflint\node_modules\sb-exec\lib\index.js:60)
    at emitTwo (events.js:126)
    at ChildProcess.emit (events.js:214)
    at maybeClose (internal/child_process.js:925)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:209)

Do you have the .cflintrc file with { "allowJre: true } in the project folder?