LightTable icon indicating copy to clipboard operation
LightTable copied to clipboard

nREPL hangs trying to connect to a Luminus project

Open yogthos opened this issue 9 years ago • 10 comments

steps to reproduce

  • create a new project with lein new luminus myapp
  • run the project with lein run, this will start nREPL on port 7000
  • open a namespace from the project in LT and try to do add connection nREPL on localhost:7000

The Connecting... message appears and hangs, no errors appear.

However, I'm able to start a REPL from LT without problems.

yogthos avatar Feb 17 '16 01:02 yogthos

Hi yogthos. When I try this on osx 10.10, I don't get a hang but instead a connection to a new process (which isn't correct). When I do a remote connection via lein repl, I'm able to correctly communicate with the server process via lein's nrepl server and can run start-app. Are you aware of any differences b/n luminus' nrepl server and lein's? Nothing immediately pops out. I don't have cycles to dig deeper but happy to answer any LT questions if you're interested in looking further into this

cldwalker avatar Feb 17 '16 07:02 cldwalker

Beat me to it, I was about to mention that the steps to reproduce didn't take into account the need to add lein-light-nrepl and nrepl-options to project.clj

rundis avatar Feb 17 '16 07:02 rundis

Yeah, I'm a bit stumped on this one as well. The nrepl started by luminus should be pretty standard and cursive connects just fine, and I can connect by running lein repl :connect 7000 as well. What's the relationship of lein-light-nrepl and nrepl-options to the app starting the repl though. Wouldn't that be happening on LT end?

yogthos avatar Feb 17 '16 14:02 yogthos

For a given port and host, LT opens a connection to a nrepl client. The lein-light-nrepl middleware entry fn is lighttable-ops. Two possible reasons for why the luminus nrepl server has different behavior: different tools.nrepl version or some of the server options as nil values is causing different behavior than lein's options

cldwalker avatar Feb 18 '16 07:02 cldwalker

I think it's most likely the tools.nrepl version. I tried adding lein-light-nrepl and nrepl-options, but that didn't have any effect. The only option I pass in by default is the repl port here, and I tried adding the same ones as lein does, but that doesn't seem to help either.

yogthos avatar Apr 02 '16 00:04 yogthos

Also having this issue.

Source code

Added: [lein-light-nrepl "0.3.3"] to :project/dev :dependencies and :repl-options {:nrepl-middleware [lighttable.nrepl.handler/lighttable-ops]} (see project.clj file).

Screenshot

Trying to directly connect with lein also results in an error. This may or may not be related:

→ lein repl :connect http://localhost:7000
Connecting to nREPL at http://localhost:7000
NoHttpResponseException localhost:7000 failed to respond

ashleyconnor avatar Aug 28 '16 15:08 ashleyconnor

For lein repl, it should just be lein repl :connect localhost:7000 without http://.

yogthos avatar Aug 28 '16 18:08 yogthos

Had the same issue – could finally connect to the nrepl server when I explicitly specified the Light Table handler for nrepl in repl-server in the core ns of my app:

(ns myapp.core
  (:require [luminus.repl-server :as repl]
            [lighttable.nrepl.handler :refer [lighttable-ops]]
            [clojure.tools.nrepl.server :as nrepl]
            ...))

(mount/defstate ^{:on-reload :noop}
                repl-server
                :start
                (when-let [nrepl-port (env :nrepl-port)]
                  (repl/start
                    {:port nrepl-port
                     :handler (nrepl/default-handler #'lighttable-ops)}))
                :stop
                (when repl-server
                  (repl/stop repl-server)))

Hope this helps.

alephyud avatar Nov 21 '16 11:11 alephyud

I have the same issue. I tried on Ubuntu and Windows. I got the same issue. After hours of trying to connect it's still trying.

nenadmitrovic avatar Apr 13 '19 00:04 nenadmitrovic

I have the same issue. I tried on Ubuntu and Windows. I got the same issue. After hours of trying to connect it's still trying.

@nenadmitrovic https://stackoverflow.com/a/55662215/6587655

prertik avatar Apr 13 '19 05:04 prertik