babashka

https://github.com/babashka/babashka. Also see #sci, #nbb and #babashka-circleci-builds .
borkdude 2021-03-25T11:27:33.175100Z

Rewrote task DSL to a more hiccup-style syntax: https://github.com/babashka/babashka/discussions/757#discussioncomment-529074

2021-03-25T11:40:51.175200Z

nice!

borkdude 2021-03-25T11:44:34.175400Z

This is especially convenient for inline tasks:

[:do
  [:shell "clojure" "-M:outdated:nop:1.8" "--exclude=clojure/brew-install"]
  [:shell "clojure" "-M:dev:1.9:test"]
  [:shell "clojure" "-M:dev:test"]]

2021-03-25T13:44:36.175600Z

Yeah looks good! And I guess you can have :and or :or this way too. Very concise!

borkdude 2021-03-25T13:46:45.175800Z

:do is :and as in, it will shortcut on the first failing job. not sure about :or since or in clojure shortcuts on the first truthy value which is not common with tasks

2021-03-25T13:54:57.176Z

ah yeah I see. :&& and :|| also seem to be valid symbols. But might be to bash-y for babashka :)

borkdude 2021-03-25T13:55:34.176200Z

I considered those, but they don't work inside the command line as they will be picked up by bash

2021-03-25T13:56:25.176400Z

Will this syntax also be usable from the command line?

borkdude 2021-03-25T13:56:57.176600Z

That is what I initially supported with :do:

bb :do :foo 1 2 3 :and-do :bar 1 2 3

borkdude 2021-03-25T13:57:12.176800Z

but this is not longer supported now with the rewrite to hiccup

borkdude 2021-03-25T13:57:19.177Z

so probably not

2021-03-25T14:00:01.177200Z

I’m guessing the following will also be valid? (the last :do part)

{:paths ["test-resources/bb-edn"]
 :deps {medley/medley {:mvn/version "1.3.0"}}
 :tasks {:shell1 ^{:description "Echo hello"}
         [:shell "echo" "hello"]
         :shell2 ^{:description "Echo bye"}
         [:shell "echo" "bye"]
         :medley ^{:description "Show off medley"}
         [:babashka -e (do (require (quote [medley.core :as m]))
                           (m/index-by :id [{:id 1} {:id 2}]))]


         :shell-all [:do :shell1 :shell2]}

 
 ,}

borkdude 2021-03-25T14:00:34.177400Z

[:do [:shell1] [:shell2]]
that already works

2021-03-25T14:00:53.177600Z

Nice 🙂

ericdallo 2021-03-25T20:19:14.179100Z

I just want to say how cool, easy and incredible was to implement integration-tests in clojure-lsp using babashka:

❤️ 3
grazfather 2021-03-26T12:44:08.202400Z

I want to do this at work but there would be too much opposition 😢

onetom 2021-03-26T15:45:56.203Z

@grazfather sounds like you are at the wrong place 🙂 what's your opposition's reasoning, btw? maybe there wouldn't be that much opposition, you are just assuming it? also, try it for yourself first on some of the work problems you have and maybe you will realize that some of the reluctance is well-founded... for example in the company i work for, we still have tension because of the different editors and the lack of consistent code-formatting tools for clojure.

grazfather 2021-03-26T15:47:12.203200Z

just bringing in a new language is always difficult. I use babashka for my own purposes

ericdallo 2021-03-25T20:20:06.179800Z

(BTW It's really incredible how fast sci return an error if there is something not right in your code)

Tomas Brejla 2021-03-25T20:26:54.184300Z

(not sure whether its better to ask here on in #calva, but I'll try this channel first, as the question is also very bb-specific) When I open bb --nrepl-server and then connect to nrepl port 1667 in calva, the editor is offering code completion for namespaces, imports of java classes, function names etc. But it's not able to offer function parameter names/positions, function docs etc. Is there any way of getting this functionality in calva when connected against bb's nrepl server?

borkdude 2021-03-26T09:29:50.200400Z

nice!!

pez 2021-03-26T09:38:37.200600Z

Awesome. Don’t hesitate to ask me for help if there is anything on the VS Code end of that that you think I can shed some light on. The nrepl “contract” I don’t know as much about as one would think. It has mostly just worked for me and I’ve been reverse engineering CIDER when I wonder about how to do some particular thing.

borkdude 2021-03-26T09:39:33.200900Z

The info op doesn't seem to be documented. https://nrepl.org/nrepl/ops.html @bozhidar should it be?

Tomas Brejla 2021-03-26T11:01:06.201100Z

I was mostly trying to look up the structure and value types from cider-nrepl 's tests https://github.com/clojure-emacs/cider-nrepl/blob/a7d24bc91028b78eda2f73a6d3f17c53495a84da/test/clj/cider/nrepl/middleware/info_test.clj#L85-L255

bozhidar 2021-03-26T11:20:49.201500Z

@borkdude There's no info op in nREPL - that's in cider-nrepl. The nREPL op is named lookup.

borkdude 2021-03-26T11:22:37.201700Z

@bozhidar should calva then use the lookup op if info is not available? and what should be in this map? > Returns :info A map of the symbol’s info. The doc is pretty handwavey here.

borkdude 2021-03-26T11:23:13.201900Z

Is lookup the same as info?

bozhidar 2021-03-26T11:23:40.202100Z

Everyone should use lookup if info is not available. As for the :info map - I agree it needs more documentation.

borkdude 2021-03-27T09:59:15.207100Z

@bozhidar So maybe it's best if @brdloush exposed his new op as both info and lookup? Are they drop-in replacements?

bozhidar 2021-03-27T12:10:36.208100Z

The API is the same and I think it's fine to expose both as aliases. Eventually I'll rename cider-nrepl's op cider/info to it's clearer that it's not built-in, but I don't have any concrete roadmap for this. Not sure how many client have been updates to support lookup by now, as it's still pretty new.

borkdude 2021-03-27T12:25:09.208300Z

ok cool. copy that @brdloush? :)

Tomas Brejla 2021-03-27T17:19:52.219800Z

@borkdude copy @pez I have some issue with calva not showing the docs on code completion. At some point, I managed to see the completion options in that way, that both the argument list and documentation reside in their own popup window (first screenshot). But now I'm always getting just a single-window code completion popup, where the parameters are included in that single window. (second screenshot)

Tomas Brejla 2021-03-27T17:21:11.220400Z

And I just don't see why the code completion is now getting rendered in that single-window form instead of two-window form. Any hint appreciated 🙂

Tomas Brejla 2021-03-27T17:23:02.220600Z

aaaaah, I am soooo stupid 😄. All I had to do was to CLICK that area with params 😄

pez 2021-03-27T17:24:18.220800Z

Is that a babashka repl?

Tomas Brejla 2021-03-27T17:31:02.221Z

yes

Tomas Brejla 2021-03-27T17:41:18.221200Z

aaah, the shortcut to switch between the single-window and multi-window code completion is ctrl+space. Now I understand how it happened that I accidently switched between the two modes 🙂

Tomas Brejla 2021-03-27T18:08:11.221400Z

After a few fixes, It's starting to behave as I'd like. https://www.youtube.com/watch?v=BxR5oE9pKAI I'll do some more testing in the evening and hopefully file a PR.

pez 2021-03-27T18:17:22.222400Z

So beautiful. You are a hero!

borkdude 2021-03-27T18:30:02.222600Z

awesome :)

borkdude 2021-03-25T20:29:26.184800Z

I think this issue is related to this: https://github.com/babashka/babashka.nrepl/issues/30

borkdude 2021-03-25T20:30:30.186600Z

I'm open to receive a PR for this

borkdude 2021-03-25T20:31:46.188200Z

These nrepl ops are currently supported:

#{"clone" "close" "eval" "load-file"
                                              "complete" "describe" "ls-sessions"
                                              "eldoc"}
I think eldoc comes relatively close and might offer you some insight in how to implement the other one

borkdude 2021-03-25T20:32:15.189Z

Thanks man, this is always nice to hear

❤️ 1
pez 2021-03-25T20:33:12.190400Z

@brdloush Calva relies on cider-nrepl and clojure-lsp for these things. So far there is no cider-nrepl in babashka's nrepl server, and clojure-lsp needs dependency info. You might get away with creating a deps.edn file with the dependencies you use. At least for some of the functionality.

borkdude 2021-03-25T20:34:00.190500Z

^ @pez is the above issue still relevant?

pez 2021-03-25T20:36:34.191300Z

Oh, yes. Would be magical!

2021-03-25T21:34:08.193100Z

I tried running the following script on Windows under Git Bash, but using Windows-native bb.exe as installed by Scoop:

#!/usr/bin/env bb
(println "Hello, world")

2021-03-25T21:34:48.193900Z

This script failed for me with the following error:

Message:  File does not exist: /cygdrive/c/Users/blah/bin/hello

2021-03-25T21:35:58.194900Z

The problem is that the native bb doesn’t recognize Cygwin paths. My solution was to create a script called bbw on my Cygwin path:

#!/bin/bash
SCRIPT=$1
shift
bb.exe $(cygpath -w $SCRIPT) $@

2021-03-25T21:36:25.195500Z

…then change the shebang in my original script to use bbw:

#!/usr/bin/env bbw

2021-03-25T21:36:47.195900Z

Would this be a common enough problem to note in the Babashka book?

onetom 2021-03-26T15:39:48.202600Z

@jkrasnay this sounds like a niche problem caused by social/organizational issues ("We can’t install WLS2 on our work machines"). instead of silently trying to overcome a social issue with software workarounds (further complicating the existing software, what's already hyper complicated, i guess), i would try to attack this problem from a social angle and solve it that way. and if you can't change the organization around you, then u should probably start looking for other ventures, which value your lifetime more and let you solve more impactful problems. these kind of rigid companies deserve to wither away; better u don't help keeping them alive... :)

✅ 1
2021-03-26T16:20:05.203500Z

I dunno, I think restricting admin access is just prudent security policy, not necessarily the sign of a rigid company that deserves to wither away.

borkdude 2021-03-26T16:32:22.203700Z

This is the case in many companies, it's always nice to have escapes

onetom 2021-03-31T16:46:16.273900Z

i've excused myself from the ms windows world decades ago, so i don't have up-to-date insights on this topic. what's wrong with allowing the installation of WSL2? @jkrasnay do you agree that it's a "prudent security policy" to disallow installing WSL2 (which is an official part of the OS, just not installed by default, if i understood correctly)? are you sure that they specifically disallow WSL2 or you were just denied by reflex? is there any documentation available about this decision to the employees? if not, then sorry, it's a shit company; let

onetom 2021-03-31T16:46:24.274100Z

let's not try to sugar coat it...

borkdude 2021-03-31T17:08:30.280400Z

@onetom Please don't be rude and respect other people's choices, or not, but I don't see a need to nag them about it.

👍 1
onetom 2021-03-31T17:36:34.297900Z

all im saying is, don't just give in so easily. many limitations are self-imposed. often u just have to ask and you will receive. and DO be a bit of a pain in the ass sometimes, because that little extra push is all that's necessary for other people to realize their own self-imposed limitations. meaning, however is the gatekeeper for the WSL2 installation, might give in and think about it for a few minutes, if asked every week 4 times in a row. demand a clear explanation the very least. @borkdude is it less rude if i put it this way? i've noticed that my threshold for directness and abrasiveness differs from other nations' thresholds. i never had such issues with ppl from eastern-europe...

borkdude 2021-03-31T17:38:54.298100Z

Fair points, but you don't always know the situation people are in and they might have good reasons to be very conservative with what people can install on certain systems with e.g. sensitive information. My wife works for a company that deals with patient information and some environments she works in are very strictly controlled. I think you made your point well, thanks for clarifying.

❤️ 1
borkdude 2021-03-25T21:40:25.196Z

So why does bb.exe not recognize that path?

borkdude 2021-03-25T21:41:01.196200Z

cygpath -w translates it to a Windows path?

borkdude 2021-03-25T21:41:44.196400Z

I think adding it to the book might be good. Maybe we can have a troubleshooting chapter

borkdude 2021-03-25T21:42:10.196600Z

Or under "recipes" we can add a cygwin section

borkdude 2021-03-25T21:42:52.196800Z

Maybe your script can just be called bb so you can run scripts cross platform without changing the shebang

2021-03-25T21:43:15.197Z

My bb.exe is not from cygwin, so it doesn’t recognize /cygdrive style paths.

borkdude 2021-03-25T21:45:42.197200Z

yeah, makes sense and so your wrapper script is only available in the cygwin shell right?

2021-03-25T21:48:12.197400Z

Yep

borkdude 2021-03-25T21:49:38.197600Z

ok, so maybe calling the script just bb is nice so the shebang is the same in bash as it is in cygwin

2021-03-25T21:51:17.197900Z

Hrm, the problem is the wrapper assumes the first arg is the name of a script. Naming the wrapper bb would prevent me from doing bb one-liners from bash.

borkdude 2021-03-25T21:54:41.198200Z

oh you mean WSL2?

borkdude 2021-03-25T21:55:23.198400Z

oh you mean, bb -e '(+ 1 2 3)' for example, I get it now.

2021-03-25T21:55:33.198600Z

Yep

2021-03-25T21:59:15.198900Z

We can’t install WLS2 on our work machines so Git Bash is the only way to hold onto a little bit of sanity 🙂

borkdude 2021-03-25T22:05:53.199100Z

you can either make a PR for the book, or post the snippets here: https://github.com/babashka/book/discussions/categories/ideas

lread 2021-03-25T22:06:20.199300Z

Yeah, I feel the babashka awesome too. Maybe I mention it too much? Nah!

❤️ 3