cider

A channel dedicated to the Clojure Interactive Development Environment that Rocks (aka CIDER). :cider:
2021-01-06T01:41:22.004600Z

Yes. but it is not easy to see compared with directly seeing it from the prompt.

zane 2021-01-06T02:39:59.004800Z

Makes sense!

solf 2021-01-06T10:46:03.008Z

I want to embed an nrepl server in one of my scripts, but only when enabled via a flag. However just requiring nrepl.server without calling nrepl.server/start-server is enough to prevent the script from exiting immediately. Is this intended? Any workarounds without explicitly quitting at the end of the script?

solf 2021-01-06T10:48:09.009100Z

I also tried to call (require ...) inside a function, but it seems it only works when called on top-level?

(ns test
  #_(:require
     [nrepl.server :as nrepl-server]) ;; This is enough to prevent the script from exiting
  )

(println "Hello world")

(defn -main [& args]
  (println "Args:" args)

  (require 'nrepl.server)
  (nrepl.server/start-server :port 7882) ;; This doesn't work, seems that you can only call (require...) at top level?
  
  )

Ed 2021-01-06T12:08:15.009200Z

the nrepl.server/start-server call doesn't compile because that namespace isn't available when you're compiling the -main fn ... I think you need to use something like requiring-resolve ...

Ed 2021-01-06T12:10:14.009400Z

maybe something like

(let [start-repl (requiring-resolve nrepl.server/start-server)]
  (start-repl :port 7882))