This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
@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
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: https://github.com/clj-kondo/clj-kondo.lsp/blob/master/bb.edn#L48-L51
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
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
?
Docs on this are here: https://book.babashka.org/#tasks
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 :)
The source for fs is here: https://github.com/babashka/fs/blob/master/src/babashka/fs.cljc
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
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.
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.
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
{:paths ["src"] :deps { honeysql/honeysql {:mvn/version "1.0.461"} } :pods { org.babashka/go-sqlite3 {:version "0.1.0"} } }
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)"
I mean "bb uberjar" with honeysql produced a jar file that works? or you have to put -e "(require 'honeysql.core)" ?
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 foo.bar
that will execute when you run the uberjar with bb app.jar
bb -cp $(clojure -A:remove-clojure -Spath) uberjar bbapp1.bb.jar -m http://bbapp1.app
if you use bb.edn, you don't need the -A:remove-clojure thing. Where did you read that? I should probably remove that.
bb -cp $(clojure -Spath) uberjar bbapp1.bb.jar -m http://bbapp1.app
I just copied it right now to check if it works, sorry I'm with few things at the same time xD
(ns http://bbapp1.app (:require [honeysql.core :as hsql] [honeysql.helpers :refer [select where from] :as helpers]) (:gen-class)) (defn -main [& a_args] (println "OK?"))
bb -cp $(clojure -Spath) uberjar bbapp1.bb.jar -e "(require 'honeysql.core)" -m http://bbapp1.app
I copied it from https://book.babashka.org/#_uberjar
There is this command line tool you can use: https://github.com/babashka/neil It is is babashka script to add dependencies etc to deps.edn or bb.edn
also maybe if Neil is ready you should feature it at https://babashka.org/