简体   繁体   English

ritz-nrepl与lein不适用于osx

[英]ritz-nrepl with lein not working on osx

I would like to use ritz-nrepl for debugging purposes from within Emacs. 我想在Emacs中使用ritz-nrepl进行调试。 Because it already fails with lein ritz-nrepl I did not go further with the Emacs integration yet. 因为使用lein ritz-nrepl已经失败, lein ritz-nrepl我还没有进一步进行Emacs集成。

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. 否则,nrepl等。 are working perfectly fine on my system. 在我的系统上运行正常。 I'm using clojure 1.5.1 with 我正在使用clojure 1.5.1

$> 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: 我的~/.lein/profiles.clj看起来像这样:

{: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 . 在lein项目中,我运行lein ritz-nrepl But this fails with the above exception. 但是,上述异常失败。 I've run lein ritz-nrepl -l trace but found no useful output. 我已经运行了lein ritz-nrepl -l trace但是没有找到有用的输出。 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. 我已经用ritz 0.7.1-SNAPSHOT测试了它,但是错误仍然存​​在。

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. 我知道这个问题很古老,但是我有一个可能的答案,因为我遇到了类似的问题,所以在2019年仍然有用。 The problem is that your debugger is trying to connect via JDI to the process to be debugged but it fails. 问题是您的调试器正在尝试通过JDI连接到要调试的进程,但是它失败了。 Let's look at the long command line after the "VM initialization failed" message: 让我们看一下“ VM初始化失败”消息之后的长长的命令行:

 /.../.../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. 这是JDI用于启动JVM的命令行,该JVM反过来运行clojure +要调试的程序。 The -Xrunjdwp options means that, after being launched, the JVM will try to connect to a debugger through a socket. -Xrunjdwp选项意味着启动后,JVM将尝试通过套接字连接到调试器。 The address=London:58846 string is, precisely, the network address and port where the debugger process is listening, waiting for an inferior to connect. 确切地说, address=London:58846字符串是调试器进程正在侦听,等待下级连接的网络地址和端口。 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. 某些版本的macOS(与Sierra(在我的情况下为Mojave)一起报告)的问题在于macOS无法将主机名(在您的情况下为London )解析为IP地址,从而阻止JVM连接到调试器。 In my case this happens because the hostname JDI is picking is my laptop's local network name . 就我而言,这是因为JDI选择的主机名是笔记本电脑的本地网络名 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. 但是我不认为这是您的情况,因为上述命令行中的主机名是London ,并且根据Apple的说法,“本地网络名是您的计算机名称,并添加了.local ”:由于命令行中的主机名不是London.local ,显然是在您的情况下,JDI试图为您的计算机使用另一个非本地网络名称。

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). 现在,对于该解决方案,假设您运行要调试程序的London机器与运行调试器的London机器相同(这是很常见的情况)。 What you need to do is to "convince" macOS to register the hostname and associate to it the IP address of your computer. 您需要做的是“说服” macOS来注册主机名并将其关联到您计算机的IP地址。 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. 只是为了记录在案,在我的情况,在提出解决方法这篇文章是足够了:我开始的共享服务之一,和MacOS注册我的电脑的本地网络名称。 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 在您的情况下,我不太了解您的网络设置,因此只能提出一个丑陋的建议:编辑/etc/hosts文件(您必须是sudo vimsudo nano ),然后将回送IP地址127.0.0.1映射到您的主机名通过修改行

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... 我知道在2019年不得不修改/etc/hosts并不理想...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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