Fork me on GitHub
#babashka
<
2022-11-18
>
oliy11:11:35

hello, i've done some searching but couldn't find an answer. i've got a bb.edn file with a :deps key which is all fine - on CI the dep gets pulled in and it all works. locally i recently deleted my .m2 directory because it got corrupted. babashka seems to think the deps are still there, because it doesn't attempt to download them and just blows up when running the script at the point it calls require on the dep. has it cached somewhere what it thinks is in my .m2 repo already? many thanks

✔️ 1
lispyclouds11:11:17

try deleting the .cpcache dir beside the bb.edn

oliy11:11:59

thanks for the suggestion - unfortunately doesn't work. i even deleted the entire repo and re-cloned it to get a completely fresh checkout and it still doesn't work 😞

lispyclouds11:11:28

could you paste the error youre seeing?

borkdude11:11:06

try -Sforce

borkdude11:11:15

or deleting ~/.clojure/.cpcache

oliy11:11:23

bb.edn looks like this

{:paths ["src"]
 :deps {org.babashka/cli {:mvn/version "0.2.16"}}}
file looks like this
(ns foo
  (:require [babashka.cli :as cli]))
and the error i get is
Type: NoSuchFileException
Message: ~/.m2/repository/org.babashka/cli/cli-0.2.16/0.2.16.jar
Location: ~/project/src/foo.clj

oliy11:11:38

thanks @U04V15CAJ i will try those

borkdude11:11:16

which bb version is this

oliy11:11:32

0.8.156 (but also seeing it on 0.8.0 and 0.8.2)

oliy11:11:00

ah, --force worked

borkdude11:11:10

but you probably mean 1.0.156 right

oliy11:11:43

no, 0.8.156. i'm inside a big institution, adopting new things is... slow...

😅 1
borkdude11:11:48

ok, it's ok

borkdude11:11:57

the newest bb should never have this problem anymore

borkdude11:11:06

since it checks for the jars to be present

oliy11:11:18

cool, thank you for the help! we will look into upgrading to a more recent version

Benjamin14:11:56

Hello can I check if the bb process is running a repl? I would like to exit my script on error but not while developing

borkdude15:11:02

@benjamin.schwerdtner You can do this:

(throw (ex-info "O no!" {:babashka/exit 1}))

2
partyparrot 1
skylize15:11:24

Awesome that bb can "just do that". For Clojure, I have this much bulkier solution, with the body of in-repl? mostly stolen from a StackOverflow answer. Makes a stack trace and checks that for some stack elements that should exist iff in a repl. I then have shutdown and die functions which print exit messages (with`die` binding *out* to *err*), and then pass an exit code to`exit`.

(defn in-repl? []
  (let [stack-trace (.getStackTrace (Thread/currentThread))
        repl-stack-element?
        (fn [elem] (and (= "clojure.main$repl" (.getClassName elem))
                        (= "doInvoke"          (.getMethodName elem))))]
    (some repl-stack-element? stack-trace)))

(defn exit [exit-code]
  (if (in-repl?)
    (println "-Aborting exit ( code " exit-code ") triggered by eval in REPL.")
    (System/exit exit-code)))

james16:11:21

I am using portal with the output of yaml/parse-string but the default viewer just shows

#ordered-map ()
instead the nice expanded display you get with edn. When I use this with clojure it looks a lot better
;; 
(def ^:private ipm-print-method
  (get (methods print-method) clojure.lang.IPersistentMap))
(defmethod print-method OrderedMap [o ^java.io.Writer w]
  (.write w "#ordered/map ")
  (ipm-print-method (seq o) w)))
I guess this would mean adding that class to babashka

james16:11:01

it's not a big thing but I guess most yaml derived data will have this issue. Wondering if anyone has a better solution.

borkdude16:11:31

you could just do a postwalk before sending it to portal

james16:11:21

thanks, I'll try that.

borkdude17:11:25

(into {} ordered-map) should solve it

james17:11:13

very nice, thanks borkdude,

Alys Brooks21:11:19

If a Java class isn't included in Babashka, it seems like my two options are recompiling Babashka with the class or creating a pod. Am I missing an option?

borkdude22:11:21

Can you be more specific?

borkdude22:11:37

Like, it depends if the class is generally useful enough for bb, we could also include it, but if it's pretty niche, then yes, those are the options you have with bb

Alys Brooks22:11:55

The class is part of Cucumber-JDK. I don't think it's widely applicable to Clojure projects.

borkdude22:11:06

hmyeah. what would be the purpose of adding it to bb? something kaocha related? there is also things like https://www.npmjs.com/package/@cucumber/cucumber which you could use with #nbb (the Node.js variant of bb)

Alys Brooks22:11:09

That's a good idea. I'm looking to add building our Cucumber feature docs to our Babashka tooling for releasing Kaocha

borkdude22:11:47

Just merged a commit to master which makes tools.namespace and cognitect test runner work with bb as is, so I can deprecate https://github.com/babashka/tools.namespace

🎉 6