clj-light-refactor
clj-light-refactor copied to clipboard
"ExceptionInfo: Unsupported escape character: \U" on Windows
This was originally reported as LightTable/LightTable#1928.
This can supposedly be reproduced by eval-ing a single form in a Clojure file.
I have this issue too when try to rename with this plugin:
clojure.lang.ExceptionInfo: Unsupported escape character: \P :: {:column 162, :line 26, :type :reader-exception}
core.clj:4327 clojure.core/ex-info
reader_types.clj:336 clojure.tools.reader.reader-types/reader-error
RestFn.java:439 clojure.lang.RestFn.invoke
reader.clj:257 clojure.tools.reader/escape-char
reader.clj:265 clojure.tools.reader/read-string*
reader.clj:166 clojure.tools.reader/read-delimited
reader.clj:177 clojure.tools.reader/read-list
reader.clj:166 clojure.tools.reader/read-delimited
reader.clj:209 clojure.tools.reader/read-map
reader.clj:166 clojure.tools.reader/read-delimited
reader.clj:177 clojure.tools.reader/read-list
reader.clj:166 clojure.tools.reader/read-delimited
reader.clj:177 clojure.tools.reader/read-list
reader.clj:743 clojure.tools.reader/read
reader.clj:729 clojure.tools.reader/read
eval.clj:17 lighttable.nrepl.eval/try-read
eval.clj:21 lighttable.nrepl.eval/lined-read[fn]
core.clj:4642 clojure.core/repeatedly[fn]
LazySeq.java:42 clojure.lang.LazySeq.sval
LazySeq.java:60 clojure.lang.LazySeq.seq
RT.java:484 clojure.lang.RT.seq
core.clj:133 clojure.core/seq
core.clj:2564 clojure.core/take-while[fn]
LazySeq.java:42 clojure.lang.LazySeq.sval
LazySeq.java:60 clojure.lang.LazySeq.seq
LazySeq.java:82 clojure.lang.LazySeq.first
RT.java:577 clojure.lang.RT.first
core.clj:55 clojure.core/first
eval.clj:184 lighttable.nrepl.eval/eval2119[fn]
AFn.java:159 clojure.lang.AFn.applyToHelper
AFn.java:151 clojure.lang.AFn.applyTo
core.clj:617 clojure.core/apply
core.clj:1788 clojure.core/with-bindings*
RestFn.java:425 clojure.lang.RestFn.invoke
eval.clj:176 lighttable.nrepl.eval/eval2119[fn]
eval.clj:175 lighttable.nrepl.eval/eval2119[fn]
MultiFn.java:227 clojure.lang.MultiFn.invoke
core.clj:97 lighttable.nrepl.core/queued[fn]
core.clj:2330 clojure.core/comp[fn]
interruptible_eval.clj:159 clojure.tools.nrepl.middleware.interruptible-eval/run-next[fn]
AFn.java:24 clojure.lang.AFn.run
(Unknown Source) java.util.concurrent.ThreadPoolExecutor.runWorker
(Unknown Source) java.util.concurrent.ThreadPoolExecutor$Worker.run
(Unknown Source) java.lang.Thread.run
Hi, my first comment at github.
I encountered similar issue when trying to use auto-complete.
This seems to be due to file path not escaped as suggested by LightTable/LightTable#1928. In particular, the following code is executed:
(object/raise ed
:eval.custom
(complete-op ed sym form)
{:result-type :refactor.complete
:verbatim true})
The function complete-op
is called which in turns call lt.plugins.cljrefactor.middleware/create-ns-op
. The later function construct the string containing clojure form to be sent to nrepl for evaluation, but it just concat strings directly:
(let [filename (-> @ed :info :path)]
...
(str (s/join "" (drop-last (pr-str params))) " :ns "
"(lighttable.nrepl.eval/file->ns \"" filename "\")}") "))"))
I checked on my computer:
(-> @(lt.objs.editor.pool/last-active) :info :path)
;; => "C:\\Users\\..."
(subs (-> @(lt.objs.editor.pool/last-active) :info :path) 2 3)
;; => "\\"
(subs (-> @(lt.objs.editor.pool/last-active) :info :path) 3 4)
;; => "U"
This presents problem since string sent to nrepl are assumed to be escaped and so "\U" is interpreted as Unicode encoded character. (I think?)
I tried to fix it by changing create-ns-op
to:
(str (s/join "" (drop-last (pr-str params))) " :ns "
"(lighttable.nrepl.eval/file->ns " (pr-str filename) ")}") "))")))
Now there is no exception, but no autocomplete either. @@
Ah, I forgot to add the middleware plugin to my project, silly me. Now it works ;)
I'm getting this error on Windows 10 with a fresh install of LightTable, clj-light-refactor, middleware in lein profiles and empty project created with lein new app my-app
command. Tried with the middleware in project.clj too.
I tried moving the project folder to different places on my disk and it seems like it's giving the error based on what is the root folder in your path. If the project resides in C:\Users\...
I'll get "Unsupported escape character: \U" and if I move it to C:\dev\...
I'll get "Unsupported escape character: \d".
So I'm guessing it has to do with how the paths are intepreted. It can't distinguish windows backslash paths from escape characters.
Here's one stacktrace:
clojure.lang.ExceptionInfo: Unsupported escape character: \d :: {:type :reader-exception, :line 10, :column 85}
core.clj:4617 clojure.core/ex-info
core.clj:4617 clojure.core/ex-info
reader_types.clj:330 clojure.tools.reader.reader-types/reader-error
reader_types.clj:326 clojure.tools.reader.reader-types/reader-error
RestFn.java:439 clojure.lang.RestFn.invoke
reader.clj:284 clojure.tools.reader/escape-char
reader.clj:265 clojure.tools.reader/escape-char
reader.clj:292 clojure.tools.reader/read-string*
reader.clj:286 clojure.tools.reader/read-string*
reader.clj:878 clojure.tools.reader/read*
reader.clj:859 clojure.tools.reader/read*
reader.clj:189 clojure.tools.reader/read-delimited
reader.clj:183 clojure.tools.reader/read-delimited
reader.clj:202 clojure.tools.reader/read-list
reader.clj:198 clojure.tools.reader/read-list
reader.clj:878 clojure.tools.reader/read*
reader.clj:859 clojure.tools.reader/read*
reader.clj:189 clojure.tools.reader/read-delimited
reader.clj:183 clojure.tools.reader/read-delimited
reader.clj:236 clojure.tools.reader/read-map
reader.clj:232 clojure.tools.reader/read-map
reader.clj:878 clojure.tools.reader/read*
reader.clj:859 clojure.tools.reader/read*
reader.clj:189 clojure.tools.reader/read-delimited
reader.clj:183 clojure.tools.reader/read-delimited
reader.clj:202 clojure.tools.reader/read-list
reader.clj:198 clojure.tools.reader/read-list
reader.clj:878 clojure.tools.reader/read*
reader.clj:859 clojure.tools.reader/read*
reader.clj:189 clojure.tools.reader/read-delimited
reader.clj:183 clojure.tools.reader/read-delimited
reader.clj:202 clojure.tools.reader/read-list
reader.clj:198 clojure.tools.reader/read-list
reader.clj:878 clojure.tools.reader/read*
reader.clj:859 clojure.tools.reader/read*
reader.clj:927 clojure.tools.reader/read
reader.clj:904 clojure.tools.reader/read
eval.clj:18 lighttable.nrepl.eval/try-read
eval.clj:15 lighttable.nrepl.eval/try-read
eval.clj:24 lighttable.nrepl.eval/lined-read[fn]
core.clj:4945 clojure.core/repeatedly[fn]
LazySeq.java:40 clojure.lang.LazySeq.sval
LazySeq.java:49 clojure.lang.LazySeq.seq
RT.java:521 clojure.lang.RT.seq
core.clj:137 clojure.core/seq
core.clj:2795 clojure.core/take-while[fn]
LazySeq.java:40 clojure.lang.LazySeq.sval
LazySeq.java:49 clojure.lang.LazySeq.seq
LazySeq.java:71 clojure.lang.LazySeq.first
RT.java:667 clojure.lang.RT.first
core.clj:55 clojure.core/first
core.clj:55 clojure.core/first
eval.clj:187 lighttable.nrepl.eval/eval2206[fn]
AFn.java:152 clojure.lang.AFn.applyToHelper
AFn.java:144 clojure.lang.AFn.applyTo
core.clj:646 clojure.core/apply
core.clj:1881 clojure.core/with-bindings*
core.clj:1881 clojure.core/with-bindings*
RestFn.java:425 clojure.lang.RestFn.invoke
eval.clj:179 lighttable.nrepl.eval/eval2206[fn]
eval.clj:178 lighttable.nrepl.eval/eval2206[fn]
MultiFn.java:229 clojure.lang.MultiFn.invoke
core.clj:96 lighttable.nrepl.core/queued[fn]
core.clj:2459 clojure.core/comp[fn]
interruptible_eval.clj:159 clojure.tools.nrepl.middleware.interruptible-eval/run-next[fn]
AFn.java:22 clojure.lang.AFn.run
ThreadPoolExecutor.java:1149 java.util.concurrent.ThreadPoolExecutor.runWorker
ThreadPoolExecutor.java:624 java.util.concurrent.ThreadPoolExecutor$Worker.run
Thread.java:748 java.lang.Thread.run