babashka

https://github.com/babashka/babashka. Also see #sci, #nbb and #babashka-circleci-builds .
2020-12-13T08:53:29.220Z

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

2020-12-13T08:53:57.220600Z

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

borkdude 2020-12-13T09:49:45.221300Z

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.

borkdude 2020-12-13T09:50:08.221700Z

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

borkdude 2020-12-13T10:17:55.221900Z

Pushed:

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

borkdude 2020-12-13T10:21:03.222200Z

This will be the first real subcommand I guess

borkdude 2020-12-13T10:22:27.222600Z

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

borkdude 2020-12-13T10:45:16.223300Z

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

❤️ 2
2020-12-13T10:52:18.224200Z

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

2020-12-13T10:53:10.225Z

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

borkdude 2020-12-13T10:53:36.225600Z

Yes. It just invokes the deps.clj main.

2020-12-13T10:55:30.226800Z

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

2020-12-13T10:55:47.227400Z

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

borkdude 2020-12-13T10:56:48.227800Z

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

2020-12-13T10:59:35.230200Z

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).

borkdude 2020-12-13T11:01:21.230600Z

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

Could not find /Users/borkdude/.deps.clj/1.10.1.763/ClojureTools/clojure-tools-1.10.1.763.jar
Attempting download from <https://download.clojure.org/install/clojure-tools-1.10.1.763.zip>

borkdude 2020-12-13T11:01:54.230900Z

That should be sufficient info to fix it manually

2020-12-13T11:03:45.231100Z

Thanks a lot!

2020-12-13T11:04:04.231400Z

I am sorry for bothering you with these silly problems.

borkdude 2020-12-13T11:04:19.231900Z

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

2020-12-13T11:05:05.232500Z

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

2020-12-13T11:05:34.233200Z

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

borkdude 2020-12-13T11:05:47.233400Z

That's very good to hear

borkdude 2020-12-13T11:11:59.233900Z

Pushed docs for babashka.deps/add-deps here: https://book.babashka.org/master.html#_add_deps Will write some docs for the rest

🎉 5
borkdude 2020-12-13T11:56:39.234200Z

Docs for clojure: https://book.babashka.org/master.html#_clojure

Olical 2020-12-13T14:01:18.235900Z

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:

borkdude 2020-12-13T14:12:08.236Z

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

borkdude 2020-12-13T14:12:58.236100Z

There is a PR here with some open questions: https://github.com/babashka/babashka.nrepl/pull/33

Olical 2020-12-13T14:58:09.236800Z

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.

borkdude 2020-12-13T14:58:38.237Z

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

borkdude 2020-12-13T16:23:53.239300Z

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)" ?

borkdude 2020-12-13T16:27:30.240700Z

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

lukasz 2020-12-13T16:28:01.241300Z

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

borkdude 2020-12-13T16:29:13.241800Z

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

lukasz 2020-12-13T16:29:38.242300Z

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

lukasz 2020-12-13T16:29:57.242600Z

as opposed to any other name

borkdude 2020-12-13T16:32:56.244Z

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

lukasz 2020-12-13T16:33:12.244200Z

hmmm

lukasz 2020-12-13T16:33:17.244400Z

I take it back, it looks bad

lukasz 2020-12-13T16:33:35.244900Z

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

borkdude 2020-12-13T16:34:10.245600Z

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

borkdude 2020-12-13T16:35:02.246500Z

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

borkdude 2020-12-13T16:35:31.246900Z

Also --foo is unlikely to conflict with any file

lukasz 2020-12-13T16:35:57.247300Z

I'm afraid the sub-command ship has sailed

borkdude 2020-12-13T16:36:38.248400Z

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

lukasz 2020-12-13T16:36:40.248500Z

unless you release a breaking change version

borkdude 2020-12-13T16:36:50.248700Z

We can make it non-breaking

borkdude 2020-12-13T16:37:17.249200Z

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

lukasz 2020-12-13T16:37:23.249400Z

indeed

lukasz 2020-12-13T16:37:50.250200Z

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

lukasz 2020-12-13T16:37:56.250400Z

and leads to weird issues

borkdude 2020-12-13T16:38:00.250600Z

alright, --clojure it is then.

borkdude 2020-12-13T16:49:34.251Z

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

borkdude 2020-12-13T16:53:07.251300Z

explanation in the help output:

Uberjar:

  --uberjar    &lt;jar&gt;  Similar to --uberscript but creates jar file.

Clojure:

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

borkdude 2020-12-13T17:16:06.252Z

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"}

👍 1
borkdude 2020-12-13T19:08:54.255900Z

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

borkdude 2020-12-13T19:15:16.257200Z

Made an issue for this here: https://github.com/borkdude/babashka/issues/680

borkdude 2020-12-13T20:03:45.257900Z

I think we have enough to get started with. Just published 0.2.5: https://github.com/borkdude/babashka/blob/master/CHANGELOG.md#v025

dharrigan 2020-12-13T20:08:03.258300Z

arch updated 🙂

🎉 1
nate 2020-12-13T20:18:32.259Z

This is awesome. Looking forward to playing with it.

borkdude 2020-12-13T20:37:18.259200Z

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

nate 2020-12-13T20:40:27.261400Z

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?

borkdude 2020-12-13T20:42:06.261900Z

@nate I've been experimenting with that: https://github.com/borkdude/tools-deps-native-experiment but I haven't quite figured it out yet.

borkdude 2020-12-13T20:42:49.262600Z

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

borkdude 2020-12-13T20:42:54.262800Z

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

nate 2020-12-13T21:13:00.264Z

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

borkdude 2020-12-13T21:39:11.264800Z

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.