babashka

https://github.com/babashka/babashka. Also see #sci, #nbb and #babashka-circleci-builds .
Tomas Brejla 2021-03-23T08:12:24.157100Z

FYI that M2-801W tablet is running rather ancient Android 6. Simple installation of termux app from google play and copying statically compiled bbwas enough to get it running. For newer androids, (I have Xiaomi MI8 phone with Android 11 10) , it might be a bit more problematic due to newly introduced changes in security. Yet, in the end, I was able to run bb even on that phone. All I had to additionally do was to to install proot package (`apt install proot`) and then execute termux-chroot script before actually trying to run bb . Without these adjustments, bb wouldn't start on this device. It's wonderful what can be achieved (and in relatively easy way) these days. I wonder what use-case scenarios people will come with. Having the ability to run full-blown bb in that powerful device resting in your pocket, may spark many new ideas.

Tomas Brejla 2021-03-23T08:20:25.157300Z

Althought it should be noted that Termux's position is rather complicated these days, as explained in this article https://www.xda-developers.com/termux-terminal-linux-google-play-updates-stopped/

borkdude 2021-03-23T08:40:07.157600Z

Cool :) I posted these notes into the arm issue

1👏
borkdude 2021-03-23T10:34:48.157900Z

bb.edn / task runner update:

14❤️
richiardiandrea 2021-03-29T17:41:24.256400Z

I like this, as a data point, I would love something like this for moving the scripts aliases (say the alias for :carve that we use) from my deps.edn to it. I would leave only dependency/per profile information in deps.edn

borkdude 2021-03-29T17:59:59.256600Z

Thanks for the feedback. The discussion here: https://github.com/babashka/babashka/discussions/757#discussioncomment-540032 shifted a bit towards: less DSL, more normal functions. This is explored here now: https://github.com/babashka/babashka/discussions/765

1👍
2021-03-23T10:40:52.158200Z

Nice! Not sure if it makes a difference for boot time, but maybe useful for isolation, are you thinking of having the :deps key per task?

borkdude 2021-03-23T10:42:18.158500Z

yeah, I'm still thinking about this. probably just support :aliases like deps.edn and then in a task you can have :task/aliases [:foo :bar] to include deps from those aliases?

borkdude 2021-03-23T10:44:23.158800Z

then everything works like expected, e.g. extra-deps, replace-deps. the only problem is, what happens when you combine multiple tasks? probably all of the aliases should be combined then as well

2021-03-23T10:45:16.159Z

Yeah maybe something to add later after some user feedback. Maybe it’s not needed (yet)

borkdude 2021-03-23T10:45:23.159200Z

right

borkdude 2021-03-23T10:45:36.159400Z

but might also be good to get this right before initial release

2021-03-23T10:45:44.159600Z

True

2021-03-23T10:45:58.159800Z

Are you seeing this also as a boot / lein replacement ?

borkdude 2021-03-23T10:47:05.160100Z

kind of a light weight replacement for make (have an overview of things you can invoke in a project) you can read the "problem statement" here: https://github.com/babashka/babashka/issues/756

2021-03-23T10:47:40.160500Z

Cool, nice

2021-03-23T10:49:30.160700Z

Regarding, the combining of multiple tasks. In my experience over time a project.clj or deps.edn gets really cluttered of dependencies that might or might not be needed anymore. Having deps per task might allow for keeping it cleaner via isolation. Also when you want to extract / update something it will be beneficial

2021-03-23T10:51:00.160900Z

I guess this also depends if it is possible to have two different versions of the same library on babashka’s path. That would be a requirement for that to work I’m guessing

borkdude 2021-03-23T10:53:37.161100Z

if you want to combine multiple tasks like bb :clean:foobar and clean uses lib1 v1 and foobar uses lib1 v2, then I'm not sure what should happen. Then we should unload certain things but that is error prone probably, since there may be references to these things by used-defined functions.

borkdude 2021-03-23T10:53:49.161300Z

So I think having a purely additive classpath works best.

borkdude 2021-03-23T10:54:05.161500Z

And do dep resolution only once with aliases from both clean and foobar

borkdude 2021-03-23T10:55:35.161700Z

So one example where this is really needed is in the case of global tasks in ~/.babashka/bb.edn, e.g. :http-server. Then we want to include some script which runs an http server we don't always want to have that on our classpath all the time.

borkdude 2021-03-23T10:56:49.161900Z

So I was thinking:

:tasks {:http-server {:task/type :main :main cool.http-server :aliases [:http-server]}}
:aliases {:extra-deps {....}}
but maybe in this case it would have been nicer to have `:extra-deps directly inside the task

2021-03-23T11:02:21.162100Z

I’m not sure what the reasoning was behind :extra-deps in tools.deps But in my naive opinion having the deps in the task itself is nicer

borkdude 2021-03-23T11:04:51.162300Z

The idea in deps.edn is that you can compose the base deps with more deps. But deps.edn also has :replace-deps which is used for more isolated tasks

borkdude 2021-03-23T11:07:48.162500Z

So e.g. in ~/.babashka/bb.edn you could have:

{:aliases {:http-server {:extra-paths ["/Users/borkdude/Dropbox/bb_scripts"]}}
 :tasks {:http-server {:task/type :main
                       :main http-server.main
                       :aliases [:http-server]}}}

borkdude 2021-03-23T11:08:26.162700Z

So e.g. in ~/.babashka/bb.edn you could have:

{:aliases {:http-server {:extra-paths ["/Users/borkdude/Dropbox/bb_scripts"]}}
 :tasks {:http-server {:task/type :main
                       :main http-server.main
                       :aliases [:http-server]}}}

borkdude 2021-03-23T11:09:26.162900Z

but this kind of duplicates things. Maybe as a convention, a task opts into the alias of the same name

borkdude 2021-03-23T11:10:08.163100Z

I agree that it would be nicer to have this directly in the tasks, but this requires somewhat more processing and I thought I could be lazy ;)

2021-03-23T11:10:40.163300Z

haha always good to try to be lazy. I don’t think you are btw 😉

borkdude 2021-03-23T11:10:56.163500Z

Maybe:

{:tasks {:http-server {:task/type :main
                       :task/deps {:extra-paths ["/Users/borkdude/Dropbox/bb_scripts"]}
                       :main http-server.main}}}

borkdude 2021-03-23T11:11:09.163700Z

so :task/deps can have the same thing as an alias perhaps

1👍
2021-03-23T11:12:30.164200Z

another consideration might be to think of how much overlap in deps there is between tasks. Maybe less than in normal deps.edn usage. So less gain in composing?

borkdude 2021-03-23T11:13:11.164400Z

but this could lead to a lot of duplication of you want to repeat the {:extra-paths ...} thing for every global task

borkdude 2021-03-23T11:13:18.164600Z

(my slack is laggy)

2021-03-23T11:13:32.164800Z

(same here)

2021-03-23T11:15:44.165100Z

What if you don’t implement it yet and we have the minimal version for feedback under beta users? You can evaluate how our bb.edn looks and you can decide based on that? Just a suggestion of course

borkdude 2021-03-23T11:17:29.165400Z

yeah, that might be good, but I think for global tasks like bb :http-server (instead of python -m http.server) it already makes sense to have a good story for this you can test the beta using binaries from #babashka-circleci-builds already (bb.edn branch)

2021-03-23T11:17:50.165600Z

ok, cool will do that

2021-03-23T11:30:46.165900Z

Where shall I post silly user feedback 😅? E.g. I thought it wasn’t working because I was using an unknown task

bb :taadf
File does not exist: :taadf
because of the colon I was expecting something like “Task does not exist”

2021-03-23T11:33:30.166100Z

Another here

➜  ~ bb :tasks
The following tasks are available:

:foo nil

Run bb :help <task> to view help of a specific task.
➜  ~ bb :foo
No such task:
That’s what you get when you use a vector instead of a map 🙈
{:tasks {:foo [:task/type :babashka
               :task/description "adf"
               :task/args [-e (println "Hi")]]}}  
With a map it works 🙂

borkdude 2021-03-23T11:33:40.166300Z

Thanks, you can post feedback here: https://github.com/babashka/babashka/discussions/757

1👍
2021-03-23T12:23:39.166600Z

Is :paths already working? If so, I don’t think I understand how it works. Am i doing something wrong below?

{:paths ["/Users/jeroen/bin/bb-scripts"]
 :tasks 
 {:http-server-ok {:task/type :babashka
                    :task/description "HTTP server"
                    :task/args ["/Users/jeroen/bin/bb-scripts/http-server"]}      
                               
  :http-server-fail {:task/type :babashka
                       :task/description "HTTP server"
                       :task/args ["http-server"]}       
                     
}}
:http-server-ok works in the above example

2021-03-23T12:41:31.166900Z

I’m guessing I need to put clj / bb files in the path and use :task/type :main . I don’t have it working yet. Do you have an example project somewhere?

2021-03-23T12:42:49.167100Z

ah nevermind found one https://github.com/babashka/babashka/blob/bb.edn/test-resources/bb.edn

borkdude 2021-03-23T12:50:27.167500Z

:paths only influences the classpath

borkdude 2021-03-23T12:50:50.167700Z

this is just from deps.edn

borkdude 2021-03-23T12:51:37.167900Z

so the latter I would write as :task/type :main and then expose your http server under a -main function

borkdude 2021-03-23T12:51:45.168100Z

and then :main http-server.main

borkdude 2021-03-23T12:52:17.168700Z

or :main http-server/start or something if you want to use a fully qualified function name different from -main

1👍
maxp 2021-03-23T12:53:21.169900Z

@borkdude what do you think about "global" bb,.edn - ~/.config/bb/bb.edn or '~/.bb/bb/edn

borkdude 2021-03-23T12:54:14.170600Z

that is being considered, along with global tasks, so you can do bb :http-server anywhere on your system

4😎
borkdude 2021-03-23T12:54:43.171Z

(see the discussion with jeroen in the thread above)