If you use in-ns
on a namespace that doesn't exist, you won't get of clojure.core
. I suggested doing a conditional check on find-ns
(and then either in-ns
if it exists or ns
if it doesn't) but I don't know how portable that is. There are definitely some REPLs it won't work with.
If you were able to do load-file
first then the problem goes away of course 😐
Probably the problem is here: (clojure.core/->> res type str...
I'm just amazed that somehow I didn't test this case.... I'll fix it 🙂
This is the problem: https://github.com/mauricioszabo/repl-tooling/commit/fcb1fb0323c55dc1b3206c44a553575643dc853b
i think what seancorfield said about in-ns for a non-existing ns may still be an issue even with that change.
i just tested by changing my source manually in my submodule checkout of repl-tooling and then did a npx shadow-cljs watch dev
(that should be enough right?), with the change, there is still an error:
user=> #object[Namespace 0x1941fb1e "sample"]
Syntax error (InvalidOperationException) compiling at (REPL:4:642).
Unable to resolve symbol: str in this context
sample=>
please let me know if there is something else i still need to do to test the latest change.looking at a wireshark capture, it doesn't look like the change got compiled in -- need to figure out how to build this correctly...
Please save the file clj_helper.clj
All files on resources
path are inlined on this clj_helper
. Saving it once will issue a compilation and things should work
thanks, that seems to have done it 🙂 seems to be working! :thumbsup:
#?(:cljs :using-cljs-repl :clj :using-clj-repl :cljr :using-cljr-repl :joker :using-joker-repl :bb :using-bb-repl)
:using-unknown-repl
user=> user=> :using-cljr-repl
user=> :using-unknown-repl
user=> (in-ns 'sample)(try (clojure.core/let [res (do (ns sample) (def a 1) ) res (clojure.core/cond #?(:cljs false :default (clojure.core/ratio? res)) (clojure.core/symbol (clojure.core/str "#repl-tooling/literal-render \"" (clojure.core/pr-str res) "\"")) (clojure.core/symbol? res) (clojure.core/symbol (clojure.core/str "#unrepl/bad-symbol [nil " (clojure.core/pr-str (clojure.core/str res)) "]")) (clojure.core/keyword? res) (clojure.core/symbol (clojure.core/str "#unrepl/bad-keyword [" (clojure.core/pr-str (clojure.core/namespace res)) " " (clojure.core/pr-str (clojure.core/name res)) "]")) (clojure.core/->> res clojure.core/type clojure.core/str (clojure.core/re-find #"Big(Decimal|Float)")) (clojure.core/symbol (clojure.core/str "#unrepl/bigdec "res)) (clojure.core/->> res clojure.core/type clojure.core/str (clojure.core/re-find #"BigInt")) (clojure.core/symbol (clojure.core/str "#unrepl/bigint "res)) :else res)] ['tooling$eval-res 'G__2 {:result (clojure.core/pr-str res)}]) (catch System.Exception e ['tooling$eval-res 'G__2 {:error (clojure.core/pr-str e)}]))
#object[Namespace 0x3629912d "sample"]
[tooling$eval-res G__2 {:result "#'sample/a"}]
sample=>
i guess as long as one uses full-qualified names, clojure.core things should be available.
If something is required at least once, they become available with their full-qualified names 🙂
Now I'm trying to cut some strange code that are appearing when I evaluate code...
right
since there is a connection to the socket repl, i guess it's safe to assume clojure.core has been (mostly?) loaded
Yes, so far it seems like so...
there are so many strange things happening on different REPLs that I'm not betting on it 😄
(for example, in-ns
in ClojureScript is bizarre....)
right
Also, I just discovered that load-file
in CLJS also suffers from the same problem...
i'm copying the lein invocation from https://atom.io/packages/chlorine and i'm getting
[dan@fedora queue]$ JVM_OPTS='-Dclojure.server.myrepl={:port,5556,:accept,clojure.core.server/repl}' lein trampoline repl
ClassCastException java.lang.String cannot be cast to java.lang.Number
nrepl.server/start-server/addr--1161 (server.clj:120)
nrepl.server/start-server (server.clj:128)
nrepl.server/start-server (server.clj:96)
reply.eval-modes.nrepl/get-connection (nrepl.clj:158)
reply.eval-modes.nrepl/get-connection (nrepl.clj:156)
the example for clj
works correctly for me though
@dpsutton That error is coming from nREPL, not the Clojure Socket REPL (just FYI)
And that command works for me -- so perhaps some problem with your project.clj
or maybe ~/.lein/profiles.clj
?
thanks @seancorfield. hmm. i thought i had emptied those 🙂 rookie mistake if not ha
i'm getting the same error output, fwiw
hmm, no ~/.lein/profiles.clj
file for me
my is pretty blank
is there a system one lurking anywhere? I always forget
or close to anyway
FWIW, that's with lein
2.8.1 on OpenJDK 8 in a random example project.
i'm 2.9.1. let me downgrade
I have no ~/.lein/profiles.clj
file.
here it was w/ lein 2.9.1
tried both openjdk 8 and adoptopenjdk 11
works with lein 2.8.1 broken lein 2.9.1
I haven't upgraded Leiningen for ages because so much stuff seemed to be breaking for other people 😐
welp, time to debug nrepl. thanks for the datapoint though @seancorfield
(this is yet another instance of why I'm glad I've stopped using nREPL and tooling built on it -- the move out of Contrib and the renaming and ripples it caused have been -- and continue to be -- quite disruptive, it appears)
I've seen a number of people have problems with Leiningen 2.9.x and downgrade to 2.8.x and it's fine ¯\(ツ)/¯
nice to be able to downgrade 🙂
w/o trampoline works here
and connecting via socket repl from chlorine w/ eval selection worked too
may be it's worth mentioning that trampoline + lein 2.9.x might have issues in README.md?
Yes, I'll just remove the trampoline part, seems that it's a regression (I remember having the same problem with some older version of lein
)
seems like reply is calling start server with port "0"
instead of nil or 0
Another issue, now with Clojure.CLR:
I was debugging why Chlorine is not rendering the exception correctly... and just discovered that #error
, on ClojureCLR, just returns an invalid map 😞
The keyword :message
is empty, so there's an odd number of arguments
which version of clojure clr are you testing with?
4.0
i mean, when you do _*clojure-version_* what do you see?
is it 1.9.x or something off of the master branch?
1.9.0
ok -- if you tell me exactly what code, i can try to see what happens for something close to 1.10
(try (throw (ex-info "FOO" {}))
(catch Exception e e))
for something on master (1.10 snapshot), i get:
#error {
:cause "FOO"
:data {}
:via
[{:type clojure.lang.ExceptionInfo
:message
:data {}
:at [System.Diagnostics.StackFrame invokeStatic "NO_FILE" 0]}]
:trace
[[System.Diagnostics.StackFrame invokeStatic "NO_FILE" 0]]}
On my REPL it returns #error {:cause "FOO" :data {} :via [:message :data {} :trace [....]]}
Yes, the same invalid map... 😞
i see the problem in core_print.clj
By the way, tomorrow I'll try to release a new version with these changes: https://github.com/mauricioszabo/repl-tooling/pull/40
the equivalent of: https://github.com/clojure/clojure/blob/master/src/clj/clojure/core_print.clj#L513
is missing
a line after here: https://github.com/clojure/clojure-clr/blob/master/Clojure/Clojure.Source/clojure/core_print.clj#L571
looking forward to trying out the ones i haven't 🙂
@sogaiu I reported that on JIRA for you https://clojure.atlassian.net/browse/CLJCLR-106
@seancorfield tyvm!
i think the discovery was by mauricio.szabo though :)
Updated 🙂
thanks again :)
nRipple
Does the latest Chlorine print UUIDs weirdly?
I didn't change that code, but I'll look at it and add a test case and fix it :)
Can you reproduce it?
Yes, I can. I think it was some change in some clojure version...
Ah, that might be it.
Just published a new Chlorine version, fixing problems with evaluation on ClojureCLR, adding support for load-file
in ClojureCLR (didn't test on Windows yet), and fixing the UUID issue too 🙂
success with load file followed by eval selection with clojure clr :thumbsup:
Great! If things become more stable with this new code, I hope I can simplify the current code for REPL connection and other issues 🙂
i have my fingers crossed 🤞
ooo, load file works with babashka too 🙂
is there an easy way to test delayed sending of the second form when connecting? the first form is a reader conditional, and the second form is the keyword :using-unknown-repl. i'd like to send the second one possibly after receiving the response for the reader conditional.
to give some background, i'm testing with arcadia -- and although there are packets flowing to arcadia / unity and prompts coming back, there are no evaluation results. the socket repl there is a bit customized. may be there are timing issues.
manually sending the same reader conditional sequence followed by the keyword via nc works.