Hi y'all how do i use babashka in calva?
Babashka has an nrepl server you can connect to for interactive development
--nrepl-server Start nREPL server. Specify port (e.g. 1667) or host and port separated by colon (e.g. 127.0.0.1:1667).
Does that help?
ooo cool thanks
Can anyone point me to a minimal example on how to use babashka as org-babel clojure backend for .org code blocks in emacs? (or is this a bad idea)?
I decided to rewrite one of the bash scripts in babashka. The problem: it reads environment variables from a .env
file in CWD.
I came up with this:
#!/usr/bin/env bash
":" ; set -a
":" ; . .env
":" ; set +a
":" ; exec bb "$0" "$@"
":" ; exit
(require '[babashka.process :as p]
'[clojure.string :as str])
;; The script continues.
Is it reasonable? Is there a better way?@p-himik that's fine with me :)
Thanks! And with this blessing, I shall continue on this endeavor.
@p-himik This is how you can do it with bb, launching itself another time:
(require '[babashka.process :as p])
(when-not (System/getenv "continue_script")
(-> (p/process ['bb *file*] {:inherit true
:env (assoc (into {} (System/getenv))
"SOME_COOL_ENV_VAR" "123"
"continue_script" "true")})
p/check)
(System/exit 0))
(println (System/getenv "SOME_COOL_ENV_VAR")) ;; 123
You can then even store env vars in EDN :)
Right, but the issue is that that .env
file is used by many other things - I can't just remove it. Maybe if I rewrite everything shell-related, but I'd like to postpone that. :)
yeah, you can also just parse the .env file, not that hard
Harder than I'd like. :) Comments, escape sequences, quotes, variable expansions. It's not a fixed format, alas.
oh ok :)
@borkdude do you know if the delightful babashka/fs
works on Windows?
it should
It might not? Not sure. Just got a failure for one of my scripts on Windows, thought it might just be my usage of fs/glob
but just tried a clojure -M:test
for babashka/fs
on a Windows 10 virtual machine and see some failures.
Can you be more specific? I currently don't have Windows-specific tests for this lib, but that sounds like a good idea
Well… there are more than a few failures…
Ran 32 tests containing 82 assertions.
9 failures, 8 errors.
It might be easiest for you to try yourself when you find a moment.
omg
@lee Are you using it from bb or as a JVM lib?
JVM for current trial.
are you on JVM 11? might be necessary
I will try on my Windows box as well
I ran on JDK8 on my virtual machine… will try JDK11…
getting same number of errors/failures on JDK11
I see some hardcoded /
, but that should not matter, /
works on all OSes.
Can reproduce on Windows. A couple of those errors are coming from posix file permission checks, which are not available on Windows, so that is kind of expected
Ya that makes sense.
Need any help on this one?
I can take a peek if you like. Lemme know.
Yeah, help is surely appreciated. I think we can add an appveyor config like the other projects (I think babashka.curl has one that might fit for this project well)
and then fix the tests
let me install the appveyor thing and then we can see the tests failing
sounds good
hmm… I just said that /
works on all OSes, but maybe not for glob
path matcher(?).
oh maybe just the matcher…
I suppose we should thread this, might be noise for many?
the spec of that glob syntax is here: True that it is different for Windows: https://docs.oracle.com/javase/7/docs/api/java/nio/file/FileSystem.html#getPathMatcher(java.lang.String) Let's take it to the babashka-sci-dev channel, I'll invite you there
sounds good