Fork me on GitHub
#babashka
<
2022-02-23
>
Eugen09:02:26

I might have found an issue ?! Running this (as seen in example https://book.babashka.org/#tasks:clojure )

test {:doc  "Runs backend tests"
               :task (clojure {:dir "../bases/app"} "-J-Dclojure.main.report=stderr -M:backend:test")}
give me :
bb test 
----- Error --------------------------------------------------------------------
Type:     java.lang.IllegalArgumentException
Message:  'other' is different type of Path
Location: 20:11

----- Stack trace --------------------------------------------------------------
borkdude.deps/relativize    - <built-in>
borkdude.deps/-main         - <built-in>
clojure.core/apply          - <built-in>
babashka.deps/clojure       - <built-in>
babashka.impl.tasks/clojure - <built-in>

borkdude09:02:27

Can you post an issue about this? A workaround could be:

(shell {:dir "../bases/app"} "bb clojure -J-D.... -M:backend:test")

borkdude09:02:32

another workaround:

{:dir (fs/absolutize "../bases/app"}}

Eugen09:02:44

thanks, the issue was the path was wrong

Eugen09:02:04

I should have seen a file not found exception or something similar

Eugen09:02:33

it works with (clojure {:dir "../../bases/app"} "-J-Dclojure.main.report=stderr -M:backend:test")

Eugen09:02:39

should I still open an issue ?

borkdude09:02:48

aaah ok. issue still welcome for better error msg

Eugen09:02:48

I think so ...

Eugen09:02:38

using bb 0.7.4

viesti10:02:13

mmmm, remember seeing somewhere a snippet in bb to run nrepl client

sheluchin11:02:00

I'm back to playing with https://github.com/babashka/nrepl-client and using it for some slightly more advanced function calls from my tasks. I wonder if there's currently any way to avoid writing the expression as a string and instead working with code, and then stringifying that code. If I just do something like (str '(+ 1 2)) the quoted form isn't getting linted but at least there is syntax highlighting and code navigation is available. Is there some way to improve it more?

borkdude11:02:47

I'm not actively developing this at the moment, but feel free to post issues + PRs :)

sheluchin11:02:09

Understood, thanks. It's been so far so good. I've been using it for running project tasks through bb tasks and there hasn't been much to complain about aside from the ergonomics of it.

borkdude11:02:54

Issues welcome :)

๐Ÿ‘ 1
borkdude11:02:56

@ all: I'm developing a zip function for babashka.fs : https://github.com/babashka/fs/commit/0222dba20f9babc032f79c2c0c008471f164ec28 It's largely based off the code in tools.build but it resembles unix zip more:

zip /tmp/out2.zip src README.md
=>
(fs/zip "/tmp/out2.zip" ["src" "README.md"])
Also within the zip the src dir is preserved whereas tools.build flattens the src-dirs into the zip. So src/babashka will be babashka in the zip in tools.build but with fs/zip it remains src/babashka. These are trade-offs to make. I'd like your input on this! ๐Ÿงต

borkdude11:02:05

Also, please take that branch for a local spin

borkdude13:02:27

Hm, it seems

shutil.make_archive(output_filename, 'zip', dir_name)
does flatten the directory

borkdude13:02:50

I made an issue here: https://github.com/babashka/fs/issues/41 Please discuss there.

๐Ÿ‘ 1
Benjamin14:02:52

can I use clojure.core.reducers in bb? I'm thinking if I have some easy ways to make my script faster in some transduction part

borkdude14:02:37

it's not included at the moment

ghadi14:02:45

clojure.core.reducers is 95% subsumed by transducers

ghadi14:02:19

the only thing c.c.reducers has that hasn't been replicated anywhere else is the Fork Join / fold stuff

Benjamin15:02:21

ah that's interesting. Yea I was thinking about the fork join stuff. I guess there is some way to transduce parallel? - the use case is basically reduce xform coll .

borkdude16:02:48

Let me phrase the above question differently. Have you shelled out to zip or implemented your own zip function based on java.util.zip in bb before and how did you use this? This should inform the API of that new function. Issue here:ย https://github.com/babashka/fs/issues/41

teodorlu20:02:06

Wrote a tiny bb script, amazed at how good + easy it was to get going. Read the book, and had a tiny file watcher running while I developed:

find .local/bin | entr -rc which+ smallid
(http://eradman.com/entrproject/ is awesome). Good error messages, and totally weird not to have to worry about the REPL. The script essentially helps me find stuff I've symlinked, reducing two commands to one:
which+ smallid

$ which smallid
/home/teodorlu/.local/bin/smallid

$ ls -l $(which smallid)
lrwxrwxrwx 1 teodorlu teodorlu 49 2022-02-14 17:04 /home/teodorlu/.local/bin/smallid -> /home/teodorlu/kb/setup/python-scripts/smallid.py

borkdude20:02:24

Awesome :) Note that babashka.fs also has a which function and also has a function to detect if something is a symlink and to resolve the symlink. So there's in fact no need to shell out to bash :)

๐Ÿ’ฏ 2
borkdude20:02:31

$ bb -e '(fs/sym-link? (fs/which "clojure"))'
true

borkdude20:02:51

$ bb -e '(str (fs/real-path (fs/which "clojure")))'
"/usr/local/Cellar/clojure/1.10.3.1058/bin/clojure"

teodorlu20:02:21

Nice! More to learn ๐Ÿ™‚ I suspect I'll write some ugly shelling before catching onto idiomatic solutions.

borkdude20:02:45

That's totally fine

clojure-spin 1
jaide22:02:10

Any HTML parsing libs that are compatible with bb and don't require pods?

borkdude22:02:27

@jayzawrotny No HTML parsers from source or built-in. Bootleg is one that's used a lot but that is a pod.

borkdude22:02:52

You can also use #nbb for this obviously :)

jaide22:02:48

Thanks. A friend was asking in a discord, I recommended nbb to him but doesn't sound like it would fit either.

jaide22:02:19

Allegedly pods are off the table for them. Don't know much about their project: > rushsteve1 โ€” Today at 5:07 PM > Unfortunately I can't really use pods (I'm trying to use bb to fix my > whole cross-compiling issue) > nbb seems interesting, but I'm not sure if I can use Node either

borkdude22:02:58

you don't need to cross-compile yourself to use pods, they are already compiled and even download automatically

borkdude22:02:44

here's the registry of pods that are ready to be used: https://github.com/babashka/pod-registry

jaide22:02:06

Sounds like they're looking for something more along the lines of jsoup

jaide22:02:44

> rushsteve1 โ€” Today at 5:21 PM > I have yet to find one that supports aarch64 OOTB. Looking at the Jsoup on in the link you sent it seems like you also need GraalVM to compile it too. > I have the same problem with the SQLite pod

borkdude22:02:40

Not all pods work on aarch64 because I usually only do that when people ask for it, but it can be done.

borkdude10:02:11

@U1QQJJK89 Perhaps bootleg (pod) can be exposed as aarch64 as well?

borkdude22:02:54

E.g. the aws pod does work on aarch64 out of the box.

borkdude22:02:40

But of course they could also just use the JVM. I'd also recommend Jsoup