technomancy / leiningen

Moved to Codeberg; this is a convenience mirror
https://codeberg.org/leiningen/leiningen
Other
7.29k stars 1.61k forks source link

lein repl (2.8.2) throws an exception on Ubuntu 18.04 and 16.04 #2497

Closed jtcbrule closed 5 years ago

jtcbrule commented 5 years ago

I get the following stack trace when running lein repl on Ubuntu 18.04 and 16.04 (Leiningen 2.8.2 on Java 1.8.0_191 OpenJDK 64-Bit Server VM):

Exception in thread "Thread-1" java.lang.AssertionError: Assert failed: transport-fn
at nrepl.core$connect.invokeStatic(core.clj:168)
at nrepl.core$connect.doInvoke(core.clj:168)
at clojure.lang.RestFn.invoke(RestFn.java:457)
at nrepl.ack$send_ack.invokeStatic(ack.clj:45)
at nrepl.ack$send_ack.invoke(ack.clj:41)
at nrepl.server$start_server.invokeStatic(server.clj:146)
at nrepl.server$start_server.doInvoke(server.clj:105)
at clojure.lang.RestFn.invoke(RestFn.java:1096)
at user$eval747.invokeStatic(NO_SOURCE_FILE:0)
at user$eval747.invoke(NO_SOURCE_FILE)
at clojure.lang.Compiler.eval(Compiler.java:6927)
at clojure.lang.Compiler.eval(Compiler.java:6917)
at clojure.lang.Compiler.eval(Compiler.java:6917)
at clojure.lang.Compiler.eval(Compiler.java:6890)
at clojure.core$eval.invokeStatic(core.clj:3105)
at clojure.core$eval.invoke(core.clj:3101)
at leiningen.core.eval$fn__4211.invokeStatic(eval.clj:343)
at leiningen.core.eval$fn__4211.invoke(eval.clj:333)
at clojure.lang.MultiFn.invoke(MultiFn.java:233)
at leiningen.core.eval$eval_in_project.invokeStatic(eval.clj:367)
at leiningen.core.eval$eval_in_project.invoke(eval.clj:357)
at leiningen.repl$server$fn__5985.invoke(repl.clj:276)
at clojure.lang.AFn.applyToHelper(AFn.java:152)
at clojure.lang.AFn.applyTo(AFn.java:144)
at clojure.core$apply.invokeStatic(core.clj:646)
at clojure.core$with_bindings_STAR_.invokeStatic(core.clj:1881)
at clojure.core$with_bindings_STAR_.doInvoke(core.clj:1881)
at clojure.lang.RestFn.invoke(RestFn.java:425)
at clojure.lang.AFn.applyToHelper(AFn.java:156)
at clojure.lang.RestFn.applyTo(RestFn.java:132)
at clojure.core$apply.invokeStatic(core.clj:650)
at clojure.core$bound_fn_STAR_$fn__4671.doInvoke(core.clj:1911)
at clojure.lang.RestFn.invoke(RestFn.java:397)
at clojure.lang.AFn.run(AFn.java:22)
at java.lang.Thread.run(Thread.java:748)
REPL server launch timed out.

Leiningen 2.8.1 runs without error.

0xtmphey commented 5 years ago

Same for MacOS

rosstimson commented 5 years ago

Also Fedora 29.

lein version
Leiningen 2.8.2 on Java 11.0.1 OpenJDK 64-Bit Server VM
tucho commented 5 years ago

The same in Arch (I'm holding the package upgrade until this issue is settled).

ghost commented 5 years ago

Same on FreeBSD.

$ lein version
Leiningen 2.8.2 on Java 1.8.0_181 OpenJDK 64-Bit Server VM
tirkarthi commented 5 years ago

Wild guess. Could it be possibly due to https://github.com/technomancy/leiningen/commit/b54b762ac1331800a7a2b10b2cae0d6aaa469d0f ? I could see references to transport-fn only with that commit.

Edit : Probably not. Building lein before the commit still has the issue.

bbatsov commented 5 years ago

I guess I made some mistake. Let me check this.

tirkarthi commented 5 years ago

@bbatsov I can see the error with 115f70e791a85badfe8ebb93609adf9c80835bd5 where nrepl was bumped to 0.5.1 and moving to the previous commit with 00e36266684c6282ed1de5227e6ec4062d6f396e shows no error with nrepl 0.4.5 . Probably something with bumping the version?

bbatsov commented 5 years ago

I can't imagine what it can be. The differences between 0.4.5 and 0.5.1 are pretty small and 0.5.1 works just fine when I run it without leiningen. I'll install it a bit and debug this further.

One mistake I see I made was that I'm passing :transport to start-server instead of :transport-fn, but this should not break anything - it'd simply render the config useless.

bbatsov commented 5 years ago

Hmm, looking closer I see something weird - why is there an invocation to nrepl.ack at all?

The only potentially related change in 0.5.0 I could find is https://github.com/nrepl/nrepl/commit/77335a912dccb8004aa7552d2a086f998e282b74 Seems the new signature is not reflected in Lein's usage of this.

bbatsov commented 5 years ago

//cc @pfeodrippe (in case he beats me to fixing this)

bbatsov commented 5 years ago

OK, so I figured this out and I'll submit a solution shortly.

I didn't notice that Lein was actually starting two nREPL servers and was making use of the ack functionality at all? Apart from the question of whether the second server is needed or not it seems there's really a regression in the commit I pointed out.

This assertion here is failing https://github.com/nrepl/nrepl/blob/master/src/clojure/nrepl/core.clj#L177

which is caused by https://github.com/nrepl/nrepl/blob/master/src/clojure/nrepl/ack.clj#L45, although at least superficially the code looks good.

bbatsov commented 5 years ago

In a bit of fun irony - I can't deploy the fix because of another bug:

Compiling 1 source files to /Users/bozhidar/projects/nREPL/target/classes
warning: [options] bootstrap class path not set in conjunction with -source 8
1 warning
Created /Users/bozhidar/projects/nREPL/target/nrepl-0.5.3.jar
Wrote /Users/bozhidar/projects/nREPL/pom.xml
java.lang.ClassCastException: clojure.lang.Keyword cannot be cast to java.base/java.lang.String
 at cemerick.pomegranate.aether$authentication.invokeStatic (aether.clj:173)
    cemerick.pomegranate.aether$authentication.invoke (aether.clj:173)
    cemerick.pomegranate.aether$set_authentication.invokeStatic (aether.clj:184)
    cemerick.pomegranate.aether$set_authentication.invoke (aether.clj:181)
    cemerick.pomegranate.aether$make_repository.invokeStatic (aether.clj:207)
    cemerick.pomegranate.aether$make_repository.invoke (aether.clj:200)
    cemerick.pomegranate.aether$deploy_artifacts$fn__110.invoke (aether.clj:361)
    clojure.core$map$fn__4785.invoke (core.clj:2644)
    clojure.lang.LazySeq.sval (LazySeq.java:40)
    clojure.lang.LazySeq.seq (LazySeq.java:49)
    clojure.lang.LazySeq.first (LazySeq.java:71)

🀣

Anyways, I'll downgrade my Lein and address this in a moment.

pfeodrippe commented 5 years ago

Thank you @bbatsov! I should have made a test for it o/

bbatsov commented 5 years ago

OK, so while my Lein PR is merged the simply workaround is to add [nrepl "0.5.3"] to your profiles.clj.

I'm sorry for this problem and I guess I'll learn to start testing lein repl as a typically used just lein repl :headless. :-)

bbatsov commented 5 years ago

Fix away!

lispyclouds commented 5 years ago

@bbatsov I get this error after adding [nrepl "0.5.3"] to ~/.lein/profiles.clj

java.lang.IllegalArgumentException: No implementation of method: :send of protocol: #'nrepl.transport/Transport found for class: clojure.tools.nrepl.middleware.render_values$wrap_renderer$reify__2280
    at clojure.core$_cache_protocol_fn.invokeStatic(core_deftype.clj:583)
    at clojure.core$_cache_protocol_fn.invoke(core_deftype.clj:575)
    at nrepl.transport$eval326$fn__327$G__317__334.invoke(transport.clj:16)
    at nrepl.middleware.session$register_session.invokeStatic(session.clj:149)
    at nrepl.middleware.session$register_session.invoke(session.clj:142)
    at nrepl.middleware.session$session$fn__1026.invoke(session.clj:193)
    at nrepl.middleware$wrap_conj_descriptor$fn__595.invoke(middleware.clj:17)
    at clojure.tools.nrepl.middleware.render_values$render_values$fn__2288.invoke(render_values.clj:42)
    at clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__2097.invoke(middleware.clj:22)
    at nrepl.server$handle_STAR_.invokeStatic(server.clj:18)
    at nrepl.server$handle_STAR_.invoke(server.clj:15)
    at nrepl.server$handle$fn__1063.invoke(server.clj:27)
    at clojure.core$binding_conveyor_fn$fn__5739.invoke(core.clj:2030)
    at clojure.lang.AFn.call(AFn.java:18)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.lang.Thread.run(Thread.java:844)

This is after the server has started. nREPL server started on port 54424 on host 127.0.0.1 - nrepl://127.0.0.1:54424

my profiles.clj:

{:user {:plugins      [[venantius/ultra "0.5.2"]]
        :dependencies [[mvxcvi/whidbey "1.3.2"]
                       [nrepl "0.5.3"]]}}
bbatsov commented 5 years ago

@lispyclouds You're using some legacy middleware that doesn't support the newest version of nREPL yet - I'm reasonably certain that removing whidbey is going to fix problem problem. Not sure if ultra is also some middleware.

bbatsov commented 5 years ago

Here are some more details about the required changes that middleware authors have to do to support nREPL 0.4+ - https://nrepl.xyz/nrepl/installation.html#upgrading. Here's a bit more context if you'd like to learn more https://metaredux.com/posts/2018/10/29/nrepl-redux.html

bbatsov commented 5 years ago

Btw, that's the code in whidbey that needs to be updated - https://github.com/greglook/whidbey/blob/master/src/clojure/tools/nrepl/middleware/render_values.clj.

Whidbey is not really needed in nREPL 0.5+, as nREPL now supports natively the ability to specify a pretty-printer.

lispyclouds commented 5 years ago

@bbatsov Turns out its both whidbey and ultra. Removing makes it work now. πŸ˜„ Thanks a lot!

jaidetree commented 5 years ago

Experiencing the same issue even after applying the work around:

profiles.clj

{:user {:deploy-repositories [["snapshots" :clojars]
                              ["releases" :clojars]]
        :dependencies [[nrepl "0.5.3"]]
        :signing {:gpg-key "XXXXXXXX"}}}

Reproduction

  1. cd ~
  2. lein repl

Actual Results:

$ lein repl
exception in thread "Thread-1" java.lang.AssertionError: Assert failed: transport-fn
    at nrepl.core$connect.invokeStatic(core.clj:168)
    at nrepl.core$connect.doInvoke(core.clj:168)
    at clojure.lang.RestFn.invoke(RestFn.java:457)
    at nrepl.ack$send_ack.invokeStatic(ack.clj:45)
    at nrepl.ack$send_ack.invoke(ack.clj:41)
    at nrepl.server$start_server.invokeStatic(server.clj:146)
    at nrepl.server$start_server.doInvoke(server.clj:105)
    at clojure.lang.RestFn.invoke(RestFn.java:1096)
    at user$eval747.invokeStatic(NO_SOURCE_FILE:0)
    at user$eval747.invoke(NO_SOURCE_FILE)
    at clojure.lang.Compiler.eval(Compiler.java:6927)
    at clojure.lang.Compiler.eval(Compiler.java:6917)
    at clojure.lang.Compiler.eval(Compiler.java:6917)
    at clojure.lang.Compiler.eval(Compiler.java:6890)
    at clojure.core$eval.invokeStatic(core.clj:3105)
    at clojure.core$eval.invoke(core.clj:3101)
    at leiningen.core.eval$fn__4211.invokeStatic(eval.clj:343)
    at leiningen.core.eval$fn__4211.invoke(eval.clj:333)
    at clojure.lang.MultiFn.invoke(MultiFn.java:233)
    at leiningen.core.eval$eval_in_project.invokeStatic(eval.clj:367)
    at leiningen.core.eval$eval_in_project.invoke(eval.clj:357)
    at leiningen.repl$server$fn__5985.invoke(repl.clj:276)
    at clojure.lang.AFn.applyToHelper(AFn.java:152)
    at clojure.lang.AFn.applyTo(AFn.java:144)
    at clojure.core$apply.invokeStatic(core.clj:646)
    at clojure.core$with_bindings_STAR_.invokeStatic(core.clj:1881)
    at clojure.core$with_bindings_STAR_.doInvoke(core.clj:1881)
    at clojure.lang.RestFn.invoke(RestFn.java:425)
    at clojure.lang.AFn.applyToHelper(AFn.java:156)
    at clojure.lang.RestFn.applyTo(RestFn.java:132)
    at clojure.core$apply.invokeStatic(core.clj:650)
    at clojure.core$bound_fn_STAR_$fn__4671.doInvoke(core.clj:1911)
    at clojure.lang.RestFn.invoke(RestFn.java:397)
    at clojure.lang.AFn.run(AFn.java:22)
    at java.lang.Thread.run(Thread.java:748)

Environment

Param Value
Operating System OS X Mojave (10.14)
Lein Version 2.8.2
Shell Fish
Directory ~HOME
project.clj present? None
technomancy commented 5 years ago

@jayzawrotny what about on master?

bbatsov commented 5 years ago

@jayzawrotny For some reason the profiles.clj doesn't get properly merged outside of a project context and you're still on 0.5.2, but as @technomancy pointed out things will work just fine on Lein's master. If you run lein within a project you'll be fine.

jaidetree commented 5 years ago

Just tried master and it worked like a charm. Though I do apologize for taking up double the support effort. I wanted to report it in case another unrelated issue was masked by the original.

Thanks for the help and clarification! πŸŽ‰