Hi, when I do
$ bb uberscript pg_copycat.clj -m pg_copycat.core
$ bb pg_copycat.core
everything goes fineโฆ
When I do
$ bb -cp $(clojure -Spath) --classpath src uberjar pg_copycat.jar -m pg_copycat.core
$ bb pg_copycat.jar
it fails with
----- Context ------------------------------------------------------------------
1: (ns user (:require [pg-copycat.core])) (apply pg-copycat.core/-main *command-line-args*)
^--- Could not resolve symbol: pg-copycat.core/-main
If I rename pg_copycat.core to pg-copycat.core in /src/pg_copycat/core.clj then it works.
But all other namespaces (like pg_copycat.utils) can stay with underscore.
I would like to keep naming consistent across namespaces. Thanks
What exactly is your question?
Why does the main namespace has to be different when using uberjar and uberscript.
@zikajk I think you should never use -m foo_bar
, always use -m foo-bar
ok, i thought so.. so it is not a feature. Thanks
for directory / file names (on the classpath) use underscores, but in code, always use hyphens
Hi, I am trying to pack my script with all the dependencies bb.edn
{:paths ["src"]
:deps {seancorfield/honeysql {:mvn/version "2.0.0-beta2"}
douglass/clj-psql {:mvn/version "0.1.2"}
clojure-term-colors/clojure-term-colors {:mvn/version "0.1.0"}
borkdude/spartan.spec {:git/url "<https://github.com/borkdude/spartan.spec>"
:sha "12947185b4f8b8ff8ee3bc0f19c98dbde54d4c90"}}}
I tried to use both
$ bb -cp $(clojure -Spath) --classpath src uberjar pg_copycat.jar -m pg-copycat.core
$ bb uberscript pg_copycat.clj -m pg-copycat.core
but it still needs to download dependencies from bb.edn when $ bb pg_copycat.jar
on different server.
What should I to create a script which depends only on BB?
Thanks again@zikajk if you have a bb.edn
in your local directory, bb will always load dependencies. if you want to run the uberscript, then run it from a directory without the bb.edn
or you could override the classpath with bb --classpath "" pg_copycat.clj
that will probably work
Ahh, this does work with uberscript but does not work with uberjar. So i will get back to using uberscript and I will delete bb.edn during the deployment. Thanks
@zikajk It should also work with the uberjar
@borkdude how to run two tasks with parameters in parallel? e.g. bb run --parallel 'task1 param1' 'task2 param1'
I am not sure what i am doing wrong but i am not skilful with java classpaths tbh
$ bb -cp $(clojure -Spath) --classpath src uberjar pg_copycat.jar -m pg-copycat.core
$ rm bb.edn
$ bb pg_copycat.jar
----- Error --------------------------------------------------------------------
Type: java.lang.Exception
Message: Could not find namespace: clojure.term.colors.
Location: 2:3
----- Stack trace --------------------------------------------------------------
- <expr>:2:3
- <expr>:3:3
- <expr>:1:10
$ bb uberscript pg_copycat.clj -m pg-copycat.core
$ rm bb.edn
$ bb pg_copycat.clj
{:exit 2, :out localhost:5432 - no response
, :err }
Cannot connect to database [postgres].
Here is an uberjar example:
borkdude@MBP2019 /tmp $ cat src/program.clj
(ns program
(:require [medley.core :as m]))
(defn -main [& _args]
(prn (m/index-by :id [{:id 1} {:id 2}])))
borkdude@MBP2019 /tmp $ bb uberjar foo.jar -m program
borkdude@MBP2019 /tmp $ cat bb.edn
{:paths ["src"]
:deps {medley/medley {:mvn/version "1.3.0"}}}
borkdude@MBP2019 /tmp $ bb --classpath "" foo.jar
{1 {:id 1}, 2 {:id 2}}
it ignores the bb.edn correctly with the --classpath ""
option
Cannot connect to database [postgres]
doesn't seem to be related to bb but more related to your configThe issue with -cp $(clojure -Spath) --classpath src
is that you are setting the classpath twice. The second option will override the first option
you can combine them: -cp $(clojure -Spath):src
The connection to database is awaited output comming from uberscript. Thank you it seems to be the problem
@mike1452 bb doesn't support invoking multiple tasks from the command line yet.
The --parallel
option just means that task dependencies of the invoked task are ran in parallel
Thank you.
Hm, it seems that babashka doesnโt work on Alpine linux. Has anyone else noticed this?
FROM alpine:latest
RUN apk add --no-cache bash curl
RUN curl -sL <https://raw.githubusercontent.com/babashka/babashka/master/install> | bash
RUN ls -l /usr/local/bin/
RUN /usr/local/bin/bb -h
---> Running in edd842dd84de
total 88200
-rwxr-xr-x 1 3434 3434 90311864 Jun 13 20:04 bb
Removing intermediate container edd842dd84de
---> 5930268b3b7d
Step 5/7 : RUN /usr/local/bin/bb -h
---> Running in a5f4abfb1f4c
/bin/sh: /usr/local/bin/bb: not found
basically itโs not seen as executable by the loader for some reason
@grazfather you should use the --static
option
you think itโs a shared lib issue? --static
is an option to the install script now?
yes
alpine is based on musl, not glibc
yep, I just expected a clearer error about missing libs if that were the issue ๐
(from alpine, not from bb)
Confirmed this works great ๐
FROM alpine:latest
# Needed to install babashka itself
RUN apk add --no-cache bash curl
RUN curl -sL <https://raw.githubusercontent.com/babashka/babashka/master/install> \
| bash -s -- --static
@grazfather Cool! Note that there is also https://hub.docker.com/layers/babashka/babashka/0.4.6-alpine/images/sha256-352797da9c15b7a91d003527c13cf5ede62e904934c0bd10e9cb772754c01728?context=explore
oh, nice, maybe I will use that as my FROM ๐ I add a bit after what is shown, itโs to test out my dotfiles installer
hm you have a redundant CMD
in there
This error is not printed by Babashka Not sure if it is the shell, linker or even Linux itself, but really nothing we could do
BTW, not alpine fault, this behavior is the same in any Linux distro I know
@grazfather if youre referring to the CMD ["/bin/sh"]
that comes from the base alpine image which we extend. This is the Dockerfile we use: https://github.com/babashka/babashka/blob/master/Dockerfile.alpine
ah, Yeah, that makes sense