Start repl with history and line-edit capabilities from -main


just a quick question. I would like to start a repl from -main in an uberjar that has line editor and persistent history baked in, so the jar can be copied to any windows, mac or linux system and behaves the same. Additional features like rebel-readline would of course be welcome :-).

I tried the code sample on under “quick usage”, but it did just yield a plain repl with not even line-edit support?!

Is something easily achievable? I tried to google but one find usual repl usage information.


  1. With the official binaries, clojure does not have readline support, whereas for clj, this is provided by GNU Readline, which needs to be installed.
  2. As for for Rebel Readline, which you linked, I got readline support.

Some questions.

  1. Does it work for you when you run

    clojure -Sdeps "{:deps {com.bhauman/rebel-readline {:mvn/version \"0.1.4\"}}}" -m rebel-readline.main

    ? Because when I do that, everything works great.

  2. Do you have GNU Readline installed? On my Ubuntu, I installed readline-common.


Hi Teodor,

thank you for the quick reply! Yes, the clojure -Sdeps… works fine.

What I would like to have is a reasonable repl experience just from an uberjar without any additional installs (java -jar …). especially must work on windows (hopefully windows 10).

If this is not feasible, I will just use a full lein installation.

When you run the clojure -Sdeps ... command with Rebel readline, you hit this function:

Have you tried calling it yourself?

;; In your own namespace
;; You'll have to require ensure-terminal and repl

(core/ensure-terminal (repl))

To be honest, I’m not quite sure of what you’re trying to achieve. Do you want to get a Clojure REPL on a machine without installing Clojure? Or do you want to get rid of the GNU Readline dependency?

A word about your motivation might help us respond :slight_smile:

It should be possible to uberjar it all. You probably just have it wrong so its not bootstrapping the rebel-readline repl.

Indeed, somehow the :main was missing in project.clj, so it always started the default repl :rofl:. All versions work on mac now, I like (core/ensure-terminal (repl)), even (core/-main) works! As I need the :init hook, I used the code from rebel-deadline GitHub page with an additional :init option.

On Windows 7 it does not work, it says “Unable to detect a system Terminal”. I try Windows 10 later, but I believe it should work there with Windows Terminal.

Thanks for help! Here is my main for reference:

(defn -main [& args]
  ;(apply rebel-readline.clojure.main/-main args) 
  ;(rebel-readline.core/ensure-terminal (rebel-readline.clojure.main/repl))
      :init #(println "put any init code here")
      :prompt (fn [])                                       ;; prompt is handled by line-reader
      :read (rebel-readline.clojure.main/create-repl-read))))

I’m glad you got it working!

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.