babashka

https://github.com/babashka/babashka. Also see #sci, #nbb and #babashka-circleci-builds .
borkdude 2021-05-04T07:30:44.425100Z

@mike1452 That's cool, but I don't understand why deps.exe saved you, since it contains the same logic as bb for resolving deps.

borkdude 2021-05-04T07:31:09.425400Z

> After I added them into cacerts file, deps.exe started to download any deps. So I suspect bb will do the same then?

borkdude 2021-05-04T07:32:00.426200Z

And you didn't respond yet about the first step: getting the tools.jar on your system. How did you manage that.

borkdude 2021-05-04T08:18:10.426600Z

@karol.wojcik Congrats on the new holy-lambda release. Note that this doesn't do anything anymore in 0.3.7: https://github.com/FieryCod/holy-lambda/blob/8747d72e4c1a8d7a842d4da392a8d95f9d15b453/examples/bb/babashka/component.example/bb.edn#L80

Karol Wójcik 2021-05-04T08:20:17.426800Z

Thank you. I will adjust a template. Btw I didn't want to poke you around yesterday, so I kinda hacked babashka.deps/add-deps https://github.com/FieryCod/holy-lambda/blob/master/modules/holy-lambda-babashka-layer/hacks.clj I would love to have an option to pass :mvn/local-repo to babashka itself.

borkdude 2021-05-04T08:21:39.427200Z

Nice hack :)

Karol Wójcik 2021-05-04T08:22:17.427400Z

Yep 😄 That way if someone use add-deps in lambda context deps are not downloaded 😄

Karol Wójcik 2021-05-04T08:24:17.427600Z

Btw I'm closing the issue https://github.com/babashka/babashka/issues/801 Pods are distributed as a separate layer now. I will write a sum up in the issue.

borkdude 2021-05-04T08:24:35.427900Z

ok

mike_ananev 2021-05-04T08:27:21.428100Z

After I configured settings.xml and added certificates deps.exedownloaded all jars for me. Before it my .m2 was empty.

mike_ananev 2021-05-04T08:28:16.428300Z

I think so, but I did not check yet.

borkdude 2021-05-04T08:28:18.428500Z

Yes, this is about dependencies. But before deps.exe can download any dependency, it first must download the tools.jar!

borkdude 2021-05-04T08:28:56.429Z

and this is a different step than downloading dependencies

borkdude 2021-05-04T08:29:03.429200Z

you mentioned that this step also went wrong

borkdude 2021-05-04T08:29:46.429400Z

or did that step succeed?

borkdude 2021-05-04T08:30:04.429600Z

anyway, perhaps that step succeeded and it were only the deps that failed?

borkdude 2021-05-04T08:30:31.429800Z

you can check this if there is a %USERPROFILE%/.deps.clj directory with the expected jar

mike_ananev 2021-05-04T08:31:41.430Z

I suppose that after I added corporate certs from CA to the cacerts file, deps.exe can access to Internet via proxy which has dynamic certs signed by root certificate from our CA. And error with PKI path verification disappeared.

borkdude 2021-05-04T08:32:34.430300Z

where is this cacerts file located?

borkdude 2021-05-04T08:32:43.430500Z

the downloading of the tools.jar isn't going through java

borkdude 2021-05-04T08:32:48.430700Z

it is part of the binary

Karol Wójcik 2021-05-04T08:32:56.430900Z

I've just removed :log-level :info from the template. Thanks!

borkdude 2021-05-04T08:34:12.432Z

I think we have had good testing of bb tasks. Maybe it's time to make a stable release announcement sometime soon. I would like to urge everyone who cares to give it another spin so any design mistakes can still be fixed

mike_ananev 2021-05-04T08:34:46.432100Z

cacerts file is located C:\Program Files\AdoptOpenJDK\jdk15\lib\security\cacerts as I remember, that deps.exe somehow used it. It is the only reason I can see

borkdude 2021-05-04T08:35:48.432400Z

@mike1452 The only explanation that I have is that the download of the tools.jar succeeded already before. Only the maven and git dependencies are downloaded by java and this was probably fixed by your cacerts in java.

borkdude 2021-05-04T08:36:07.432600Z

The same should work with bb, since it's also going through java for maven/git deps

mike_ananev 2021-05-04T08:37:08.432900Z

Oh! I have Idea + Cursive. When I configured Idea for Clojure I pressed button to download jars from there.

mike_ananev 2021-05-04T08:37:23.433100Z

this is the third step I made

borkdude 2021-05-04T08:38:13.433300Z

yeah, but this is a different location than what deps.clj uses so this can't be related

borkdude 2021-05-04T08:38:53.433600Z

(although I realize now that it could maybe use the same tools.jar if clojure is already installed, I'll make an issue for that)

mike_ananev 2021-05-04T08:38:58.433800Z

Idea runs under JVM and this step downloaded jars

borkdude 2021-05-04T08:39:12.434Z

oh

borkdude 2021-05-04T08:39:57.434200Z

anyway, there are too many steps going on at once for me too follow. I need precise details of what is going on next time, it's all intermingled now.

borkdude 2021-05-04T09:05:59.434900Z

Added another bb.edn, this time for building the http://babashka.org website: https://github.com/babashka/babashka.github.io

Jakub Holý 2021-05-04T09:18:05.435700Z

How to troubleshoot this, please?

user=>  (require '[babashka.deps :as deps])
nil
user=> (deps/add-deps '{:deps {djblue/portal {:mvn/version "0.11.1"}}})
java.lang.NullPointerException [at <repl>:2:1]
this is thrown at borkdude.deps$which invokeStatic "deps.clj" 171 . babashka v0.3.4 More info: When I am offline, I get a different (and kind of expected) error: > Could not find /Users/me/.deps.clj/1.10.3.822/ClojureTools/clojure-tools-1.10.3.822.jar > Attempting download from https://download.clojure.org/install/clojure-tools-1.10.3.822.zip > java.net.SocketException: Connection reset [at <repl>:6:1]

✅ 1
borkdude 2021-05-04T09:25:10.436300Z

@holyjak Could it be that your PATH environment variable isn't set? https://github.com/borkdude/deps.clj/blob/9e0ca8002cca486223a962c06865dbbe3bc1917a/src/borkdude/deps.clj#L164

Jakub Holý 2021-05-04T09:25:36.437Z

oh yeah, that is it! I am running env -i to solve some other issue. Thanks a lot

borkdude 2021-05-04T10:21:29.439300Z

Another library compatible with babashka! This time the config library from my colleague we're using at work :) https://github.com/dunaj-project/crispin

👍 1
👀 1
borkdude 2021-05-04T10:59:21.440100Z

I also made an env task in our app tasks:

$ DRE_SCHEDULER_ENABLE=true bb env :dre :scheduler :enable
"true"
✓ env
https://gist.github.com/borkdude/35bc0a20bd4c112dec2c5645f67250e3#file-2-bb-edn-L29-L35

mike_ananev 2021-05-04T14:31:10.442900Z

@borkdude have you any video, how do you debug babashka tasks from the bb.edn file? IDEA + Cursive doesn't treat the bb.edn file as Clojure code. May be in Emacs I can eval and debug bb.edn scripts?

borkdude 2021-05-04T14:31:44.443400Z

@mike1452 you can make a repl task which starts (clojure.main/repl) and then debug

borkdude 2021-05-04T14:33:31.444500Z

The next version will support bb --debug &lt;task&gt; which prints the task as it's executed before running it

borkdude 2021-05-04T14:33:42.444800Z

you can try this from #babashka-circleci-builds

Jakub Holý 2021-05-04T15:33:50.444900Z

Any tips for persisting data between bb invocations (Namely oidc refresh tokens) in cross-os manner independent of the current working directory? On osx/Linux I'd just put a file in ~/.config/mybbstuff but that likely doesn't work so well for Windows..

borkdude 2021-05-04T15:34:55.445400Z

you can get the home directory using (System/getProperty "user.home")

borkdude 2021-05-04T15:35:26.446Z

persisting in &lt;home&gt;/.config/.tool also works in Windows

❤️ 1
littleli 2021-05-04T15:44:55.447700Z

@holyjak you have two options which I would recommend ot you: use APPDATA environment variable for the roaming profile, for example $APPDATA\appname\tempfile or use LOCALAPPDATA environment variable if you want to avoid roaming profile

👍 1
littleli 2021-05-04T15:47:20.448400Z

roaming profile in fact can be synced between machines, consider it the user directory that can move between the machines eventually.

littleli 2021-05-04T15:48:44.448600Z

I would personally pick LOCALAPPDATA

borkdude 2021-05-04T15:51:13.448800Z

on linux/macos you could also respect XDG_DATA_HOME or XDG_CACHE_HOME

Jakub Holý 2021-05-04T16:16:50.449200Z

Thank you!

kokada 2021-05-04T16:36:26.449400Z

Nice, will we have a new release (0.4 maybe?) soon? Just asking because I was going to update nixpkgs with 0.3.7 release, but if a new release is coming I think I will wait until it

borkdude 2021-05-04T16:37:14.449600Z

I think 0.4 is appropriate indeed for the tasks feature

👍 1
mike_ananev 2021-05-04T17:09:31.454200Z

@borkdude found useful the following way to develop and debug bb.edn tasks 1. Run babashka nREPL by: bb nrepl-server in terminal in project root 2. Run Emacs and open bb.edn 3. call cider-connect-clj to repl localhost:1667 4. eval (in-ns 'babashka.tasks) to make current repl ns 5. now I can call shell or clojure functions from babashka.tasks ns or run particular task by (run 'my-task) and see result in terminal

👍 1
Karol Wójcik 2021-05-04T17:11:14.454600Z

The only downside of it is when shell results in error. This will exit the process of nrepl 😞

mike_ananev 2021-05-04T17:16:47.455100Z

I have no such behavior. If the shell fails it will not exit now. Maybe this was before v0.3.7?

borkdude 2021-05-04T17:42:36.456400Z

The shell function does exit in case of an error

borkdude 2021-05-04T17:43:10.456600Z

You can avoid this by writing (shell {:continue true} "ls foo")

Karol Wójcik 2021-05-04T17:46:00.456800Z

Right. I have forgotten that I have my own implementation of shell which does that 😄

borkdude 2021-05-04T17:46:48.457100Z

Maybe we can make shell throw an exception instead, but I don't know if that would help

borkdude 2021-05-04T17:56:26.457500Z

I think I'll change it to that, so you can just keep REPLing

mike_ananev 2021-05-04T18:01:43.457700Z

now shell has no exception if command fails ( {:continue true} is default, right?). this behavior is expected in my scripts.

borkdude 2021-05-04T18:02:44.458400Z

shell will exit the babashka process if there is a non-zero exit code

borkdude 2021-05-04T18:03:07.458900Z

if that doesn't work for you it's a bug

borkdude 2021-05-04T18:03:28.459500Z

$ bb -e '(babashka.tasks/shell "ls foo") (prn :bar)'
ls: foo: No such file or directory
[bb null] Terminating with non-zero exit code: 1

mike_ananev 2021-05-04T18:04:26.460400Z

I just found how to use Idea + Cursive without problems. See https://github.com/cursive-ide/cursive/issues/2452, onetom gave working recipe using vlaad/remote-repl

👍 1
mike_ananev 2021-05-04T18:06:36.460700Z

ah, sorry. My mistake. It works as you described.

borkdude 2021-05-04T18:07:02.460900Z

but I will change this into an exception, which has the same effect, but works better in a REPL

mike_ananev 2021-05-04T18:07:17.461100Z

👍