Anyone have a clue why I get error Could not resolve symbol: clojure.lang.PersistentList
?
When doing
(def rop-dep '{:deps {rop/rop {:mvn/version "0.4.1"}}})
(def cp (-> (sh "clojure" "-Spath" "-Sdeps" (str rop-dep)) :out s/trim))
(add-classpath cp)
(require '[rop.core :as rop])
This is because not all classes are explicitly available for interop in babashka, they have to be manually added. Which library is this? (I'll be back in a bit)
@borkdude the library I am trying to use is https://github.com/druids/rop which depends on https://github.com/funcool/cats where persistentList is referenced here: https://github.com/funcool/cats/blob/master/src/cats/builtin.cljc#L143
@mozinator You're welcome to post an issue about this.
Maybe the rop and cats library might be too heavyweight for babashka scripts anyway. I found this solution to error handling which seems to cover most of what I need https://adambard.com/blog/acceptable-error-handling-in-clojure/
@borkdude what are your criteria for adding libraries to the included libraries in babashka ?
Do you think https://github.com/clj-commons/camel-snake-kebab would be a good candidate ?
camel-snake-kebab has been asked at least one time before. I'm willing to add it if more people ask for it in an issue.
You can read the criteria here: https://github.com/borkdude/babashka#including-new-libraries-or-classes
But since that lib can also be ran from source, there might not be a need to include it in babashka proper. This can be discussed in an issue though. So making an issue would be the first step.
I was trying out slingshot btw:
$ bb -e "(require '[slingshot.slingshot :as s]) (s/try+ (s/throw+ {:type ::foo}) (catch [:type ::foo] [] 1)))"
----- Error --------------------------------------------------------------------
Type: java.lang.ClassNotFoundException
Message: clojure.lang.RT
Location: <expr>:1:40
----- Context ------------------------------------------------------------------
1: (require '[slingshot.slingshot :as s]) (s/try+ (s/throw+ {:type ::foo}) (catch [:type ::foo] [] 1)))
^--- clojure.lang.RT
I'm not sure why this error appears, since I see no mention of clojure.lang.RT in the source code of slingshotI'll also make an issue for that.
Ah, found the issue. Not sure why this is happening.
$ bb -e '(alength (into-array []))'
----- Error --------------------------------------------------------------------
Type: java.lang.ClassNotFoundException
Message: clojure.lang.RT
Location: <expr>:1:1
----- Context ------------------------------------------------------------------
1: (alength (into-array []))
^--- clojure.lang.RT
`Maybe this uses reflection in Clojure?
(defn alength
"Returns the length of the Java array. Works on arrays of all
types."
{:inline (fn [a] `(. clojure.lang.RT (alength ~a)))
:added "1.0"}
[array] (. clojure.lang.RT (alength array)))
yap:
user=> (. clojure.lang.RT (alength (into-array [])))
Reflection warning, NO_SOURCE_PATH:1:1 - call to static method alength on clojure.lang.RT can't be resolved (argument types: unknown).
0
https://www.thoughtworks.com/podcasts/future-clojure#trans > Obviously, you have ClojureScript compiling JavaScript, which was something that we started and led at the beginning, but is now led primarily outside of Cognitect by David Nolan and others. And then, a variety of other dialects and things that people are doing like the babashka for shell scripting in Clojure and those kinds of things.
https://twitter.com/borkdude/status/1337164427095924737 <- the com.stuartsierra/dependency lib works with bb