Fork me on GitHub
#babashka
<
2022-05-16
>
mukundzare11:05:47

@borkdude Making an uberjar solved the problem! Another question: I use emacs with CIDER to connect to the remote machine's bb nREPL server. I fire up the nREPL conventionally like bb nrepl-server 1667 and would like to continue with my development (with the medley dependency) loaded into the REPL session. It seems to me that it is not so straight forward to load the jar in the REPL. Hot-loading *.clj files where the medley dependency is used in my emacs cider session still throws the missing dependency issue. Is there a way to make the nREPL server to load an uberjar? As per my limited knowledge, one can connect to a running clojure application's nREPL server (which I honestly have not reached yet to do 😄).

borkdude11:05:45

@mukundzare Yes, you can do that :)

(babashka.classpath/add-classpath "deps/medley.jar")

👀 1
mukundzare12:05:10

This seems to not work for me somehow. I made the repl connection by using the --classpath however.

borkdude12:05:31

Define "to not work"

borkdude12:05:41

The jar file has to live on the remote machine of course

mukundzare12:05:48

FileNotFoundException

mukundzare12:05:02

let me paste the folder structure

mukundzare12:05:13

last_restart.clj is where I define the classpath using add-classpath

borkdude12:05:21

if you start bb from the directory where bb.edn resides, you should be able to do (babashka.classpath/add-classpath "deps/medley.jar")

1
borkdude12:05:48

gotta go, be back later.

mukundzare13:05:01

that worked!

mukundzare13:05:31

either I could use --classpath and call bb from anywhere OR call bb from the place where bb.edn exists

mukundzare13:05:52

thanks again!

mukundzare11:05:54

Does this mean that I can add this dynamic classpath to let's say my main.clj and then add the (require '[medley.core :as m] statement form and don't bother with a uberjar?

borkdude11:05:45

yeah, I guess so :)

mukundzare11:05:14

let me try that

borkdude12:05:09

You can see the running site here: https://shy-sound-2847.fly.dev/

❤️ 4
🎉 1
wow 1
Eugen17:05:12

@borkdude: do you think we can add some parameters to bb tasks command ? I would like to add --format parameter to list tasks in different formats (simple and edn). the end goal is to improve this part:

;; Type bb tasks to see all tasks
;; Type bb <task-name> or bb run <task-name> to run a task
{:min-bb-version "0.7.4"
 :tasks {:requires ([clojure.string :as str])
         app {:doc "Without arguments, prints tasks in app - with arguments, invokes task in app dir"
              :task (if (empty? *command-line-args*)
                      (shell {:dir "projects/app"} "bb tasks")
                      (shell {:dir "projects/app"}
                             (str "bb run " (str/join " " *command-line-args*))))}}} 
so I can list all tasks in a directory and print them with the prefix.

Eugen17:05:42

also, it would be cool if I could intercept task execution and choose if I want to run the task or do something else. Trying to figure out how can I call tasks in different directories from a central place

borkdude18:05:42

@U011NGC5FFY The bb.edn is already EDN so why would you need EDN output? :)

Eugen18:05:42

yeah, I guess I don't 🙂

Eugen18:05:05

is there a way to register tasks via a function call. Wondering if I can read tasks from a bb edn and register them via a function

borkdude18:05:53

Currently there is not a way to dynamically create tasks

Eugen18:05:57

yes, looks very much related

Eugen18:05:13

or a possible solution for my use case