provegard / ncdbg

A debugger for Nashorn that uses Chrome DevTools as frontend
BSD 3-Clause "New" or "Revised" License
31 stars 5 forks source link

Startup script at bin/ncdbg fails when 'sh' is dash (Debian, Ubuntu, Linux Mint) #97

Closed davidpcaldwell closed 6 years ago

davidpcaldwell commented 6 years ago

This is with the 0.8.0 build -- I don't have an installation process that uses gradle / master yet.

Error message:

/home/inonit/src/inonit/slime/trunk/slime/local/jsh/lib/ncdbg/bin/ncdbg: 67: /home/inonit/src/inonit/slime/trunk/slime/local/jsh/lib/ncdbg/bin/ncdbg: Bad substitution`

Substituting ${JAVA_HOME} for the expression fixes the problem. Alternatively, a different shell, or way of detecting the shell, could be specified.

My system:

$ dpkg -S /bin/sh
diversion by dash from: /bin/sh
diversion by dash to: /bin/sh.distrib
dash: /bin/sh

and

$ dpkg -s dash
Package: dash
Essential: yes
Status: install ok installed
Priority: required
Section: shells
Installed-Size: 228
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Architecture: amd64
Version: 0.5.7-4ubuntu1
Depends: debianutils (>= 2.15), dpkg (>= 1.15.0)
Pre-Depends: libc6 (>= 2.14)
Description: POSIX-compliant shell
 The Debian Almquist Shell (dash) is a POSIX-compliant shell derived
 from ash.
 .                                                                                                                                  
 Since it executes scripts faster than bash, and has fewer library                                                                  
 dependencies (making it more robust against software or hardware                                                                   
 failures), it is used as the default system shell on Debian systems.                                                               
Homepage: http://gondor.apana.org.au/~herbert/dash/                                                                                 
Original-Maintainer: Gerrit Pape <pape@smarden.org>                                                                                 
provegard commented 6 years ago

I'll take a look. However, the startup script comes from Gradle, so I'm not sure what I can do. Maybe related: https://github.com/gradle/gradle/issues/4926

That said, I already patch the startup script wrt tools.jar, so perhaps there's a workaround.

provegard commented 6 years ago

I dual-boot to Ubuntu 18.04, and when I checked I use dash as well.

I had to upgrade Gradle to 4.8 in order to make the build system work with Java 11.

When I then tested the bin/ncdbg script, it worked - perhaps Gradle 4.8 did the trick.

I created a new release, https://github.com/provegard/ncdbg/releases/tag/0.8.1. Could you please test it?

provegard commented 6 years ago

I just tested the script in the 0.8.0 zip (yesterday I was stuck in running-from-repo mode apparently...) and it does not work. The script in the 0.8.1 zip does.

davidpcaldwell commented 6 years ago

I'll have a look as well. Thanks for letting me know about the 0.8.1 release!

davidpcaldwell commented 6 years ago

To me -- not being a Gradle expert -- it doesn't look like it's coming from Gradle. It looks like it's coming from line 116 of build.gradle. which is now line 115.

unixScriptFile.text  = unixScriptFile.text.replace('$APP_HOME/lib/tools.jar', '/${JAVA_HOME/:/}/lib/tools.jar')

That second expression, starting with the forward-slash, is what my system is choking on, I believe. But I'll do a bit more testing.

davidpcaldwell commented 6 years ago

So the 0.8.1 zip file fails for me as well -- because in that startup script, the tools.jar has been removed altogether. Line 67:

CLASSPATH=$APP_HOME/lib/ncdbg-0.8.1.jar:$APP_HOME/lib/logback-classic-1.1.7.jar:$APP_HOME/lib/tinyws-0.0.6.jar:$APP_HOME/lib/slf4s-api_2.12-1.7.25.jar:$APP_HOME/lib/akka-actor_2.12-2.4.17.jar:$APP_HOME/lib/jackson-module-scala_2.12-2.8.4.jar:$APP_HOME/lib/scallop_2.12-2.1.0.jar:$APP_HOME/lib/scala-reflect-2.12.1.jar:$APP_HOME/lib/scala-java8-compat_2.12-0.8.0.jar:$APP_HOME/lib/scala-library-2.12.6.jar:$APP_HOME/lib/closure-compiler-v20180204.jar:$APP_HOME/lib/logback-core-1.1.7.jar:$APP_HOME/lib/slf4j-api-1.7.25.jar:$APP_HOME/lib/config-1.3.0.jar:$APP_HOME/lib/jackson-module-paranamer-2.8.4.jar:$APP_HOME/lib/jackson-databind-2.8.4.jar:$APP_HOME/lib/jackson-core-2.8.4.jar:$APP_HOME/lib/jackson-annotations-2.8.4.jar:$APP_HOME/lib/closure-compiler-externs-v20180204.jar:$APP_HOME/lib/args4j-2.33.jar:$APP_HOME/lib/guava-22.0.jar:$APP_HOME/lib/error_prone_annotations-2.0.18.jar:$APP_HOME/lib/protobuf-java-3.0.2.jar:$APP_HOME/lib/gson-2.7.jar:$APP_HOME/lib/jsr305-3.0.1.jar:$APP_HOME/lib/jsinterop-annotations-1.0.0.jar:$APP_HOME/lib/paranamer-2.8.jar:$APP_HOME/lib/j2objc-annotations-1.1.jar:$APP_HOME/lib/animal-sniffer-annotations-1.14.jar

This leads to the unsurprising error:

NCDbg version: 0.8.1
Local Java version: 1.8.0_144
Connecting to localhost:7777...
Exception in thread "main" java.lang.BootstrapMethodError: java.lang.NoClassDefFoundError: com/sun/jdi/VirtualMachine
        at com.programmaticallyspeaking.ncd.boot.Broker.connect(Broker.scala:27)
        at com.programmaticallyspeaking.ncd.boot.Boot$.delayedEndpoint$com$programmaticallyspeaking$ncd$boot$Boot$1(Boot.scala:37)
        at com.programmaticallyspeaking.ncd.boot.Boot$delayedInit$body.apply(Boot.scala:16)
        at scala.Function0.apply$mcV$sp(Function0.scala:34)
        at scala.Function0.apply$mcV$sp$(Function0.scala:34)
        at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
        at scala.App.$anonfun$main$1$adapted(App.scala:76)
        at scala.collection.immutable.List.foreach(List.scala:389)
        at scala.App.main(App.scala:76)
        at scala.App.main$(App.scala:74)
        at com.programmaticallyspeaking.ncd.boot.Boot$.main(Boot.scala:16)
        at com.programmaticallyspeaking.ncd.boot.Boot.main(Boot.scala)
Caused by: java.lang.NoClassDefFoundError: com/sun/jdi/VirtualMachine
        ... 12 more
Caused by: java.lang.ClassNotFoundException: com.sun.jdi.VirtualMachine
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 12 more
Exception in thread "Thread-1" java.lang.NoClassDefFoundError: com/sun/jdi/Bootstrap
        at com.programmaticallyspeaking.ncd.nashorn.Connections$.getConnector(Connections.scala:13)
        at com.programmaticallyspeaking.ncd.nashorn.Connections$.connect(Connections.scala:9)
        at com.programmaticallyspeaking.ncd.nashorn.NashornDebuggerConnector.connect(NashornDebugger.scala:26)
        at com.programmaticallyspeaking.ncd.nashorn.NashornDebuggerConnector.$anonfun$connect$1(NashornDebugger.scala:18)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassNotFoundException: com.sun.jdi.Bootstrap
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 5 more

Here's the code from the 0.8.0 version, which does contain tools.jar, but with that expression dash doesn't like:

CLASSPATH=$APP_HOME/lib/nashorn-chrome-debugging-0.8.0.jar:/${JAVA_HOME/:/}/lib/tools.jar:$APP_HOME/lib/logback-classic-1.1.7.jar:$APP_HOME/lib/tinyws-0.0.6.jar:$APP_HOME/lib/slf4s-api_2.12-1.7.25.jar:$APP_HOME/lib/akka-actor_2.12-2.4.17.jar:$APP_HOME/lib/jackson-module-scala_2.12-2.8.4.jar:$APP_HOME/lib/scallop_2.12-2.1.0.jar:$APP_HOME/lib/scala-java8-compat_2.12-0.8.0.jar:$APP_HOME/lib/scala-reflect-2.12.1.jar:$APP_HOME/lib/scala-library-2.12.1.jar:$APP_HOME/lib/closure-compiler-v20180204.jar:$APP_HOME/lib/logback-core-1.1.7.jar:$APP_HOME/lib/slf4j-api-1.7.25.jar:$APP_HOME/lib/config-1.3.0.jar:$APP_HOME/lib/jackson-module-paranamer-2.8.4.jar:$APP_HOME/lib/jackson-databind-2.8.4.jar:$APP_HOME/lib/jackson-core-2.8.4.jar:$APP_HOME/lib/jackson-annotations-2.8.4.jar:$APP_HOME/lib/closure-compiler-externs-v20180204.jar:$APP_HOME/lib/args4j-2.33.jar:$APP_HOME/lib/guava-22.0.jar:$APP_HOME/lib/error_prone_annotations-2.0.18.jar:$APP_HOME/lib/protobuf-java-3.0.2.jar:$APP_HOME/lib/gson-2.7.jar:$APP_HOME/lib/jsr305-3.0.1.jar:$APP_HOME/lib/jsinterop-annotations-1.0.0.jar:$APP_HOME/lib/paranamer-2.8.jar:$APP_HOME/lib/j2objc-annotations-1.1.jar:$APP_HOME/lib/animal-sniffer-annotations-1.14.jar

I'll continue running through a few different cases.

provegard commented 6 years ago

The problem is that I built the 0.8.1 distribution with Java 11 which doesn't contain tools.jar. But it should be included in the classpath regardless, of course. I'll fix it!

provegard commented 6 years ago

Could you please try the 0.8.2 release?

davidpcaldwell commented 6 years ago

Yep, I'll try to get to that this morning!

provegard commented 6 years ago

Since I haven't heard anything I'm going to close this issue.