babashka 2026-09-13

@seancorfield I'm looking at ex-triage now and it seems when using rephrase with a clojure.main repl, when I enter (.subs nil 1) in the REPL, the repl exits. Could this be a bug?

Can you provide a bit more context about how you start the REPL and what deps you're using?

In my Clojure REPL setup (via the repl script in my dot-clojure repo):

user=> (.subs nil 1)
Reflection warning, NO_SOURCE_PATH:1:1 - call to method subs can't be resolved (target class is unknown).
Tried to call .getClass() on Object, but was given 'nil', possibly in target (which may be in code you are calling), at user/eval19285 (REPL:1) - runtime error ('nil' encountered).
user=> 

Barebones example:

(!2008)-> clj -Sdeps '{:deps {org.corfield/rephrase {:mvn/version "1.0.4"}}}'
Clojure 1.13.0-alpha6
(require '[org.corfield.rephrase :as rephrase])
nil
user=>
user=>
user=> (clojure.main/repl :caught rephrase/repl-caught)
user=> (.subs nil 1)
Tried to call .getClass() on Object, but was given 'nil', possibly in target (which may be in code you are calling), at user/eval255 (REPL:1) - runtime error ('nil' encountered).
user=> (.subs nil 1)
Tried to call .getClass() on Object, but was given 'nil', possibly in target (which may be in code you are calling), at user/eval257 (REPL:1) - runtime error ('nil' encountered).
user=> nil
user=> (.subs nil 1)
Execution error (NullPointerException) at user/eval259 (REPL:1).
Cannot invoke "Object.getClass()" because "target" is null
user=>
Stays in the inner REPL. When I press ctrl+d, it exits back to the original REPL, as can be seen by the bare error.

With latest dev bb, I can repro and I get

java.lang.NullPointerException [at org/corfield/rephrase/ex_str.clj:53:25]
Will investigate and fix. I suspect the exception data format is different on bb and that's the problem.

On Native image an NPE doesn't have a message, which may be the issue

so perhaps try to test with an exception thrown that doesn't have a message as a repro

A "simple fix" now produces this:

user=> (.subs nil 1)
, at (REPL:1:1) - runtime error ('nil' encountered).
user=> (.subs nil 1)
, at (REPL:1:1) - runtime error ('nil' encountered).

As opposed to this without rephrase:

user=> (.subs nil 1)
java.lang.NullPointerException [at <repl>:1:1]

yeah. the other errors were more or less the same I think

1.0.5 released with that fix.

πŸŽ‰ 1

Thank you for adding ex-triage. I'm really looking forward to the next bb release now, so I can switch my build.clj processes over and add full Babashka support to rephrase!

(i.e., have bb in CI)

yes, me too. I think I'll release it this week 🀞

I have a branch prepared for HoneySQL but rephrase will require a bit more work since it doesn't currently run tests against bb.

I wonder if it's a good idea to have something like :project {:version "1.0.1"} in bb.edn now to manage projects in a more uniform way,since it supports tools.build now but that will probably lead to some kind of library that you also wrote initially

Yeah, I wouldn't go that way. I think leaving folks to manage versions however they want is probably better.

Did you literally copy ex-triage from Clojure or did you make any changes?

I made bb/SCI specific changes, why?

The tests fail in rephrase so I'm just staking out the parameters of the problem for debugging.

(I'm at lunch right now and will get back to debugging properly when I get home)

I have it all working now with dev bb. I expect the next version of rephrase to fully support the (next) release version of bb and a new release of Jolt.

Made a script which wraps deps.clj using bb's new JVM-less mvn stuff. https://gist.github.com/borkdude/0b2581f512dd1aa6c825e22b8659892f It supports mvn deps, unlike the "real" cljr CLI:

cljrb -Sdeps '{:deps {medley/medley {:mvn/version "1.4.0"}}}' -M -e "(require 'medley.core) (prn (medley.core/index-by :id [{:id 1}]))"
{1 {:id 1}}
cc @markus.agwin @dmiller

🀩 1

It does require the current dev build of bb on the PATH:

bash <(curl ) --dev-build --dir /tmp

πŸ”₯ 1

cljrb works splendid on my machine!

might also be interesting for @seancorfield

I use ClojureCLR very rarely so in-1 is working well enough for me at this point. At some point, I may dig back into how to run tests and so on, to see if I can get HoneySQL running on cljr...

I'd love to be able to just run cljr -M:test:cljr-runner (similar to the existing clojure -M:test:cljs-runner) so PRs welcome on HoneySQL for that...

πŸ’‘ 1

Here's a general way to do this with just cljr and grenadine: Install cljr and grenadine:

$ source <(curl -sL ) cljr grenadine
√ cljr v1.12.6 installed to /home/ingy/.local/bin/cljr (5.09s)
√ grenadine v0.1.14 installed to /home/ingy/.local/bin/grenadine (0.82s)
and (with a deps.edn file):
$ <<<'{:deps {medley/medley {:mvn/version "1.4.0"}}}' cat > deps.edn
$ CLOJURE_LOAD_PATH=$(grenadine --loadpath deps.edn) \
  cljr -e "(require 'medley.core) (prn (medley.core/index-by :id [{:id 1}]))"
{1 {:id 1}}
or all in one command:
$ CLOJURE_LOAD_PATH=$(grenadine --loadpath - <<<'{:deps {medley/medley {:mvn/version "1.4.0"}}}') \
  cljr -e "(require 'medley.core) (prn (medley.core/index-by :id [{:id 1}]))"
{1 {:id 1}}

πŸŽ‰ 1