Fork me on GitHub
#sci
<
2023-09-23
>
Jakub Holý (HolyJak)16:09:33

Hello! How do I avoid call unbound fn: #'clojure.core/*print-fn* ? I evaluate code in cljs repl, the following works fine:

(println :i-fail)
; OUT: :i-fail
; => nil
but when I do the same via sci, it fails:
(sci/eval-string* (sci/init {}) "(println :i-fail)")
; Execution error (Error) at (<cljs repl>:1).
; Attempting to call unbound fn: #'clojure.core/*print-fn*
I tried to add (enable-console-print!) to the code I send to SCI for eval, but of course this var is not known at that point. I must be doing something wrong, but what?

1
borkdude16:09:24

It’s in the SCi README, sorry for the brief response but traveling, look for alter var root sci out err

Jakub Holý (HolyJak)16:09:58

You answer was perfect! I should have checked the readme… For posterity: I have added this to my cljs ns, where I invoke sci from:

(enable-console-print!)
(sci/alter-var-root sci/print-fn (constantly *print-fn*))
(sci/alter-var-root sci/print-err-fn (constantly *print-err-fn*))

Jakub Holý (HolyJak)16:09:17

A tiny attempt at improving the readme for lazy ppl https://github.com/babashka/sci/pull/900/files