inf-clojure icon indicating copy to clipboard operation
inf-clojure copied to clipboard

Eval into self-started clojure CLI REPL fails

Open seancorfield opened this issue 5 years ago • 8 comments

Expected behavior

Open a Clojure file, do M-x inf-clojure and provide clojure as the startup command. You get a plain CLI REPL (and you can type into it just fine and it evaluates correctly). Switch back to the Clojure file, put the cursor after a form and eval it C-c C-e. I expect the REPL to display the result of evaluating that form, and I expect to be able to type into the REPL as well, to evaluate new forms.

Actual behavior

C-c C-e causes the REPL to display a very long line of control g characters ^G^G^G^G^G^G^G... and the REPL then becomes unresponsive (you can still type into it, but nothing evaluates).

Note: using a Socket REPL and inf-clojure-connect works correctly -- the problem only seems to happen for a self-start CLI REPL.

Steps to reproduce the problem

See above.

Environment & Version information

inf-clojure version information

3.0.0

Lein/Boot version

n/a; using Clojure CLI 1.10.1.645 (installed via brew)

Emacs version

27.1 (from emacsforosx.com)

Operating system

macOS 10.12

seancorfield avatar Aug 28 '20 17:08 seancorfield

@seancorfield i'm unable to reproduce this. can you say what OS this is? I know you're a user of WSL and i'm wondering if its related to something funky here?

can you also try (setq inf-clojure-log-activity t) and then try this again? this should create a log file called .inf-clojure.log in the root directory with contents similar to


----CMD->
"(+ 1 1)\n"
<-RES----
"2\nbug=> "

i suspect that the mechanism to separate out the new repl prompt from the result might be messing up.

dpsutton avatar Aug 28 '20 23:08 dpsutton

Per template:

Operating system
macOS 10.12

It looks like some very simple forms will eval into a fresh REPL but it always fails eval'ing the ns form. I'm using next.jdbc as my test case. I open src/next/jdbc.clj, start inf-clojure with just a basic clojure command, then C-M-f to the end of the ns form and C-c C-e.

.inf-clojure.log attached:

inf-clojure.txt

seancorfield avatar Aug 29 '20 00:08 seancorfield

I tried a few more evals after that, plus one in the REPL window itself:

----CMD->
"(set! *warn-on-reflection* true)\n"
<-RES----
""
----CMD->
"(try\n                             (:arglists\n                              (clojure.core/meta\n                               (clojure.core/resolve\n                                (clojure.core/read-string \"set!\"))))\n                            (catch #?(:clj Throwable :cljr Exception) e nil))"
----CMD->
"tr\n"
----CMD->
"(try\n                             (:arglists\n                              (clojure.core/meta\n                               (clojure.core/resolve\n                                (clojure.core/read-string \"Clojure\"))))\n                            (catch #?(:clj Throwable :cljr Exception) e nil))"
----CMD->
"1\n"

That last one (1) didn't even produce anything.

seancorfield avatar Aug 29 '20 00:08 seancorfield

ok i can reproduce. i'll start tracking down. In the meantime a workaround is to load the file inf-clojure-load-file C-c C-l and then inf-clojure-set-ns C-c M-n. I'll look into what's happening with the parsing. thanks @seancorfield

dpsutton avatar Aug 29 '20 00:08 dpsutton

That workaround did not work for me. It successfully loads the file and successfully switches to the next.jdbc namespace, but if I try to eval that ns form with C-c C-e, I get into the bad state again.

Some experimentation suggests it is something to do with the docstrings. I can eval some forms, such as defn's with smaller/simpler docstrings, but not anything that has a larger (formatted) docstring containing markdown or possibly quoted quotes, e.g., (defn foo "some \"thing\" like this" [])

I can keep trying to narrow it down a bit on my side if you want?

seancorfield avatar Aug 29 '20 00:08 seancorfield

I worked my way up from the bottom of next/jdbc.clj eval'ing each form and plan fails to eval but the functions below it all work.

seancorfield avatar Aug 29 '20 00:08 seancorfield

so to recap from discussions on slack, this seems to be a problem with process-send-string on osx. bug report here: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=43099

dpsutton avatar Aug 29 '20 05:08 dpsutton

Is there any sort of workaround for this?

RobertARandolph avatar Sep 16 '20 13:09 RobertARandolph