cursive-ide / cursive

Cursive: The IDE for beautiful Clojure code
579 stars 7 forks source link

FileNotFoundException when more than one project uses simple-brepl #546

Open mfikes opened 9 years ago

mfikes commented 9 years ago

I have an issue where I can't close and then open another project using simple-brepl unless I restart my Mac (presumably clearing transient state in tmp directories).

How to reproduce:

Create a project (use lein new proj1) and add simple-brepl, weasel, etc.:

(defproject proj1 "0.1.0-SNAPSHOT"
  :dependencies [[org.clojure/clojure "1.6.0"]
                 [org.clojure/clojurescript "0.0-2371"]
                 [weasel "0.4.0-SNAPSHOT"]]
  :plugins [[lein-cljsbuild "1.0.3"]
            [jarohen/simple-brepl "0.1.1"]])

Import project into IntelliJ, set to use JDK 1.7 or later, and create a REPL (by right-clicking on project.cl) and run that REPL.

Then close IntelliJ and create a similar project, say, named proj2, and follow same steps.

When running the REPL, I get the following

Starting nREPL server...
/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/bin/java -Dclojure.compile.path=/Users/mfikes/foo/proj2/target/classes -Dproj2.version=0.1.0-SNAPSHOT -Dfile.encoding=UTF-8 -Dclojure.debug=false -Didea.launcher.port=7534 "-Didea.launcher.bin.path=/Applications/IntelliJ IDEA 13.app/Contents/bin" -classpath "/Users/mfikes/foo/proj2/test:/Users/mfikes/foo/proj2/src:/Users/mfikes/foo/proj2/dev-resources:/Users/mfikes/foo/proj2/resources:/Users/mfikes/foo/proj2/target/classes:/Users/mfikes/.m2/repository/com/google/code/findbugs/jsr305/1.3.9/jsr305-1.3.9.jar:/Users/mfikes/.m2/repository/args4j/args4j/2.0.26/args4j-2.0.26.jar:/Users/mfikes/.m2/repository/com/google/guava/guava/17.0/guava-17.0.jar:/Users/mfikes/.m2/repository/com/google/javascript/closure-compiler-externs/v20140625/closure-compiler-externs-v20140625.jar:/Users/mfikes/.m2/repository/com/google/javascript/closure-compiler/v20140625/closure-compiler-v20140625.jar:/Users/mfikes/.m2/repository/org/clojure/clojurescript/0.0-2371/clojurescript-0.0-2371.jar:/Users/mfikes/.m2/repository/org/clojure/data.json/0.2.3/data.json-0.2.3.jar:/Users/mfikes/.m2/repository/com/google/protobuf/protobuf-java/2.5.0/protobuf-java-2.5.0.jar:/Users/mfikes/.m2/repository/org/clojure/tools.reader/0.8.9/tools.reader-0.8.9.jar:/Users/mfikes/.m2/repository/org/clojure/google-closure-library-third-party/0.0-20140718-946a7d39/google-closure-library-third-party-0.0-20140718-946a7d39.jar:/Users/mfikes/.m2/repository/org/clojure/google-closure-library/0.0-20140718-946a7d39/google-closure-library-0.0-20140718-946a7d39.jar:/Users/mfikes/.m2/repository/org/clojure/tools.nrepl/0.2.3/tools.nrepl-0.2.3.jar:/Users/mfikes/.m2/repository/weasel/weasel/0.4.0-SNAPSHOT/weasel-0.4.0-SNAPSHOT.jar:/Users/mfikes/.m2/repository/org/clojure/clojure/1.6.0/clojure-1.6.0.jar:/Users/mfikes/.m2/repository/org/mozilla/rhino/1.7R4/rhino-1.7R4.jar:/Users/mfikes/.m2/repository/http-kit/http-kit/2.1.18/http-kit-2.1.18.jar:/Users/mfikes/.m2/repository/clojure-complete/clojure-complete/0.2.3/clojure-complete-0.2.3.jar:/Users/mfikes/.m2/repository/org/json/json/20090211/json-20090211.jar:/Applications/IntelliJ IDEA 13.app/Contents/lib/idea_rt.jar" com.intellij.rt.execution.application.AppMain clojure.main -i /private/var/folders/m0/161fm8fx069fk_fny08nrmkm0000gp/T/form-init1054644403979217911.clj
Exception in thread "main" java.io.FileNotFoundException: Could not locate simple_brepl/service__init.class or simple_brepl/service.clj on classpath: , compiling:(/private/var/folders/m0/161fm8fx069fk_fny08nrmkm0000gp/T/form-init1054644403979217911.clj:1:142)
    at clojure.lang.Compiler.load(Compiler.java:7142)
    at clojure.lang.Compiler.loadFile(Compiler.java:7086)
    at clojure.main$load_script.invoke(main.clj:274)
    at clojure.main$init_opt.invoke(main.clj:279)
    at clojure.main$initialize.invoke(main.clj:307)
    at clojure.main$null_opt.invoke(main.clj:342)
    at clojure.main$main.doInvoke(main.clj:420)
    at clojure.lang.RestFn.invoke(RestFn.java:421)
    at clojure.lang.Var.invoke(Var.java:383)
    at clojure.lang.AFn.applyToHelper(AFn.java:156)
    at clojure.lang.Var.applyTo(Var.java:700)
    at clojure.main.main(main.java:37)
    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 com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
Caused by: java.io.FileNotFoundException: Could not locate simple_brepl/service__init.class or simple_brepl/service.clj on classpath: 
    at clojure.lang.RT.load(RT.java:443)
    at clojure.lang.RT.load(RT.java:411)
    at clojure.core$load$fn__5066.invoke(core.clj:5641)
    at clojure.core$load.doInvoke(core.clj:5640)
    at clojure.lang.RestFn.invoke(RestFn.java:408)
    at clojure.core$load_one.invoke(core.clj:5446)
    at clojure.core$load_lib$fn__5015.invoke(core.clj:5486)
    at clojure.core$load_lib.doInvoke(core.clj:5485)
    at clojure.lang.RestFn.applyTo(RestFn.java:142)
    at clojure.core$apply.invoke(core.clj:626)
    at clojure.core$load_libs.doInvoke(core.clj:5524)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.core$apply.invoke(core.clj:626)
    at clojure.core$require.doInvoke(core.clj:5607)
    at clojure.lang.RestFn.invoke(RestFn.java:408)
    at user$eval5.invoke(form-init1054644403979217911.clj:1)
    at clojure.lang.Compiler.eval(Compiler.java:6703)
    at clojure.lang.Compiler.eval(Compiler.java:6692)
    at clojure.lang.Compiler.eval(Compiler.java:6692)
    at clojure.lang.Compiler.load(Compiler.java:7130)
    ... 16 more

Process finished with exit code 1
No nREPL ack received

If I reboot my Mac, this causes it to clear something under /private/var/folders/ and then I can open proj2 and run its REPL. But then, I can't close, and then open proj1 and run its REPL.

This is always reproducible, and I can always work around it by restarting my Mac.

mfikes commented 9 years ago

I should add that, if I open a terminal in either of these projects and run lein repl, things work. The problem seems to be related to the REPL in Cursive.

mfikes commented 9 years ago

Actually this is much simpler to reproduce that I thought. Just open proj1 as illustrated in the original description start its REPL, close IntelliJ and reopen proj1 and attempt to start its REPL.

I have done a diff of the classpath present in the first line that is emitted when starting the REPL between the first time and the second time and I can see that simple-brepl is included the first time but not the second time.

Specifically, the first launch of the REPL includes:

/Users/mfikes/.m2/repository/jarohen/simple-brepl-core/0.1.1/simple-brepl-core-0.1.1.jar

and

/Users/mfikes/.m2/repository/com/cemerick/piggieback/0.1.3/piggieback-0.1.3.jar

where the second launch is missing these two dependencies.

cursive-ide commented 9 years ago

Wow, that sounds extremely strange, not to mention annoying. I'll take a look and see if I can figure this out.

mfikes commented 9 years ago

I'll retract my previous assertion that this is always reproducible. I've restarted IntelliJ perhaps 50 times now, deleting various things out of the temp directory, looking at network port usage etc. It feels like it is some unreleased resource (perhaps the REPL port still being in use or somesuch) that can cause something in the stack to omit those plugin dependencies. I'm using Yosemite GM 3 right now. Given what I now know, I wouldn't be surprised if this is a challenge to reproduce on other platforms or even other versions of OS X, so let me know if you would like me to dig further.

This is not a pressing issue for me; I've lived with it for quite a while and workarounds exist.