Fork me on GitHub
#babashka
<
2021-05-04
>
borkdude07:05:44

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

borkdude07:05:09

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

mike_ananev08:05:16

I think so, but I did not check yet.

borkdude07:05:00

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

mike_ananev08:05:21

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

borkdude08:05:18

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

borkdude08:05:56

and this is a different step than downloading dependencies

borkdude08:05:03

you mentioned that this step also went wrong

borkdude08:05:46

or did that step succeed?

borkdude08:05:04

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

borkdude08:05:31

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

mike_ananev08:05:41

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.

borkdude08:05:34

where is this cacerts file located?

borkdude08:05:43

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

borkdude08:05:48

it is part of the binary

mike_ananev08:05:46

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

borkdude08:05:48

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

borkdude08:05:07

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

mike_ananev08:05:08

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

mike_ananev08:05:23

this is the third step I made

borkdude08:05:13

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

borkdude08:05:53

(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_ananev08:05:58

Idea runs under JVM and this step downloaded jars

borkdude08:05:57

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.

Karol Wójcik08:05:17

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.

borkdude08:05:39

Nice hack :)

Karol Wójcik08:05:17

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

Karol Wójcik08:05:17

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.

Karol Wójcik08:05:56

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

borkdude08:05:12

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

kokada16:05:26

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

borkdude16:05:14

I think 0.4 is appropriate indeed for the tasks feature

👍 3
borkdude09:05:59

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

Jakub Holý09:05:05

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]

3
Jakub Holý09:05:36

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

borkdude10:05:29

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

👍 3
👀 3
borkdude10:05:21

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_ananev14:05:10

@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?

borkdude14:05:44

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

borkdude14:05:31

The next version will support bb --debug <task> which prints the task as it's executed before running it

borkdude14:05:42

you can try this from #babashka-circleci-builds

Jakub Holý15:05:50

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

borkdude15:05:55

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

borkdude15:05:26

persisting in <home>/.config/.tool also works in Windows

❤️ 3
littleli15:05:55

@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

👍 3
littleli15:05:20

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

littleli15:05:44

I would personally pick LOCALAPPDATA

borkdude15:05:13

on linux/macos you could also respect XDG_DATA_HOME or XDG_CACHE_HOME

mike_ananev17:05:31

@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

👍 3
Karol Wójcik17:05:14

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

mike_ananev17:05:47

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

borkdude17:05:36

The shell function does exit in case of an error

borkdude17:05:10

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

Karol Wójcik17:05:00

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

borkdude17:05:48

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

borkdude17:05:26

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

mike_ananev18:05:43

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

borkdude18:05:44

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

borkdude18:05:07

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

borkdude18:05:28

$ 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_ananev18:05:36

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

borkdude18:05:02

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

mike_ananev18:05:26

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

👍 3