Skip to content
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

GroovyLint: Unable to start CodeNarc Server [MacOS] #16

Closed
yuvmel opened this issue Apr 6, 2020 · 18 comments · Fixed by nvuillam/npm-groovy-lint#22
Closed

GroovyLint: Unable to start CodeNarc Server [MacOS] #16

yuvmel opened this issue Apr 6, 2020 · 18 comments · Fixed by nvuillam/npm-groovy-lint#22
Assignees

Comments

@yuvmel
Copy link

yuvmel commented Apr 6, 2020

Hi, using version 0.6.3 on MacOS 10.15.4 with the following tool versions:

  • nodejs 12.16.1
  • java adopt-openjdk-11.0.6+10
  • groovy apache-groovy-binary-3.0.2

I'm getting this output message right after starting to lint:

GroovyLint: Unable to start CodeNarc Server. Use --noserver if you do not even want to try

I'd like to make it work please (and see if it may improve the linting & formatting performance...) - could you please help?

Thanks for publishing this promising extension! It'd be great if you could list all the required dependencies before installation please :)

@nvuillam
Copy link
Owner

nvuillam commented Apr 6, 2020

I never had anything Apple in my life... sorry i've not tested on it, but I can try to add Mac on the CircleCi job ^^
Your minimal requirements seems quite ok... maybe it's platform related ...

I think the issue is related to the CLI package npm-groovy-lint, which is embedded in the extension

Please could you clone https://github.com/nvuillam/npm-groovy-lint then run

  • npm install
  • npm run test

Then send me the log ?

Thanks !

It'd be great if you could list all the required dependencies before installation please :)

Just node >12 is necessary, as the runner embed jdeploy, who installs java if it is missing, and a few groovy release jars , so Groovy doesn't even needs to be installed :)

@yuvmel
Copy link
Author

yuvmel commented Apr 6, 2020

EDIT: Original log seems a short summary - I now ran npm run test > test.out 2>&1 & attached
test.out.zip

2020-04-06T20_50_44_054Z-debug.log

Log is attached, thanks for checking this!
Maybe its indeed a Mac thing (got it from work), but I learned the hard way (via vscode output pane) that I had to install node, then java (Mac has stub binaries that popup a message to install a tool, e.g. java) & finally groovy, to solve #6 :)

@nvuillam
Copy link
Owner

nvuillam commented Apr 6, 2020

I apologize, I forgot that when you use npm-groovy-lint locally, you need to build the jdeploy bundle to be able to run it.

The good order is :

  • npm install jdeploy -g (required for build)
  • npm install
  • npm run build
  • npm run test

Please can you try again ?

Your test.out.zip should contain what i need to investigate (else tomorrow i'll borrow my girlfriend's macbook 😁 )

Note: I updated contribute instructions thanks to your remarks :)
https://github.com/nvuillam/npm-groovy-lint/blob/master/CONTRIBUTING.md

@yuvmel
Copy link
Author

yuvmel commented Apr 7, 2020

Thanks! I ran the following now:

npm install jdeploy -g
npm install
npm run build
npm run test 2>&1 | tee test2.out
zip -j test2 test2.out ~/.npm/_logs/2020-04-07T05_50_07_489Z-debug.log

And attached: test2.zip 🙏

@yuvmel yuvmel changed the title GroovyLint: Unable to start CodeNarc Server. GroovyLint: Unable to start CodeNarc Server [MacOS] Apr 7, 2020
@nvuillam
Copy link
Owner

nvuillam commented Apr 7, 2020

Ok, so the good news is that most of the tests are passing

65 passing (7m)
14 failing

The bad news is that there is an execution error because of some permissions issue, and i know few about permission issues on MAC 😨

     Error: Command failed: npm-groovy-lint --path "jdeploy-bundle/lib/example" --files 
**/SampleFileSmall.groovy --loglevel warning --verbose
/bin/sh: /Users/yuval.melamed/.asdf/installs/nodejs/12.16.1/.npm/bin/npm-groovy-lint: Permission denied

Can you try to add exec rights and try again ?
chmod +x /Users/yuval.melamed/.asdf/installs/nodejs/12.16.1/.npm/bin/npm-groovy-lint

or if the previous line did not work:
chmod 755 /Users/yuval.melamed/.asdf/installs/nodejs/12.16.1/.npm/bin/npm-groovy-lint

I'll get my girlfriend's macbook today to try to reproduce

@yuvmel
Copy link
Author

yuvmel commented Apr 7, 2020

After chmod 755 ... things improved:

75 passing (7m)
4 failing

test3.zip
Perhaps the permission issue has to do with installing the npm package globally?
Could it work locally? Thanks! I appreciate your efforts :)

@nvuillam
Copy link
Owner

nvuillam commented Apr 7, 2020

Thanks! I appreciate your efforts :)

The thanks are for you, I really appreciate your time so the package can run on every platform :)

I tried to build my first mac based CircleCI build, but it's not available on free plan :'(
I tried a little fix, can u check out branch https://github.com/nvuillam/npm-groovy-lint/tree/FixRunOnMacOs and see if it works better ?

@yuvmel
Copy link
Author

yuvmel commented Apr 7, 2020

Thanks, at first it was down to 68 passing, but another chmod made it 78:
test4.zip

@nvuillam
Copy link
Owner

nvuillam commented Apr 7, 2020

Ok, that means that with your config, the CodeNarc Server can not be launched, but direct call to CodeNarc class is working ( but as it loads all jars at each call, it must be dramatically slow )

To avoid that, I use a tiny httpServer ( https://github.com/nvuillam/npm-groovy-lint/blob/master/groovy/src/main/com/nvuillam/CodeNarcServer.groovy ) so jars remain loaded, and only the first call has bad performances

I detected the same issue with Linux on CircleCI builds , so there is some permission to manage somewhere for Linux & Mac ...

What if you try npm run groovy:run-server-from-source ?

@yuvmel
Copy link
Author

yuvmel commented Apr 7, 2020

npm run groovy:run-server-from-source 2>&1 | tee test5.out failed - attaching:
test5.zip
LMK if I ran it out of context...
And indeed, the linting in VS is currently quite slow (8-20s).

@nvuillam
Copy link
Owner

nvuillam commented Apr 7, 2020

image
Ok... so it seems that i just can't run CodeNarcServer.groovy on Linux/Mac , compiled or not, because it doesn't find class org.codenarc.CodeNarc, whereas it is clearly in the classpath of the call...
( lib/CodeNarc-1.5.jar )

Do you have any clue about why ? :/
It works like a charm on Windows :'(

linting in VS is currently quite slow (8-20s).

If we succeed to run CodeNarcServer, it will be much less, all the time spent is in java - groovy startup

@yuvmel
Copy link
Author

yuvmel commented Apr 7, 2020

Yes, it seems like a known Linux/macOS (aka OSX) issue - found these issues now:
CodeNarc/CodeNarc#159
CodeNarc/CodeNarc#187
It might be related to a wrong delimiter in class path - ; vs. :?
Also, might worth mentioning, I noticed here: https://github.com/CodeNarc/CodeNarc
That it mentions some dependency in class path:

CodeNarc requires

Groovy version 2.1 or later
The SLF4J api/implementation jars, accessible on the CLASSPATH.
The GMetrics jar, version 1.0 or later -- optional if using some of the size/complexity rules.

I haven't installed the last 2 - should I?

@nvuillam
Copy link
Owner

nvuillam commented Apr 7, 2020

The related JARS are all embedded, no need to do more than npm install npm-groovy-lint -g :)
That''s why it's supposed to work .... ^^
I'm about to try on my Raspberry Pi, i'm pretty confident that if I solve the CodeNarcServer issue for Linux, it will also solve for mac :)

@nvuillam nvuillam self-assigned this Apr 7, 2020
nvuillam added a commit to nvuillam/npm-groovy-lint that referenced this issue Apr 8, 2020
Fix nvuillam/vscode-groovy-lint#16
- CodeNarcServer: use default InetSocketAddress instead of netAddress.localHost loopback value
- CodeNarcServer: use multi-thread instead of single thread
- Include Class-Path in MANIFEST instead of -cp argument
- Fix jar compilation folder error
- Activate KillServer test
@nvuillam
Copy link
Owner

nvuillam commented Apr 8, 2020

Just released v0.7.0 containing npm-groovy-lint v4.0.0 :)

@nvuillam
Copy link
Owner

nvuillam commented Apr 8, 2020

I also added Lint folder command :) #17

The issue was mainly on the jar generation of CodeNarcServer and local ip adddress used by it ...

@yuvmel please can you test on your mac and reopen the issue if the problem is still here ? 😍

@yuvmel
Copy link
Author

yuvmel commented Apr 9, 2020

Thank you so much for this quick fix! There's still something left - resembles #6 - LMK if we should continue there:

Start linting file:///XXX/Jenkinsfile
GroovyLint: Started CodeNarc Server after 1 attempts
Completed linting file:///XXX/Jenkinsfile in 10831 ms
[Error - 7:56:11 AM] Request textDocument/codeAction failed.
  Message: Request textDocument/codeAction failed with message: Cannot read property 'split' of undefined
  Code: -32603 
[Error - 8:04:31 AM] Request textDocument/codeAction failed.
  Message: Request textDocument/codeAction failed with message: Cannot read property 'split' of undefined
  Code: -32603 
[Error - 8:04:33 AM] Request textDocument/codeAction failed.
  Message: Request textDocument/codeAction failed with message: Cannot read property 'split' of undefined
  Code: -32603 

EDIT: (Only) the last error seems to repeat after visiting the file again (without changes - no new linting), if it may help you pinpoint the issue ;-)

@nvuillam
Copy link
Owner

nvuillam commented Apr 9, 2020

I created a new issue with your description :)

I'll try to see how we can activate debug logs so we can have more complete info to investigate :)

@nvuillam
Copy link
Owner

nvuillam commented Apr 9, 2020

@yuvmel I posted for you on #18 , please can you have a look ? ( can't highlight you there as u didn't comment the new issue yet )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants