clojure - Why does read-line not return after hitting ENTER (seems like a hang) using lein run, but works with lein repl? -


the problem @ hand when run program lein run gets (read-line) part , can't out of it, meaning: read-line never returns.

here relevant code:

(def command (atom ""))  (defn print-prompt []   (print "prompt> ")   (flush) )  (defn ask-for-input []     (print-prompt)     (let [x (str (read-line))]       (println (str "user input: " x))       (reset! command x)     ) ) 

i never see "user input: " string on screen. strange part is, if run lein repl , call (ask-for-input) works correctly :s

try lein trampoline run, works.

the following leiningen faq:

q: don't have access stdin inside project.

a: limitation of jvm's process-handling methods; none of them expose stdin correctly. means functions read-line not work expected in contexts, though repl task includes workaround. can use trampoline task launch project's jvm after leiningen's has exited rather launching subprocess.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -