Fork me on GitHub
#babashka
<
2022-10-18
>
macrobartfast04:10:18

Is babashka in apt repositories (for Ubuntu)? I’m helping someone install Babashka. (or perhaps suggest the best route for them… maybe the curl?)

seancorfield04:10:58

According to https://github.com/babashka/babashka#installation it seems (Linux) Brew or curl are the recommended choices.

seancorfield04:10:37

I use brew for Ubuntu but only for Clojure tool installs -- brew is too opinionated for other stuff, IMO.

macrobartfast01:10:54

I didn’t know Brew is on non-mac platforms… thanks!

macrobartfast01:10:14

They ended up curling it but they’ll have to remember to update it.

Georgi Stoyanov06:10:21

Hi guys, Is it possible in babashka to use external for clojure libraries? I have a simple file that want to convert to script which I want to execute from the terminal. I have two dependencies -> net.cgrand.enlive-html and morse.api

teodorlu06:10:36

quick reply from me - borkdude can give the "correct response" later if he wants to: 1 - you can use any babashka-dependencies directly. Here's an example from my stuff:

(require '[babashka.deps :as deps])
(deps/add-deps '{:deps {org.babashka/cli {:mvn/version "0.3.31"}
                        eu.teod/pandoc-toolbox {:local/root "../pandoc-toolbox"}}})
(require '[babashka.cli :as cli]
         '[babashka.fs :as fs]
         '[clojure.java.shell]
         '[clojure.string :as str]
         '[clojure.edn :as edn]
         '[clojure.pprint :refer [pprint]]
         '[cheshire.core :as json]
         '[teod.pandoc-toolbox :as pandoc])
(https://github.com/teodorlu/play.teod.eu/blob/0792c7a05503dc201f6c488ce19a01ab7e92ce6d/play.clj#L23-L33) 2 - for babasha-incompatible dependencies, there are pods A pod is a protocol to talk from a babashka-script to a library written in some other way. Pod docs: https://book.babashka.org/#pods

1
Georgi Stoyanov06:10:29

thank you, I'll try the first approach you mentioned

borkdude07:10:21

enlive doesn't work in bb due to the Jsoup dependency but there are pods that do work with bb for parsing HTML: the bootleg pod for example

1
borkdude07:10:35

You can specify deps as above but also in bb.edn similar to deps.edn

1
1
borkdude07:10:15

If Node.js is an option for you, there's also #nbb which gives access to NPM libraries. Here is an example of that: https://github.com/babashka/nbb/blob/main/examples/posthtml-parser/example.cljs

borkdude16:10:57

Version 1.0.164 now building... The first non-0.x.x release... loading

babashka 5
🎉 1
richiardiandrea17:10:11

Question, can bb work if I include a bb.edn from another bb.edn (as local/root)?

richiardiandrea17:10:43

I get

Error building classpath. Manifest type not detected when finding deps for acuity/scripting in coordinate #:local{:root "/home/cokap/git/cohesic/acuity/scripting"}
But maybe I am missing something

lispyclouds17:10:34

we dont support local/root in bb.edn not a part of its spec.

lispyclouds17:10:50

as in look for a bb.edn when specified in a local/root

lispyclouds17:10:49

you could maybe do :paths ["other repo path"] and then you can require namespaces from that?

borkdude17:10:56

:local/root is supported in bb.edn but the local/root you are referring to has to have deps.edn

👍 1
borkdude17:10:37

bb.edn dependencies are only considered for the local working directory, not for resolving other dependencies, that always goes via deps.edn

👍 1
richiardiandrea18:10:13

Thank you both that is clear now

richiardiandrea19:10:02

I made it work, the only oddity is that the :pods declaration need to stay in the parent if I want to be able to exec :tasks

borkdude20:10:35

@U0C8489U6 There is ongoing work to support pod manifests in libraries so in the future I hope that will be easier (cc @U06FS3DLH)

👍 2
escherize21:10:45

I am having some problems with dependency resolution, and I don’t want to make my users have to use -Sforce to overcome it. I hope there’s a better way. I am trying to use a dependency from maven, here’s a minimal example:

{:deps {clojure-term-colors/clojure-term-colors {:mvn/version "0.1.0"}}
 :tasks {red {:requires ([clojure.term.colors :as c])
              :task (println (c/red "hi"))}}}
If I run: rm -rf ~/.m2 && bb red, I get the following error:
----- Error --------------------------------------------------------------------
Type:     java.nio.file.NoSuchFileException
Message:  /Users/me/.m2/repository/clojure-term-colors/clojure-term-colors/0.1.0/clojure-term-colors-0.1.0.jar
Location: <expr>:4:47
Running rm -rf ~/.m2 && bb -Sforce red works. It seems like whenever the library is missing it should get downloaded, but that is not the case. What am I missing?

borkdude21:10:11

This is expected. The clojure CLI and also babashka (via deps.clj) cache their classpath for performance/startup time reasons. These caches aren't aware of anything you delete manually from .m2

escherize21:10:43

Alright, thanks for explaining that. My colleague is seeing something different, when he moves his ~/.m2 dir and runs bb -Sforce red, he gets:

...
Downloading: org/clojure/spec.alpha/0.3.218/spec.alpha-0.3.218.jar from central
Downloading: ...
Downloading: clojure-term-colors/clojure-term-colors/0.1.0/clojure-term-colors-0.1.0.jar from clojars
Error while executing task:
Which I just can’t fathom, but it must be coming from here: https://github.com/babashka/babashka/blob/4aa352c94ac9885a1ee896679104dd2461220e2d/src/babashka/impl/tasks.clj#L53

escherize21:10:28

Would this indicate an error happening before the task is loaded? I’ll keep digging

borkdude21:10:03

You could maybe just put that code in a standalone script , to exclude anything task related

borkdude21:10:54

Perhaps something is going wrong while downloading the dependency

borkdude21:10:13

You could also try do to the same with JVM Clojure and see what happens

escherize21:10:22

Good idea, I’ll try that out!

escherize17:10:13

Thanks a lot, that is super helpful

escherize17:10:31

It ended up being a problem on my end (of course). 🙇