clojure-emacs / refactor-nrepl

nREPL middleware to support refactorings in an editor agnostic way
Eclipse Public License 1.0
255 stars 69 forks source link

Fail to start REPL with refactor-nrepl #94

Closed lsnape closed 9 years ago

lsnape commented 9 years ago

With the advent of clj-refactor 1.1.0 I decided to update my Emacs config and Clojure deps from cider 0.8.2 -> 0.9.1, clj-refactor to 1.1.0 (not sure exactly what it was before), and refactor-nrepl -> 1.1.0.

I created a new project and ran lein repl and everything worked fine; however, when I tried to fire up a repl for an existing project (with actual code to compile), I get this compiler error:

2015-07-07 17:39:54,476 [main] INFO   org.eclipse.jetty.util.log - Logging initialized @932ms
Error loading refactor-nrepl.middleware: java.lang.reflect.InvocationTargetException, compiling:(deps/alembic/v0v3v2/alembic/still.clj:63:48)
Exception in thread "main" java.lang.RuntimeException: Unable to resolve var: refactor-nrepl.middleware/wrap-refactor in this context, compiling:(/private/var/folders/yc/bmmm_mr96h7bv7wb01x15y2r0000gn/T/form-init2722549162999486964.clj:1:8232)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:6651)
    at clojure.lang.Compiler.analyze(Compiler.java:6445)
    at clojure.lang.Compiler.analyze(Compiler.java:6406)
    at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3719)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:6646)
    at clojure.lang.Compiler.analyze(Compiler.java:6445)
    at clojure.lang.Compiler.analyze(Compiler.java:6406)
    at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3719)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:6646)
    at clojure.lang.Compiler.analyze(Compiler.java:6445)
    at clojure.lang.Compiler.access$100(Compiler.java:38)
    at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:6050)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:6644)
    at clojure.lang.Compiler.analyze(Compiler.java:6445)
    at clojure.lang.Compiler.analyze(Compiler.java:6406)
    at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5782)
    at clojure.lang.Compiler$FnMethod.parse(Compiler.java:5217)
    at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3846)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:6642)
    at clojure.lang.Compiler.analyze(Compiler.java:6445)
    at clojure.lang.Compiler.eval(Compiler.java:6700)
    at clojure.lang.Compiler.eval(Compiler.java:6693)
    at clojure.lang.Compiler.eval(Compiler.java:6693)
    at clojure.lang.Compiler.load(Compiler.java:7130)
    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)
Caused by: java.lang.RuntimeException: Unable to resolve var: refactor-nrepl.middleware/wrap-refactor in this context
    at clojure.lang.Util.runtimeException(Util.java:221)
    at clojure.lang.Compiler$TheVarExpr$Parser.parse(Compiler.java:659)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:6644)
    ... 34 more

I've tried other projects and they don't load either. The compiler errors vary but most of them are OOME PermGen space related.

To clarify, I'm just running lein repl in the terminal, so this is nothing emacs related. I've emptied my profiles.clj so it only contains: [refactor-nrepl "1.1.0"], wiped my local maven repo etc. The ideas barrel is starting to get empty now! Any ideas what this could be?

Thanks in advance :)

expez commented 9 years ago

The OOME PermGen error might be related to our use of source rewriting. After googling this error it sometimes appears when loading a ton of classes, and our source rewriting does create quite a few unique classes to avoid polluting the classpath. If you project is large and/or has a ton of dependencies, and especially if you're running on a 32bit VM (smaller default), then this might be the cause of your woes.

Try adding the jvm opt -XX:MaxPermSize=128M and see if that solves your problem.

lsnape commented 9 years ago

Yep adding :jvm-opts ["-XX:MaxPermSize=128M"] to my profiles.clj has done the trick.

Very odd that it manifested itself as the InvocationTargetException pasted above. Anyway, all working and up-to-date. Thanks very much :D