To summarize, I put the above script in a file test_bb_requires.clj, ran bb against it, and checked that BABASHKA_CLASSPATH doesn’t exist before and after. Then I ran your sample on the command-line which works fine:
bash-3.2$ echo $BABASHKA_CLASSPATH
bash-3.2$ bb test_bb_requires.clj
java.lang.Exception: Could not require java-time. [at /Users/me/..../mydir/test_bb_requires.clj, line 16, column 1]
bash-3.2$ echo $BABASHKA_CLASSPATH
bash-3.2$ export BABASHKA_CLASSPATH=$(clojure -Sdeps '{:deps {henryw374/cljc.java-time
{:git/url "<https://github.com/henryw374/cljc.java-time.git>"
:sha "e3d184b78e933322b3fcaa6ca66cbb8f42a6b35c"}}}' -Spath)
> > bash-3.2$ bash-3.2$ bb -e "(require '[cljc.java-time.local-date :as ld])"
bash-3.2$ java -version
java version "1.8.0_112"
Java(TM) SE Runtime Environment (build 1.8.0_112-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.112-b16, mixed mode)
(MacOS 10.13.6) Thanks!Note that you are requiring a different namespace in the first example, but apart from that, I can reproduce your issue now. I'll look into it.
This example works for me:
(require '[babashka.classpath :refer [add-classpath]]
'[clojure.java.shell :refer [sh]]
'[clojure.string :as str])
(def added-deps
'{:deps {cljc.java-time {:git/url "<https://github.com/henryw374/cljc.java-time.git>"
:sha "e3d184b78e933322b3fcaa6ca66cbb8f42a6b35c"}
medley {:git/url "<https://github.com/borkdude/medley>"
:sha "91adfb5da33f8d23f75f0894da1defe567a625c0"}}})
(def cp (:out (sh "clojure" "-Spath" "-Sdeps" (str added-deps))))
(add-classpath (str/trim cp))
(require '[cljc.java-time.local-date :as ld])
Somehow I needed to trim the classpath to get rid of the newline
So it turns out it was in fact loading macrovich, but the part on the path had appended a new line for that .jar file
I adapted the README accordingly
Fixed indeed, thanks! I was wondering if others encountered the same newline issue. Regarding the wrong ns name, I think I was trying to avoid the cljs call from an earlier try, sorry about that. Looking forward to discover and learn more from your work! Cheers..
@kingcode Cool. I think the cljc.java-time lib could maybe be optimized by not loading macrovich for babashka and/or clojure, since it's only relevant to cljs. Maybe the author will take a PR