简体   繁体   中英

ritz-nrepl with lein not working on osx

I would like to use ritz-nrepl for debugging purposes from within Emacs. Because it already fails with lein ritz-nrepl I did not go further with the Emacs integration yet.

Exception in thread "main" com.sun.jdi.connect.VMStartException: 
   VM initialization failed for: ...

The full stacktrace is shown at the end of the post. I know that this exception was around for some time and that there are potential fixes but that did not help in my case:

Otherwise, nrepl et al. are working perfectly fine on my system. I'm using clojure 1.5.1 with

$> lein version
Leiningen 2.2.0 on Java 1.7.0_25 Java HotSpot(TM) 64-Bit Server VM

My ~/.lein/profiles.clj looks like this:

{:user
  {:plugins [[lein-ritz "0.7.0"]]
   :dependencies [[nrepl-inspect "0.3.0"]
             [org.clojure/tools.trace "0.7.5"]
             [ritz/ritz-nrepl-middleware "0.7.0"]
             [ritz/ritz-debugger "0.7.0"]
             [clojure-complete "0.2.3"]]
   :repl-options {:nrepl-middleware
             [ritz.nrepl.middleware.javadoc/wrap-javadoc
              ritz.nrepl.middleware.simple-complete/wrap-simple-complete
              inspector.middleware/wrap-inspect]}}}

From within a lein project I run lein ritz-nrepl . But this fails with the above exception. I've run lein ritz-nrepl -l trace but found no useful output. What can I do to get this running?

BTW. I've tested this with the the ritz 0.7.1-SNAPSHOT but the errors persist.

Am I missing something obvious? Any help is greatly appreciated.

Cheers!

Full stacktrace:

Exception in thread "main" com.sun.jdi.connect.VMStartException: VM initialization failed for: /Library/Java/JavaVirtualMachines/jdk1.7.0_25.jdk/Contents/Home/jre/bin/java -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -Xdebug -Xrunjdwp:transport=dt_socket,address=London:58846,suspend=y -cp /private/tmp/test/test:/private/tmp/test/src:/private/tmp/test/dev-resources:/private/tmp/test/resources:/private/tmp/test/target/classes:/Users/me/.m2/repository/reply/reply/0.1.9/reply-0.1.9.jar:/Users/me/.m2/repository/org/thnetos/cd-client/0.3.6/cd-client-0.3.6.jar:/Users/me/.m2/repository/org/sonatype/aether/aether-connector-wagon/1.13.1/aether-connector-wagon-1.13.1.jar:/Users/me/.m2/repository/quoin/quoin/0.1.0/quoin-0.1.0.jar:/Users/me/.m2/repository/useful/useful/0.8.3-alpha8/useful-0.8.3-alpha8.jar:/Users/me/.m2/repository/org/clojure/java.classpath/0.2.0/java.classpath-0.2.0.jar:/Users/me/.m2/repository/clj-stacktrace/clj-stacktrace/0.2.4/clj-stacktrace-0.2.4.jar:/Users/me/.m2/repository/org/clojure/core.cache/0.6.2/core.cache-0.6.2.jar:/Users/me/.m2/repository/org/apache/maven/indexer/indexer-core/4.1.3/indexer-core-4.1.3.jar:/Users/me/.m2/repository/org/tcrawley/dynapath/0.2.3/dynapath-0.2.3.jar:/Users/me/.m2/repository/classlojure/classlojure/0.6.6/classlojure-0.6.6.jar:/Users/me/.m2/repository/ritz/ritz-nrepl-core/0.7.1-SNAPSHOT/ritz-nrepl-core-0.7.1-SNAPSHOT.jar:/Users/me/.m2/repository/org/clojure/tools.trace/0.7.5/tools.trace-0.7.5.jar:/Users/me/.m2/repository/org/clojure/data.xml/0.0.3/data.xml-0.0.3.jar:/Users/me/.m2/repository/org/apache/maven/wagon/wagon-http/2.2/wagon-http-2.2.jar:/Users/me/.m2/repository/org/sonatype/aether/aether-connector-file/1.13.1/aether-connector-file-1.13.1.jar:/Users/me/.m2/repository/stencil/stencil/0.3.1/stencil-0.3.1.jar:/Users/me/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.14/plexus-interpolation-1.14.jar:/Users/me/.m2/repository/org/sonatype/sisu/sisu-inject-bean/2.2.3/sisu-inject-bean-2.2.3.jar:/Users/me/.m2/repository/org/apache/maven/indexer/indexer-artifact/4.1.3/indexer-artifact-4.1.3.jar:/Users/me/.m2/repository/org/apache/lucene/lucene-memory/3.6.1/lucene-memory-3.6.1.jar:/Users/me/.m2/repository/org/codehaus/plexus/plexus-component-annotations/1.5.5/plexus-component-annotations-1.5.5.jar:/Users/me/.m2/repository/jakarta-regexp/jakarta-regexp/1.4/jakarta-regexp-1.4.jar:/Users/me/.m2/repository/org/codehaus/plexus/plexus-utils/2.0.7/plexus-utils-2.0.7.jar:/Users/me/.m2/repository/org/apache/httpcomponents/httpclient/4.2.2/httpclient-4.2.2.jar:/Users/me/.m2/repository/slingshot/slingshot/0.8.0/slingshot-0.8.0.jar:/Users/me/.m2/repository/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar:/Users/me/.m2/repository/com/fasterxml/jackson/dataformat/jackson-dataformat-smile/2.0.6/jackson-dataformat-smile-2.0.6.jar:/Users/me/.m2/repository/org/apache/httpcomponents/httpcore/4.2.2/httpcore-4.2.2.jar:/Users/me/.m2/repository/org/clojars/trptcolin/sjacket/0.1.0.2/sjacket-0.1.0.2.jar:/Users/me/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.0.6/jackson-core-2.0.6.jar:/Users/me/.m2/repository/org/apache/maven/wagon/wagon-http-shared4/2.2/wagon-http-shared4-2.2.jar:/Users/me/.m2/repository/org/apache/maven/maven-model-builder/3.0.4/maven-model-builder-3.0.4.jar:/Users/me/.m2/repository/org/clojure/tools.macro/0.1.1/tools.macro-0.1.1.jar:/Users/me/.m2/repository/cheshire/cheshire/4.0.3/cheshire-4.0.3.jar:/Users/me/.m2/repository/com/cemerick/pomegranate/0.0.13/pomegranate-0.0.13.jar:/Users/me/.m2/repository/jline/jline/2.8/jline-2.8.jar:/Users/me/.m2/repository/scout/scout/0.1.0/scout-0.1.0.jar:/Users/me/.m2/repository/clj-http/clj-http/0.5.8/clj-http-0.5.8.jar:/Users/me/.m2/repository/leiningen-core/leiningen-core/2.0.0/leiningen-core-2.0.0.jar:/Users/me/.m2/repository/org/apache/maven/maven-aether-provider/3.0.4/maven-aether-provider-3.0.4.jar:/Users/me/.m2/repository/commons-io/commons-io/2.4/commons-io-2.4.jar:/Users/me/.m2/repository/org/sonatype/aether/aether-util/1.13.1/aether-util-1.13.1.jar:/Users/me/.m2/repository/clj-http-lite/clj-http-lite/0.2.0/clj-http-lite-0.2.0.jar:/Users/me/.m2/repository/nrepl-inspect/nrepl-inspect/0.3.0/nrepl-inspect-0.3.0.jar:/Users/me/.m2/repository/ritz/ritz-debugger/0.7.1-SNAPSHOT/ritz-debugger-0.7.1-SNAPSHOT.jar:/Users/me/.m2/repository/org/jsoup/jsoup/1.6.1/jsoup-1.6.1.jar:/Users/me/.m2/repository/org/sonatype/aether/aether-api/1.13.1/aether-api-1.13.1.jar:/Users/me/.m2/repository/org/clojure/clojure/1.5.1/clojure-1.5.1.jar:/Users/me/.m2/repository/net/cgrand/regex/1.1.0/regex-1.1.0.jar:/Users/me/.m2/repository/org/codehaus/plexus/plexus-classworlds/2.4/plexus-classworlds-2.4.jar:/Users/me/.m2/repository/org/sonatype/sisu/sisu-guice/3.0.3/sisu-guice-3.0.3-no_aop.jar:/Users/me/.m2/repository/commons-codec/commons-codec/1.6/commons-codec-1.6.jar:/Users/me/.m2/repository/trptcolin/versioneer/0.1.0/versioneer-0.1.0.jar:/Users/me/.m2/repository/org/apache/lucene/lucene-highlighter/3.6.1/lucene-highlighter-3.6.1.jar:/Users/me/.m2/repository/org/sonatype/aether/aether-impl/1.13.1/aether-impl-1.13.1.jar:/Users/me/.m2/repository/bultitude/bultitude/0.1.7/bultitude-0.1.7.jar:/Users/me/.m2/repository/robert/hooke/1.3.0/hooke-1.3.0.jar:/Users/me/.m2/repository/ritz/ritz-nrepl/0.7.1-SNAPSHOT/ritz-nrepl-0.7.1-SNAPSHOT.jar:/Users/me/.m2/repository/ritz/ritz-repl-utils/0.7.1-SNAPSHOT/ritz-repl-utils-0.7.1-SNAPSHOT.jar:/Users/me/.m2/repository/org/apache/maven/maven-repository-metadata/3.0.4/maven-repository-metadata-3.0.4.jar:/Users/me/.m2/repository/org/clojure/tools.nrepl/0.2.3/tools.nrepl-0.2.3.jar:/Users/me/.m2/repository/org/apache/lucene/lucene-queries/3.6.1/lucene-queries-3.6.1.jar:/Users/me/.m2/repository/com/cemerick/drawbridge/0.0.6/drawbridge-0.0.6.jar:/Users/me/.m2/repository/org/apache/maven/maven-model/3.0.4/maven-model-3.0.4.jar:/Users/me/.m2/repository/org/clojure/tools.namespace/0.2.3/tools.namespace-0.2.3.jar:/Users/me/.m2/repository/org/clojure/tools.cli/0.2.1/tools.cli-0.2.1.jar:/Users/me/.m2/repository/org/sonatype/aether/aether-spi/1.13.1/aether-spi-1.13.1.jar:/Users/me/.m2/repository/org/apache/httpcomponents/httpmime/4.2.2/httpmime-4.2.2.jar:/Users/me/.m2/repository/org/apache/lucene/lucene-core/3.6.1/lucene-core-3.6.1.jar:/Users/me/.m2/repository/leiningen/leiningen/2.0.0/leiningen-2.0.0.jar:/Users/me/.m2/repository/ritz/ritz-nrepl-middleware/0.7.1-SNAPSHOT/ritz-nrepl-middleware-0.7.1-SNAPSHOT.jar:/Users/me/.m2/repository/clojure-complete/clojure-complete/0.2.3/clojure-complete-0.2.3.jar:/Users/me/.m2/repository/org/sonatype/sisu/sisu-inject-plexus/2.2.3/sisu-inject-plexus-2.2.3.jar:/Users/me/.m2/repository/org/apache/maven/wagon/wagon-provider-api/2.2/wagon-provider-api-2.2.jar:/Users/me/.m2/repository/net/cgrand/parsley/0.9.1/parsley-0.9.1.jar:/Users/me/.m2/repository/org/clojure/java.classpath/0.2.0/java.classpath-0.2.0-sources.jar:/Users/me/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.14/plexus-interpolation-1.14-sources.jar:/Users/me/.m2/repository/org/codehaus/plexus/plexus-component-annotations/1.5.5/plexus-component-annotations-1.5.5-sources.jar:/Users/me/.m2/repository/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1-sources.jar:/Users/me/.m2/repository/org/clojure/clojure/1.5.1/clojure-1.5.1-sources.jar:/Users/me/.m2/repository/org/codehaus/plexus/plexus-classworlds/2.4/plexus-classworlds-2.4-sources.jar:/Users/me/.m2/repository/commons-codec/commons-codec/1.6/commons-codec-1.6-sources.jar:/Users/me/.m2/repository/org/clojure/tools.nrepl/0.2.3/tools.nrepl-0.2.3-sources.jar:/Users/me/.m2/repository/org/clojure/tools.namespace/0.2.3/tools.namespace-0.2.3-sources.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_25.jdk/Contents/Home/lib/tools.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_25.jdk/Contents/Home/lib/sa-jdi.jar clojure.main -i /private/var/folders/07/mlnfr3g573g13w374qm17s_c0000gn/T/ritz-init3860568408072505479.clj
at com.sun.tools.jdi.AbstractLauncher$Helper.launchAndAccept(AbstractLauncher.java:192)
at com.sun.tools.jdi.AbstractLauncher.launch(AbstractLauncher.java:132)
at com.sun.tools.jdi.SunCommandLineLauncher.launch(SunCommandLineLauncher.java:235)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:93)
at clojure.lang.Reflector.invokeInstanceMethod(Reflector.java:28)
at ritz.jpda.jdi$launch.invoke(jdi.clj:86)
at ritz.jpda.jdi_vm$launch_vm.invoke(jdi_vm.clj:176)
at ritz.jpda.debug$launch_vm.invoke(debug.clj:59)
at ritz.nrepl$start_jpda_server.invoke(nrepl.clj:259)
at user$eval6209.invoke(NO_SOURCE_FILE:1)
at clojure.lang.Compiler.eval(Compiler.java:6511)
at clojure.lang.Compiler.eval(Compiler.java:6500)
at clojure.lang.Compiler.eval(Compiler.java:6501)
at clojure.lang.Compiler.eval(Compiler.java:6477)
at clojure.core$eval.invoke(core.clj:2797)
at clojure.main$eval_opt.invoke(main.clj:297)
at clojure.main$initialize.invoke(main.clj:316)
at clojure.main$null_opt.invoke(main.clj:349)
at clojure.main$main.doInvoke(main.clj:427)
at clojure.lang.RestFn.invoke(RestFn.java:421)
at clojure.lang.Var.invoke(Var.java:419)
at clojure.lang.AFn.applyToHelper(AFn.java:163)
at clojure.lang.Var.applyTo(Var.java:532)
at clojure.main.main(main.java:37)

I know that this question is ancient, but I have a possible answer, that is still relevant in 2019 because I had a similar issue. The problem is that your debugger is trying to connect via JDI to the process to be debugged but it fails. Let's look at the long command line after the "VM initialization failed" message:

 /.../.../java ... -Xrunjdwp:transport=dt_socket,address=London:58846,suspend=y ... clojure.main ...

This is the command line that JDI uses to launch the JVM that, in turns, runs clojure + your program to be debugged. The -Xrunjdwp options means that, after being launched, the JVM will try to connect to a debugger through a socket. The address=London:58846 string is, precisely, the network address and port where the debugger process is listening, waiting for an inferior to connect. The problem with some versions of macOS (reported with Sierra and, in my case, Mojave) is that macOS is unable to resolve the hostname ( London in your case) to an IP address, preventing the JVM to connect to the debugger. In my case this happens because the hostname JDI is picking is my laptop's local network name . But I don't think it is your case, because the hostname in the above command line is London , and according to Apple "The local network name is your computer's name with .local added": Since the hostname in your command line is not London.local , apparently in your case JDI is trying to use another, nonlocal network name for your computer.

Now for the solution, supposing that your London machine where you run the program to be debugged is the same where you run the debugger (that's quite the common case). What you need to do is to "convince" macOS to register the hostname and associate to it the IP address of your computer. Just for the record, in my case the workaround proposed at this post was sufficient: I started one of the sharing services, and macOS registered the local network name of my computer. In your case, not knowing much of your network settings, I am able to suggest only a ugly hack: Edit the /etc/hosts file (you must sudo vim or sudo nano ) and map the loopback IP address 127.0.0.1 to your hostname by modifying the row

127.0.0.1    localhost

to

127.0.0.1    localhost    London

I know that having to modify /etc/hosts in 2019 is less than ideal...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM