This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-06-01
Channels
- # babashka (30)
- # beginners (80)
- # calva (21)
- # chlorine-clover (2)
- # cider (22)
- # clj-kondo (65)
- # cljfx (2)
- # cljs-dev (3)
- # cljsrn (3)
- # clojure (37)
- # clojure-europe (27)
- # clojure-italy (3)
- # clojure-nl (2)
- # clojure-taiwan (1)
- # clojure-uk (21)
- # clojurescript (13)
- # conjure (23)
- # core-typed (1)
- # cursive (16)
- # datahike (1)
- # datomic (6)
- # docs (2)
- # emacs (5)
- # figwheel-main (1)
- # fulcro (12)
- # helix (11)
- # jobs (2)
- # jobs-discuss (2)
- # leiningen (1)
- # lsp (34)
- # luminus (1)
- # malli (19)
- # microservices (1)
- # nrepl (1)
- # off-topic (25)
- # pathom (6)
- # polylith (47)
- # practicalli (5)
- # re-frame (8)
- # reagent (1)
- # reitit (1)
- # releases (2)
- # remote-jobs (2)
- # reveal (1)
- # sci (1)
- # shadow-cljs (11)
- # sql (8)
- # tools-deps (9)
- # xtdb (16)
@nicolas.estrada938 Decided to add support to bb for this trailing map and StackTraceElement. I'm building a new bb version now
You my friend are a saint! ๐
Babashka 0.4.4 is released. Changes: https://github.com/babashka/babashka/blob/master/CHANGELOG.md#044

Fun side effect of including StackTraceElement in bb is that you can inspect some of bb/sci's runtime ;)
$ bb -e '(->> (try (/ 1 0) (catch Exception e (.getStackTrace e))) (map bean) clojure.pprint/print-table)'
| :classLoaderName | :fileName | :moduleVersion | :nativeMethod | :className | :moduleName | :class | :lineNumber | :methodName |
|------------------+------------------+----------------+---------------+-----------------------------------------+-------------+-----------------------------------+-------------+--------------|
| | Numbers.java | | false | clojure.lang.Numbers | | class java.lang.StackTraceElement | 188 | divide |
| | core.clj | | false | clojure.core$_SLASH_ | | class java.lang.StackTraceElement | 1029 | invokeStatic |
| | core.clj | | false | clojure.core$_SLASH_ | | class java.lang.StackTraceElement | 1022 | invoke |
This is pretty cool too. Get info about another process:
$ bb -e '(.info (.get (java.lang.ProcessHandle/of 39045)))'
#object[java.lang.ProcessHandleImpl$Info 0x6bd723ed "[user: Optional[borkdude], cmd: /Applications/Emacs.app/Contents/MacOS/Emacs-x86_64-10_14, startTime: Optional[2021-05-28T08:59:27.973Z]]"]
so with this you can get command line arguments, the exact binary location of what the process was started with, arguments, etc
There is supposed to be an alternative to clojure.java.shell/sh
in babashka. What is it called?
And can I do (bb/sh "ecco my command is just a string")
with it? (clojure.java.shell/sh "echo hi")
fails with
Execution error (IOException) at java.lang.ProcessImpl/forkAndExec (ProcessImpl.java:-2).
error=2, No such file or directory
I do not want to split my command string into whitespace as that might not be easy "ecco 'hi there'"
:
(clojure.java.shell/sh (clojure.string/split "echo 'hi there'" #" "))
Execution error (IllegalArgumentException) at clojure.java.shell/parse-args (shell.clj:47).
No value supplied for key: ["echo" "'hi" "there'"]
With apply
it works. But I wonder whether this might ever break a command line string.
If you want to invoke a shell command just like how you could do it in the shell, streaming output directly to stdout/stderr, then you could also use (babashka.tasks/shell "echo 'hi there'")
Syntax error (ClassNotFoundException) compiling at (*cider-repl code/myapp:localhost:56301(clj)*:32:12).
babashka.tasks
My lein coords are:
[babashka/babashka "0.4.4"]
Also tried:
(require '[babashka.impl.tasks :as tasks])
Syntax error (IllegalArgumentException) compiling . at (borkdude/deps.clj:196:12).
More than one matching method found: newFileSystem
Hmm, babashka isn't really supposed to be used as a JVM project. I was assuming you were using babashka as a tool
But the libraries contained in there, such as babashka.process, are available on the JVM
Cool!
It seems like clojure.java.shell/sh
does not support many simple commands like:
(clojure.java.shell/sh "sleep" "1" ";" "echo" "2")
;; => {:exit 1, :out "", :err "usage: sleep seconds\n"}
So I'll be looking into babashka :thumbsup:Thanks ๐
2000+ stars! https://github.com/babashka/babashka/stargazers :star-struck:
Well deserved! Congrats!
So this now works @ben.sless
{:tasks
{:init (do (def ^:dynamic *java*)
(def ^:dynamic *browser*))
test-front-end (println :browser *browser*)
test-back-end (println :java *java*)
test-app {:depends [test-front-end test-back-end]}
run-matrix (doseq [java [8 11]
browser ["Safari" "Chrome" "Firefox"]]
(binding [*java* java
*browser* browser]
(run 'test-app)))}}
The previous issues are fixed.