This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-02-10
Channels
- # announcements (6)
- # babashka (38)
- # beginners (85)
- # biff (3)
- # calva (2)
- # cider (11)
- # clerk (14)
- # clj-kondo (6)
- # clj-on-windows (27)
- # cljsrn (18)
- # cljtogether (2)
- # clojure (106)
- # clojure-austin (1)
- # clojure-belgium (1)
- # clojure-europe (19)
- # clojure-nl (1)
- # clojure-norway (9)
- # clojure-uk (2)
- # clr (2)
- # cryogen (1)
- # cursive (10)
- # datahike (3)
- # datavis (2)
- # datomic (15)
- # emacs (7)
- # graalvm (10)
- # graphql (20)
- # gratitude (1)
- # hyperfiddle (1)
- # improve-getting-started (23)
- # joyride (24)
- # london-clojurians (1)
- # lsp (22)
- # malli (4)
- # matcher-combinators (3)
- # membrane (13)
- # off-topic (1)
- # pathom (24)
- # polylith (9)
- # react (31)
- # reagent (9)
- # releases (1)
- # remote-jobs (1)
- # reveal (3)
- # shadow-cljs (50)
- # spacemacs (3)
- # specter (5)
- # xtdb (4)
From what I can read in https://github.com/babashka/process it seems that (require '[babashka.process.pprint])
should always “just work”… what did I miss?
(Note: requiring other things eg process/shell, works as expected.)
ah so the Clojure.pprint bit only applies when invoking clj. That makes sense in hindsight 🙂
yeah, and I think nowadays it isn't mostly necessary at all to call it yourself anymore, since it's automatically done when clojure.pprint is already loaded
Not exactly a follow up, but debugging the same thing (and my clojure is 5+ years rusty, so I’m probably misreading)… I want to pass both opts, and a command sequence to process. The third/fourth rows here suggests that I can’t have both:
(parse-args ["git" "ls-files"]) ; {:prev nil, :cmd ["git" "ls-files"], :opts nil}
(parse-args [["git" "ls-files"]]) ; {:prev nil, :cmd ["git" "ls-files"], :opts nil}
(parse-args [{} ["git" "ls-files"]]) ; {:prev nil, :cmd ["[git" "ls-files]"], :opts {}}
(parse-args [{:cmd ["git" "ls-files"]}]) ; {:prev nil, :cmd [], :opts {:cmd ["git" "ls-files"]}}
Note that cmd
gets stringified to become the unwelcome command [git
when it’s second arg, nor is there an explicit way to set cmd
to a sequence.
It seems better to support sequences as such so that my pre-constructed command + args can be passed directly… (instead of me quoting and using bash -c).
[a] do I understand correctly?
[b] PR welcome with such a tweak?(parse-args [{} "git" "ls-files"]) ; {:prev nil, :cmd ["git" "ls-files"], :opts {}}
does work, thanks!
It feels a bit incongruous that it flattens in the “first position” sequence, but not the second.
I’m curious, is there a reason to avoid that case? (Not seeking controversy, but curious since the behavior is counter to my intuitions after my initial sequence experiment worked.)
The process library moved from the syntax (process [args] ?opts))
to (process ?opts ...args)
since this was easier in combination with apply
. parse-args
bridges that migration
That this is the case shouldn't matter to you as a new user, the README reflects how you should currently use the library
I have considered allowing this:
(process ?opts ...preceding-args [remaining-arguments])
right now you have to do it like this:
(apply process ?opts ...preceding-args [remaining-arguments])
Close, but not quite — the “considered allowing” form seems that would imply full something like:
;; both args and extra-args arguments are flattened into command
(process ?opts args & extra-args)
where both args and extra-args may be string-or-seq-of-string, but “another migration” suggests that it’s no longer compatible.Perhaps I misunderstand some of the nuance in the type checks due to the argument reordering. My mental model assumes 3 basic types: map (opts), seq (array of args), or string (arg).
(process ?opts [...strings])
was never supported - if it works, it's purely accidental
there are many things in clojure that work, but not according to prescribed usage. E.g. (inc (merge 1))
deps-try, a bb CLI to try out JVM Clojure libs: https://twitter.com/borkdude/status/1624027178307387393
Cool! But see in 🧵
deps-try 127 ✘ 14:03:38
----- Error --------------------------------------------------------------------
Type: clojure.lang.ArityException
Message: Wrong number of args (3) passed to: babashka.deps/clojure
Location: /Users/dmg46664/.gitlibs/libs/io.github.eval/deps-try/dca3e52fa7e723021ae4f8c62d3c111771d27bde/src/eval/deps_try.clj:26:40
----- Context ------------------------------------------------------------------
22: (str/trim (with-out-str (deps/clojure {:dir (str tmp)} "-Spath" "-Sdeps" (str {:deps deps})))))
23:
24: (defn -main [& args]
25: (fs/with-temp-dir [tmp {}]
26: (let [verbose-output (with-out-str (deps/clojure {:dir (str tmp)} "-Sverbose" "-Spath"))
^--- Wrong number of args (3) passed to: babashka.deps/clojure
27: cp-file (parse-cp-file verbose-output)
28: basis-file (str/replace cp-file #".cp$" ".basis")
29: requested-deps (try-deps/parse-dep-args args)
30: default-cp (deps->cp tmp '{org.clojure/clojure {:mvn/version "RELEASE"}})
31: requested-cp (deps->cp tmp requested-deps)
----- Stack trace --------------------------------------------------------------
eval.deps-try - /Users/dmg46664/.gitlibs/libs/io.github.eval/deps-try/dca3e52fa7e723021ae4f8c62d3c111771d27bde/src/eval/deps_try.clj:26:40
clojure.core/apply - <built-in>
user - <expr>:1:38
@U03B2SRNYTY Upgrade your bb
Works! Thanks.
@UHZPYLPU1 Yes:
(shell {:extra-env {"MY_ENV_VAR" "1"} "clojure -M:foo:baz")
@U04V15CAJ you rocks! Thanks!
Hi, I'm attempting to use java.time.format.DateTimeFormatter
in bb and I'm seeing the java.util.Locale
is having no effect:
$ bb
Babashka v1.1.173 REPL.
Use :repl/quit or :repl/exit to quit the REPL.
Clojure rocks, Bash reaches.
user=> (import '[java.time LocalDate])
java.time.LocalDate
user=> (import '[java.time.format DateTimeFormatter])
java.time.format.DateTimeFormatter
user=> (def df (.withLocale (DateTimeFormatter/ofPattern "YYYY-MMM-dd") java.util.Locale/JAPAN))
#'user/df
user=> (.format (LocalDate/now) df)
"2023-Feb-10"
user=>
vs clojure jvm:
$ clj
Clojure 1.11.1
user=> (import '[java.time LocalDate])
java.time.LocalDate
user=> (import '[java.time.format DateTimeFormatter])
java.time.format.DateTimeFormatter
user=> (def df (.withLocale (DateTimeFormatter/ofPattern "YYYY-MMM-dd") java.util.Locale/JAPAN))
#'user/df
user=> (.format (LocalDate/now) df)
"2023-2月-10"
user=>
@U051V5LLP locales aren't automatically included in a native image since they take up a lot of space. I think only English is included
and because these are defined in java you'd need a custom image to add more, is that correct?