Fork me on GitHub
#babashka
<
2024-03-08
>
jcd01:03:51

I'm trying to make a babashka script executable from anywhere on my system. I'm having difficulty because the classpath isn't being found when I call it not in the directory of the project root. I get an error like this:

❯ r.bb 4d8
----- Error --------------------------------------------------------------------
Type:     java.lang.Exception
Message:  Could not find namespace: dice-roller.roller.
Location: /home/jcd/Projects/dice-roller/r.bb:4:3

----- Context ------------------------------------------------------------------
1: #!/usr/bin/env bb
2: 
3: (ns r
4:   (:require
     ^--- Could not find namespace: dice-roller.roller.
5:    [dice-roller.roller :as r]
6:    ))
7: 
8: (prn (r/roll-dice-command (apply str *command-line-args*)))

----- Stack trace --------------------------------------------------------------
r - /home/jcd/Projects/dice-roller/r.bb:4:3
I suspect there is something silly I am doing wrong. Both the deps.edn and the bb.edn have :paths ["src"] declared, which works when I invoke the script from /home/jcd/Projects/dice-roller/. Any suggestions?

1
jcd01:03:45

updating babashka solved the issue

👍 1
marrs10:03:11

@borkdude Is it possible to create compiled binaries against Babashka? I don't just want a script that I can run against bb, I want an executable with everything baked into it. Preferably one that runs across different platforms and OS's

borkdude10:03:09

you can't make an executable that runs in all OSes, you have to make one for each OS, but you can easily do so from just 1 linux box and downloading the binaries for different OSes on that + the above method

wcohen14:03:26

I’ve got a bunch of text documents with content structured as jsons that I want to compile into some cleaner asciidoctor files, which I can then epub/pdf. Seems like a perfect babashka task. The text does include some inline formatting inside the strings inside the json’s contents, things like ["<b>Bolded text</b> and some unbolded text <i>and some italicized text</i>.", "Other content etc."] . I’d need to then replace these as two paragraphs in a new document, like:

*Bolded text* and some unbolded text _and some italicized text_.

Other content etc.
Suggestions for if I should go with regexp to replace tags, or some kind of conversion via hiccup/hickory and then back out to a joined string?

marrs17:03:22

If it's just a case of converting all tags to markdown, then a regex on the json will be adequate. I'd consider parsing the strings if things get trickier than that, e.g. if you only want to convert tags nested within a particular element, across multiple lines.

wcohen17:03:22

Makes sense. Thank you!

Yuhri Graziano Bernardes21:03:47

Hi everyone. Hope you're all doing great! I'm trying to setup a new project with a tools deps and babashka. I can be terribly wrong, but I remember seeing some sort of bb.edn config in which I could specify where my deps.edn file is and tell it to use an specific alias to get :paths and :deps from it. I've searched all over the babashka book, but I didn't find any reference to it 😓 Does anyone know if it's possible? Thank you in advance 🙂

borkdude21:03:28

You can use :local/root but this doesn't support aliases (ask in #C6QH853H8 to support that)

borkdude21:03:54

search the book for local/root and you will find it

babashka 1