This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-08-31
Channels
- # announcements (3)
- # aws-lambda (1)
- # babashka (122)
- # beginners (241)
- # calva (28)
- # cider (7)
- # clara (7)
- # clj-kondo (43)
- # clojars (5)
- # clojure (326)
- # clojure-europe (60)
- # clojure-italy (2)
- # clojure-nl (4)
- # clojure-spec (21)
- # clojure-uk (4)
- # clojurescript (162)
- # cursive (30)
- # datomic (3)
- # editors (5)
- # emacs (4)
- # figwheel-main (1)
- # fulcro (24)
- # gratitude (3)
- # helix (7)
- # honeysql (20)
- # improve-getting-started (1)
- # introduce-yourself (11)
- # jobs (3)
- # joker (2)
- # kaocha (15)
- # lsp (21)
- # lumo (2)
- # meander (3)
- # off-topic (34)
- # re-frame (6)
- # reagent (1)
- # releases (4)
- # rum (2)
- # shadow-cljs (37)
- # spacemacs (16)
- # tools-deps (16)
- # vim (23)
- # xtdb (32)
@borkdude hi! We use babashka
in CI Jenkins in a closed environment without Internet. When we run babashka task, babashka tries to download tools.deps 1.10.3.822 and fails. Is there any way to run babashka without internet ?
@mike1452 I think it only does this when you have :deps
in your bb.edn and when you have deps then bb needs internet to download these
ah, thank you. I will check.
Yes, we have `
:deps {cprop/cprop {:mvn/version "0.1.18"}}
Can I put cprop
to classpath or .m2 to make babashka
not using internet?@mike1452 Perhaps you can use bb uberjar
for this, but currently that doesn't really integrate with bb.edn tasks I think
bb uberjar will package the deps into an uberjar which you can invoke with bb foo.jar
This is CI task, uberjar is not suitable here.
cprop is used to work with env vars for tasks.
Ok, I probably should rewrite my tasks to use (System/getProperties) directly, not from cprop
Yeah, I'm just experimenting right now. I will respond here when I find the solution.
@borkdude we made several experiments.
We completely deleted :deps section from bb.edn. It doesn't help. Babashka tries to download jar file Could not find /home/jenkins/.deps.clj/1.10.3.822/ClojureTools/clojure-tools-1.10.3.822.jar
Where should we place clojure-tools-1.10.3.822.jar?
What folder? Can't find group-id/artifact-id inside jar?
Btw, we run bb not in a docker.
You should be placing it in /home/jenkins/.deps.clj/1.10.3.822/ClojureTools
like the error message suggests
it surprises me that bb tries to download if you don't use deps. are you using babashka.deps
anywhere else in your scripts
borkdude@MBP2019 /tmp $ rm -rf ~/.deps.clj
borkdude@MBP2019 /tmp $ bb dude.clj
6
borkdude@MBP2019 /tmp $ cat dude.clj
(+ 1 2 3)
borkdude@MBP2019 /tmp $ echo '{:deps {}}' > bb.edn
borkdude@MBP2019 /tmp $ bb dude.clj
Could not find /Users/borkdude/.deps.clj/1.10.3.933/ClojureTools/clojure-tools-1.10.3.933.jar
Attempting download from
6
Thank you. I will continue to experiment and respond here
We have closed Nexus repo with all deps. Can I put :mvn/repos
to bb.edn to tell babashka download deps from here ?
but it will still try to download the tools jar the first time you're downloading deps
In babashka book I can't find how to do this.
Is there a way to call nbb from a js file? I’m not entirely sure how to import it because I don’t really understand what shadow has generated in nbb_core.js. I want to do something like this
import nbb from 'nbb'
const script = fs.readFileSync('./test.cljs', 'utf8')
nbb(script, 'args');
@alex395 That is something which I still haven't figured out yet. I think nbb should expose an API but it's not yet been implemented. If you want to help with this, I would appreciate that
@alex395 I don't know how normal nodejs projects do this but perhaps we can make a index.js
in the repo which exports things
Is there something like a :bb
or :sci
platform tag for reader conditional expressions that would target bb/sci? I've got a script that's using data.xml, and the alias-uri
function https://github.com/clojure/data.xml/blob/master/src/main/clojure/clojure/data/xml/name.cljc#L99:
#?(:clj
(defn alias-uri
"Define a Clojure namespace aliases for xmlns uris.
This sets up the current namespace for reading qnames denoted with
So bb fails with:
7: (xml/alias-uri 'Atom "")
^--- Could not resolve symbol: xml/alias-uri
I'm not sure if there's something in that function that legitimately won't work on bb, or if it was just not around/not considered when that code was written.Reader conditionals are new to me, but the docs only list four possibilities: :clj :cljs :cljr :default
: https://clojure.org/guides/reader_conditionals
@horton.wh.dev yes, :bb
@horton.wh.dev The precedence for reader conditionals is, first :bb
, then :clj
, if there is no :bb
then bb will take the :clj
branch
Thanks, so in that case since alias-uri
only has a single :clj
branch, wouldn't we expect bb pick it up as-is?
$ bb -e "(clojure.data.xml/alias-uri 'foo 'bar)"
----- Error --------------------------------------------------------------------
Type: clojure.lang.ExceptionInfo
Message: Could not resolve symbol: clojure.data.xml/alias-uri
Location: <expr>:1:2
Phase: analysis
----- Context ------------------------------------------------------------------
1: (clojure.data.xml/alias-uri 'foo 'bar)
^--- Could not resolve symbol: clojure.data.xml/alias-uri
It's a function or macro that needs to be addedThe available functions are mapped in this file: https://github.com/babashka/babashka/blob/master/feature-xml/babashka/impl/xml.clj
Ah, should have clarified that I was trying to pull in data.xml using a bb.edn
file. Did not realize it was packaged with bb itself. And this is where my understanding gets really, really fuzzy -- can any arbitrary dependency that's not already available in bb be pulled in using a bb.edn
and be expected to work? Or do other libraries need to be "prepared" somehow to run on sci vs. normal JVM Clojure? I'm relatively new to Clojure in general so sorry if that's an obvious question.
@horton.wh.dev That's an understandable question. bb supports a (large) subset of Clojure. Some libraries work, but ones that go outside of the subset don't.
That makes sense, thanks. Is the subset of non-built-in ones that do work known, or is it more of a "try and see what happens" thing? 🙂
@horton.wh.dev This may be helpful: https://book.babashka.org/#differences-with-clojure
Excellent, thank you. And thanks for all the work on babashka itself too, it is really cool.
there’s currently no way to customize the (excellent!) exception printing in babashka, correct? We’d be interested to show the report but hide the locals because they can leak sensitive information (secrets).
but one could wonder: if the locals contain sensitive info, then anyone having access to that script can already get at that right?
or is it more like when you're sharing your screen, it can get awkward if someone else sees the output?
yeah, in our case the user does has access to the secret (they put it there in the first place) but we don’t want to write it to the logfile where the babashka exception ends up being written to. Our use case is scripting for github and s3 bucket components on nextjournal, so it’s great to see more info when things don’t work but we don’t want the locals there. A cli flag seems like overkill though since our use case is quite unusual.
Not sure how easy that is, but this problem might occur more frequently with other tools as well
hmm, so wrap it in a thing with a custom .toString
impl? Yeah, I guess that could work, will give it a try and let you know, thanks!
@mkvlr You can also set the uncaught exception handler and then remove :locals
from the exception, perhaps (I'll try locally)
@borkdude oh, so just remove it from ex-data
? We already catch the exception so that should be easy, one sec
if you're already catching the exception that that's the place where you want to do this?
but there we get whatever exception occurred and not this one? https://github.com/babashka/babashka/blob/512a6f2220a0e54ab585ead1dec2b10995f637f9/src/babashka/impl/error_handler.clj#L79
try
is handled by the interpreter, only when the exception escapes the interpreter, then this stacktrace + locals stuff gets added
so I think it has to be an option in bb itself probably. or perhaps something that you can set in bb. exposing the stacktrace stuff has been on my list for a while. perhaps we can make this more programmable in scripts
Perhaps you can just grep the locals portion out:
----- Locals -------------------------------------------------------------------
x: 1
----- Stack trace
At least it's structured so you can do italso the printing ******
is something we’ll try, might work well with protocol extension via metadata
@mkvlr perhaps solving this at a lower (or higher, depends on how you look at this) is better, so it works independent of language/tech?
yeah, not sure how it can be prevented in general, will have to take a look at how circle ci does it
https://circleci.com/blog/keep-environment-variables-private-with-secret-masking/ < @mkvlr
> With secret masking, if you inadvertently `echo`, or print, your environment variable or context, we substitute it with `XXXXX`. Before the build logs are printed out by the UI, CircleCI scans the logs’ output to ensure there are no secrets printed that match against the names of project or context environment variables.
not sure I fully understand it, do they prevent secret env variable names or contents from being printed out?
@mkvlr would it help if bb "masked" the variable if the value came from an environment variable?
that could be implemented on the bb side but I'm not sure if it would solve the problem generally enough
we could just look at all the vals of the env vars and then mask it if it's in that set
perhaps bb could always mask the values of locals or dump the locals to a file instead
I found some Java libraries too https://en.wikipedia.org/wiki/Expect#Java did not try them yet, also no clojure wrappers to my knowledge
@i.slack I haven't seen something like this in the bb space yet, but perhaps it can be built in user space?