Fork me on GitHub
David Pham08:12:29

It is really interesting :) You could use babashka as the cli tool then?

David Pham08:12:57

I am using deps.clj but this would replace it?


This won't replace it but uses deps.clj under the hood. I haven't really thought about CLI usage but this is a way to invoke clojure from a bb script.


We could have a bb clojure -Sdeps ... subcommand?



$ bb clojure
Clojure 1.10.2-alpha2
user=> (+ 1 2 3)
user=> ^D


This will be the first real subcommand I guess


This would I guess replace the deps.clj project, if people already have babashka installed. @neo2551


Merged bb clojure and babashka.deps add-deps + clojure to master now.

❤️ 6
David Pham10:12:18

This is really interesting. I think it provides an even better way to enter Clojure world!

David Pham10:12:10

What happens under the hood, if I might asked? Do we have an exact copy of deps.clj behavior?


Yes. It just invokes the deps.clj main.

David Pham10:12:30

It really helps a lot. I fear updated deps.clj in office

David Pham10:12:47

because I still remember the pain to get the required clojure tools jar from deps.clj


> I fear updated deps.clj in office could you explain more? this will still download the required clojure tools jar

David Pham10:12:35

In office, we are blocked by a proxy and so the installation process for deps.clj is more invovled, we can't perform http request from terminal. So we have to download the jar manually. It would be beneficial to have a link showing us which dependencies we can download manually and put in the .clojure/.deps folder (I don't remember precisely).


@neo2551 The newer deps.clj will print this when it can't download the jar:

Could not find /Users/borkdude/.deps.clj/
Attempting download from 


That should be sufficient info to fix it manually

David Pham11:12:45

Thanks a lot!

David Pham11:12:04

I am sorry for bothering you with these silly problems.


Not at all, it's exactly the pain I'm trying to solve with this

David Pham11:12:05

Babashka and deps.clj were critical for passing the Clojure pill in my team.

David Pham11:12:34

It made installation and trying stuff so much "easier" because now it was reachable without any additional admin rights.


That's very good to hear


Pushed docs for babashka.deps/add-deps here: Will write some docs for the rest

🎉 15

Hey folks 🙂 I was just wondering if anyone is using babashka + nREPL + pretty printing? Not sure if bb's nREPL supports the same pretty printing keys as JVM nREPL :thinking_face:


@olical Do you mean cider-pprint-eval-expr or something named like that?


There is a PR here with some open questions:


Ohh interesting! Thanks a lot, this is helpful. Was just interested in the state of this concept 🙂 I had someone ask me about it RE Conjure the other day and I just had no idea.


Feel free to dig in. Still waiting on a reply from Bozhidar but maybe you will have some ideas as well


So one thing I'm currently wondering about: How can I introduce "sub-commands" like bb clojure -M -e "(+ 1 2 3)" (and possibly also bb uberscript ... etc without conflicting with similarly named scripts. E.g. if there is a file clojure or uberscript (without an extension), this will conflict with the sub-command. Should I just go with: bb --clojure -M -e "(+ 1 2 3)" ?


Maybe --clojure is good enough and I should just let go of "nicer looking" subcommand idea


@borkdude bb exec <subcommand> perhaps? (to borrow from ruby's bundler) Although I'm not 100% clear what the sub-commands would do :-)


exec is then a subcommand itself which doesn't solve the problem I was wondering about :)


since exec is a posix/bash/etc builtin - unlikely you'll have naming clashes


as opposed to any other name


bb exec clojure -M ....
bb clojure -M ...
bb --clojure -M ...
bb exec uberjar -m -cp $(clojure -Spath) -ofoo.jar
bb uberjar -m -cp ... -o foo.jar
bb --uberjar foo.jar -m -cp ...


I take it back, it looks bad


--uberjar makes it obvious what's going to happen


Yeah, and bb --help is pretty clear what is the expected way of passing the args, so keeping the --clojure hyphened style is probably best


tools like clojure and curl only take - or -- commands, but no subcommands. git and docker always take a subcommand I think


Also --foo is unlikely to conflict with any file


I'm afraid the sub-command ship has sailed


Yeah and I'm alright with that. bb in its simplest use doesn't need a subcommand.


unless you release a breaking change version


We can make it non-breaking


we can prioritize files over the subcommand name but this will be very confusing


reminds me of nodes require working with dirs or files because it tries to be clever


and leads to weird issues


alright, --clojure it is then.


I really appreciate the feedback from this channel, helping me think into the right direction


explanation in the help output:


  --uberjar    <jar>  Similar to --uberscript but creates jar file.


  --clojure [args...] Invokes clojure. Takes same args as the official clojure CLI.


If anyone wants to try it, there are binary downloads in #babashka_circleci_builds :

$ bb --clojure -M -e "*clojure-version*"
{:major 1, :minor 10, :incremental 2, :qualifier "alpha2"}

👍 3

One of the last things I want to consider for now for babashka.deps / tools.deps related usage within bb: Setting the default classpath for a bb "project" This isn't very nice:

$ bb --classpath $(bb --clojure -Spath -Sdeps "{:deps {medley/medley {:mvn/version \"1.3.0\"}}}")
We can already do this from within a file (on master):
(require '[babashka.deps :as deps])
(deps/add-deps '{:deps {medley/medley {:mvn/version "1.3.0"}}})
Options: - automatically read deps.edn if present. Have a --deps-aliases argument to modify the classpath using aliases. Not my favorite option, since it will change current behavior and typically you will have a different set of deps for bb and clj when bb is used for scripting inside a JVM project. - separate babashka.edn with :deps and :paths. Set classpath when present. Maybe also support command line aliases, although I'm not sure if someone is going to different sets of deps for one script. - Maybe leave this out for now, since programmatic setting of the classpath using babashka.deps and babashka.classpath is sufficient


I think we have enough to get started with. Just published 0.2.5:


arch updated 🙂

🎉 3

This is awesome. Looking forward to playing with it.


Thanks for the useful feedback. Hope we got it right the first time ;)


Crazy idea: is there a possible future where bb doesn't even need Java to add deps? Would this mean we have to get the entire t.d.a. stuff to graal compile?


@nate I've been experimenting with that: but I haven't quite figured it out yet.


The README is out of date. But you'll likely run into a different issue


Tried again but doesn't really finish compiling...


Ah cool. Everywhere I use bb, I have the jvm, and I suspect that's the common situation.


Yeah. babashka.deps assumes a JVM. You don't have to use it, but it's convenient. And due to caching, it's fast when your deps are already downloaded and the classpath has been calculated before.