This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-12-13
Channels
- # adventofcode (36)
- # aleph (1)
- # announcements (7)
- # aws (4)
- # babashka (14)
- # beginners (61)
- # calva (79)
- # cider (19)
- # clojure (48)
- # clojure-austin (1)
- # clojure-australia (2)
- # clojure-czech (2)
- # clojure-europe (46)
- # clojure-france (8)
- # clojure-nl (19)
- # clojure-uk (4)
- # clojuredesign-podcast (14)
- # core-logic (42)
- # data-science (3)
- # datalevin (8)
- # datomic (76)
- # events (1)
- # figwheel-main (9)
- # fulcro (6)
- # helix (1)
- # holy-lambda (1)
- # honeysql (2)
- # jobs (2)
- # jobs-discuss (20)
- # leiningen (5)
- # lsp (87)
- # minecraft (11)
- # nextjournal (4)
- # off-topic (17)
- # practicalli (1)
- # reagent (22)
- # reitit (8)
- # releases (3)
- # rum (2)
- # shadow-cljs (18)
- # sql (11)
- # tools-build (5)
- # tools-deps (9)
- # xtdb (20)
Is there a way to set env vars for tasks? I saw https://github.com/babashka/babashka/issues/849, so guessing not, but maybe there's a workaround?
@alex.sheluchin you can set env vars for shell
and clojure
, both with (f {:extra-env {"FOO" "BAR"}} ...)
@U04V15CAJ what am I doing wrong here?
foo (shell {:extra-env {:FOO "BAR"}}
"echo $FOO")
$ bb foo
$FOO
I tried with both "FOO"
and :FOO
and got the same result, like it's not performing the expansion.
I tried the keyword version because of this example in the bb/process readme:
user=> (-> (process '[sh -c "echo $FOO"] {:env {:FOO "BAR"}}) :out slurp)
"BAR\n"
Ah, okay, I was confused in thinking bash syntax is okay there. Either "printenv FOO"
or pass the command to the shell with -c
. I'm not familiar with Runtime.exec() - didn't quite understand its execution context.
Thanks @U04V15CAJ.
This uses ProcessBuilder, not Runtime.exec, but it's similar. There is nothing bash specific in this since it works cross platform
That makes sense seeing as clojure
and shell
both return a bb/process, which is a wrapper for ProcessBuilder.
I think it's a little unclear because shell
returns a process
, and process
has sh
, but not shell
, but there's also clojure.java.shell
which has a sh
and they all kinda perform.. just about the same thing, but not quite. There's a lot of name overloading going on, which I suppose is intentional to make things familiar, but still makes my brain 🤯 a little 🙂 Just my impression as someone fairly new to this machinery. I don't know if the docs could clarify this for a newbie like me.
But for what it's worth, I did search for "environment variable" and similar terms in the book and couldn't find what I was looking for. Maybe it's common enough of an operation that it should get a ctrl+f friendly mention?
Thanks for the help @U04V15CAJ. Just wanted to provide some feedback. Appreciate your work 🙏
@alex.sheluchin Yes, you are absolutely right and this is on my TODO list, but feel free to make a PR to the book if you want to have it in there sooner :)
@U011NGC5FFY do you mean documentation on setting env vars? I think I added a blurb when this came up. https://github.com/babashka/book/commit/28e24277ec6c5ecaaec01abe3b644433b7cd06cb Does that cover it?
no, on the fact that shell is not a bash shell - so it does not do expansion + example on how to do expansion.