2
votes

I'm running the interactive Groovy Shell and it's literally taking minutes to start on my machine (a Windows 7 laptop with an Intel i5 processor and 4 GB of RAM so not an ancient computer, just a middle of the road one)

Running simple scripts using groovy or groovyclient and groovyserver takes an acceptable amount of time (several seconds tops) but after running groovysh the cursor just starts blinking for... long enough for me to make tea, write this very question and rant about this on Twitter (and still no prompt to write any code)

Tried this with the following configurations

  • Groovy Version: 2.3.4 JVM: 1.7.0_03 Vendor: Oracle Corporation OS: Windows 7
  • Groovy Version: 2.3.4 JVM: 1.8.0_20 Vendor: Oracle Corporation OS: Windows 7

and it's exactly the same.

I'd really like to be able to use it in a REPL style. Has anyone faced and solved similar problems? Can you recommend a different tool for the job?

As suggested in the comments, I ran groovysh -d -v to enable debug and verbose output, in hope of seeing what takes such a long time.

Output of groovysh -d -v

DEBUG [org.codehaus.groovy.tools.shell.BufferManager] Created new buffer with index: 0
DEBUG [org.codehaus.groovy.tools.shell.BufferManager] Buffers reset
DEBUG [org.codehaus.groovy.tools.shell.Parser] Using parser flavor: rigid
DEBUG [org.codehaus.groovy.tools.shell.CommandRegistry] Registered command: ?
DEBUG [org.codehaus.groovy.tools.shell.CommandRegistry] Registered command: :help
DEBUG [org.codehaus.groovy.tools.shell.CommandRegistry] Registered command: :quit
DEBUG [org.codehaus.groovy.tools.shell.CommandRegistry] Registered command: :exit
DEBUG [org.codehaus.groovy.tools.shell.CommandRegistry] Registered command: import
DEBUG [org.codehaus.groovy.tools.shell.CommandRegistry] Registered command: :display
DEBUG [org.codehaus.groovy.tools.shell.CommandRegistry] Registered command: :clear
DEBUG [org.codehaus.groovy.tools.shell.CommandRegistry] Registered command: :show
DEBUG [org.codehaus.groovy.tools.shell.CommandRegistry] Registered command: :inspect
DEBUG [org.codehaus.groovy.tools.shell.CommandRegistry] Registered command: :purge
DEBUG [org.codehaus.groovy.tools.shell.CommandRegistry] Registered command: :edit
DEBUG [org.codehaus.groovy.tools.shell.CommandRegistry] Registered command: .
DEBUG [org.codehaus.groovy.tools.shell.CommandRegistry] Registered command: :load
DEBUG [org.codehaus.groovy.tools.shell.CommandRegistry] Registered command: :save
DEBUG [org.codehaus.groovy.tools.shell.CommandRegistry] Registered command: :record
DEBUG [org.codehaus.groovy.tools.shell.CommandRegistry] Registered command: :history
DEBUG [org.codehaus.groovy.tools.shell.CommandRegistry] Registered command: :alias
DEBUG [org.codehaus.groovy.tools.shell.CommandRegistry] Registered command: :set
DEBUG [org.codehaus.groovy.tools.shell.CommandRegistry] Registered command: :register
DEBUG [org.codehaus.groovy.tools.shell.CommandRegistry] Registered command: :doc

For a very long time, no further output and then the whole rest in a matter of seconds:

DEBUG [org.codehaus.groovy.tools.shell.Groovysh] Terminal (jline.AnsiWindowsTerminal@66f57048)
DEBUG [org.codehaus.groovy.tools.shell.Groovysh]     Supported:  true
DEBUG [org.codehaus.groovy.tools.shell.Groovysh]     ECHO:       (enabled: false)
DEBUG [org.codehaus.groovy.tools.shell.Groovysh]     H x W:      41 x 169
DEBUG [org.codehaus.groovy.tools.shell.Groovysh]     ANSI:       true
DEBUG [org.codehaus.groovy.tools.shell.Groovysh]     Direct:     true
DEBUG [org.codehaus.groovy.tools.shell.InteractiveShellRunner] Using history file: C:\Users\Tomek\.groovy\groovysh.history
Groovy Shell (2.3.4, JVM: 1.8.0_20)
Type ':help' or ':h' for help.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 
DEBUG [org.codehaus.groovy.tools.shell.CommandsMultiCompleter] Added completer[1] for command: :help
DEBUG [org.codehaus.groovy.tools.shell.CommandsMultiCompleter] Added completer[2] for command: ?
DEBUG [org.codehaus.groovy.tools.shell.CommandsMultiCompleter] Added completer[3] for command: :exit
DEBUG [org.codehaus.groovy.tools.shell.CommandsMultiCompleter] Added completer[4] for command: :quit
DEBUG [org.codehaus.groovy.tools.shell.CommandsMultiCompleter] Added completer[5] for command: import
DEBUG [org.codehaus.groovy.tools.shell.CommandsMultiCompleter] Added completer[6] for command: :display
DEBUG [org.codehaus.groovy.tools.shell.CommandsMultiCompleter] Added completer[7] for command: :clear
DEBUG [org.codehaus.groovy.tools.shell.CommandsMultiCompleter] Added completer[8] for command: :show
DEBUG [org.codehaus.groovy.tools.shell.CommandsMultiCompleter] Added completer[9] for command: :inspect
DEBUG [org.codehaus.groovy.tools.shell.CommandsMultiCompleter] Added completer[10] for command: :purge
DEBUG [org.codehaus.groovy.tools.shell.CommandsMultiCompleter] Added completer[11] for command: :edit
DEBUG [org.codehaus.groovy.tools.shell.CommandsMultiCompleter] Added completer[12] for command: :load
DEBUG [org.codehaus.groovy.tools.shell.CommandsMultiCompleter] Added completer[13] for command: .
DEBUG [org.codehaus.groovy.tools.shell.CommandsMultiCompleter] Added completer[14] for command: :save
DEBUG [org.codehaus.groovy.tools.shell.CommandsMultiCompleter] Added completer[15] for command: :record
DEBUG [org.codehaus.groovy.tools.shell.CommandsMultiCompleter] Added completer[16] for command: :history
DEBUG [org.codehaus.groovy.tools.shell.CommandsMultiCompleter] Added completer[17] for command: :alias
DEBUG [org.codehaus.groovy.tools.shell.CommandsMultiCompleter] Added completer[18] for command: :set
DEBUG [org.codehaus.groovy.tools.shell.CommandsMultiCompleter] Added completer[19] for command: :register
DEBUG [org.codehaus.groovy.tools.shell.CommandsMultiCompleter] Added completer[20] for command: :doc
DEBUG [org.codehaus.groovy.tools.shell.CommandsMultiCompleter] Refreshing the completer list
DEBUG [org.codehaus.groovy.tools.shell.InteractiveShellRunner] Running
groovy:000>
2
is starting with -vd giving any clues? - cfrick
Running groovysh -vd results in the following error: "Unrecognized option: -vd error: jvm creation failed with code -1: unknown error" - toniedzwiedz
just -d? check the help. maybe its /d or some other windowizm - cfrick
@cfrick updated with the output, running with -d -v now, I'll post the output if it's different in any meaningful way. - toniedzwiedz

2 Answers

1
votes

It could be memory, ensure that no java apps are running first (Java performs horribly when 2 java apps are fighting for memory in windows--it's a total system killer), but if that were the case I'd think groovy would load slowly too.

Another possibility is that your system may be having trouble loading the JLine dll. To test for this try:

Groovysh --terminal=false

It will avoid loading JLine-- without JLine you won't get up/down/tab processing so you don't want to run that way, but if you know that this is your problem you should easily be able to find something online telling you how to fix it.

1
votes

After 7 years ... well, here's another suggestion for an answer. I had a similar issue and investigated to find that on startup, groovysh attempts to resolve classes by calling PackageHelperImpl. The problem here is that it recursively scans all the subdirectory. So, one reason for groovysh to be extremely slow to start up is that you have a huge file hierarchy underneath the location where you tried to start it. To test this, try starting it exactly the same but in a folder with no child directories.