in Clojure

Clojure – (read-line) doesn’t wait for input

“lein run”을 이용하여 (read-line) 함수를 사용하는 중에 문제가 발생하였다.

(read-line) 함수는 (. (new java.util.Scanner (. System in)) nextLine)]와 동일하다.

문제의 원인은 leiningen은 새로운 프로세스를 생성하여 사용하므로 사용자 콘솔에 접근을 할 수 없다는 문제이다.

ref :

Try “lein trampoline run”. See

 Q: I don't have access to stdin inside my project.
 A: There's a problem in the library that 
Leiningen uses to spawn new processes that blocks access to console input. 
This means that functions like read-line will not work as expected in most contexts, 
though the repl task necessarily includes a workaround. 
You can also use the trampoline task to launch 
your project's JVM after Leiningen's has exited rather than launching it as a subprocess.

Write a Comment