Fork me on GitHub

@borkdude - small suggestion. Can babashka have a function that returns a simple bb.edn template? This way, I can make a bb.edn by merely evaling a function in the REPL


Yes, we could have something like bb init


Please post an issue


or even just a *bb.edn*


I wish clojure had it too. A simple way of just evaling a deps.edn into existence


OK, sorry for very basic simple questions here, but I've been living under a rock where babashka wasn't in use before. Details of my question in reply thread.


This bb.edn file has many keys in a map that is the value of its :tasks key:


including lsp-jar as one of the keys, which I've linked directly to the lines that define it.


It contains this key/value pair: :depends [java1.8 build-server -jar]


and the Clojure code that is the value of the :task key just after that contains an occurrence of the symbol -jar


The tasks on which this task depends bring in values that can be used in the task


I am guessing that this :depends is something like a Makefile dependency, where all :depends tasks are executed first, recursively if those tasks have their own :depends non-empty sequence of tasks, and then the return value of the task -jar becomes the value of the symbol -jar in the code of lsp-jar's :task ?


What would you recommend as a good way to learn the return value of a function like fs/copy in bb? I tried (doc fs/copy) in a bb interactive session, which gave some docs, but doesn't mention the return value. A reasonable guess is that it returns either the source or destination path of the fs/copy, but not obvious which.


(and for fs/copy being successful, I guess it doesn't matter much which)


(source fs/copy) in a bb interactive session shows "Source not found"


@U0CMVHBL2 if the return value is not specified I would say it's undefined :)


(i.e. I probably didn't think hard enough about that)


Your bb.edn file uses the return value of fs/copy, I think, yes?


in the lines that I highlighted, as the value of the symbol -jar


The return value is the return value java java.nio.file.Files/copy


I'm not complaining, by the way, or saying there is a bug or anything. Just looking for recommended ways to discover the behavior here.


Docs should probably be more clear on this


I did find in the doc page on bb tasks you linked that I can find out experimentally for that bb.edn file what the return value of a task is by running a command like this: bb run --prn lsp-jar which shows that copy returns the source file here, so I'm good to go.

👍 1

Is it normal that when I create bb uberjar with deps it doesn't work?


the app works without uberjaring, also if I create an uberjar but don't use honeysql - the uberjar works fine.


but if I uberjar with honeysql as dep - then - after compiling the jar I have this message: ^--- Could not find namespace: honeysql.core.


without using honeysql in the uberjar, using simple sql strings with a pod go-sqlite3 it works


my bb.edn is


{:paths ["src"] :deps { honeysql/honeysql {:mvn/version "1.0.461"} } :pods { org.babashka/go-sqlite3 {:version "0.1.0"} } }


also I tried adding deps.edn file with { honeysql/honeysql {:mvn/version "1.0.461"} }


but no luck


How did you create the uberjar, with bb uberjar?


Hello! yes of course


I call it "bb uberjar"


also maybe it wouldnt be a bad idea if "bb uberjar" generated <appname>.bb.jar instead of .jar


This worked fine for me:

bb uberjar app.jar
bb -cp app.jar -e "(require 'honeysql.core)"


The name of the jar up to you


right now I'm at my office


bb uberjar
that one worked?


bb uberjar app.jar


This will produce a jar file called app.jar


yes of course


I mean "bb uberjar" with honeysql produced a jar file that works? or you have to put -e "(require 'honeysql.core)" ?


> a jar file that works


What exactly do you mean by this? You have to be more specific. Or you can create a repository that someone can clone locally to exactly see what you are seeing.


You can specify a main function with -m that will execute when you run the uberjar with bb app.jar


It's not clear to me if you mean this


yes sorry I'm bit distracted right now


I didn't remember exactly the command


I make jar with


bb -cp $(clojure -A:remove-clojure -Spath) uberjar -m


if you use bb.edn, you don't need the -A:remove-clojure thing. Where did you read that? I should probably remove that.


it's from the book I use this one


bb -cp $(clojure -Spath) uberjar -m


I just copied it right now to check if it works, sorry I'm with few things at the same time xD


I'm gonna check if this works with -e "(require 'honeysql.core)"


(ns (:require [honeysql.core :as hsql] [honeysql.helpers :refer [select where from] :as helpers]) (:gen-class)) (defn -main [& a_args] (println "OK?"))


this is the program


this is the bb.edn


{:paths ["src"] :deps {honeysql/honeysql {:mvn/version "1.0.461"}} :pods {}}


that is the structure


the thing is that if I do


it works


if I do this:


bb -cp $(clojure -Spath) uberjar -e "(require 'honeysql.core)" -m


it makes a jar but it throws this


remove -cp ...


you do not need that


also remove -e


you're right


it was because of -cp


because then it uses the dependencies from deps.edn, not from bb.edn


well for me the Java world, classpaths and all that is a reason why I don't use java


I simplified the book now


(will take a few minutes for the github docs to refresh)


ah it's there now. please refresh


thank you very much


would it be possible to implement something like "bb init"


so it creates bb.edn


yes, there is a new issue for this since yesterday.


and bb i honeysql.core


turning to npm


I'm too used to node and npm


and convention over config


There is this command line tool you can use: It is is babashka script to add dependencies etc to deps.edn or bb.edn


If you are used to node.js then you might like #nbb


You can use any Node.js dependency from that.


I'm sure I'll like it


but for now I'm like trying to forget about node a bit


also maybe if Neil is ready you should feature it at


just to say you - you are great! thank you