Fork me on GitHub
#babashka
<
2023-07-12
>
Benjamin09:07:21

I am not sure but can it be that on jvm the process/shell does not print the error to stderr?

(ns foo
  (:require
   [babashka.process :as process]))

(process/shell "ls" "nothing")
running with bb will say ls: no such file but with a jvm program it doesn't
(process/shell "ls" "nothing")

Execution error (ExceptionInfo) at babashka.process/check (process.cljc:111).

2
borkdude09:07:25

shell just uses the system's stdout. Are you in a JVM REPL? CIDER hacks may cause things to behave differently

Benjamin09:07:54

I suspected the same thing. For some reason that must be hacks on the nrepl interaction layer because the cider eval layer doesn't see this stderr. Just the message of the exception.

borkdude09:07:54

just try without cider and report back. shell isn't doing much magic

Benjamin10:07:27

confirm without cider it does print stderr

borkdude10:07:38

ok, then complain with cider :)

Stephan Renatus10:07:08

I’m stumbling with process, too, atm. I’m trying two things: 1. have a wrapper that’ll always pass {:dir "my-dir"} 2. feed a string into stdin for one call.

2
Stephan Renatus10:07:54

I think I’ve realized that I cannot do (2.) with process/shell, so I’ve tried it using process/process, but it fails with a null pointer exception:

----- Error --------------------------------------------------------------------
Type:     java.lang.NullPointerException
Location: /Users/stephan/Sources/StyraInc/example-api-authz-go/e2e/test/data-kafka/data_kafka_test.clj:25:3

----- Context ------------------------------------------------------------------
21: 
22: (def messages "{\"id\": \"bob\", \"permissions\": {\"path\": [\"cars\"], \"method\":\"GET\"}}\n")
23: 
24: (defn publish-messages []
25:   (process/process {:dir "test/data-kafka" :in "messages"}) "docker compose run -T kcat -P -b broker:29092 -t users")
      ^--- 
26: 

Stephan Renatus10:07:31

(problem (1.) is just a lack of knowledge of clojure basics, I’m afraid)

Stephan Renatus10:07:17

well — I’m sure that is true for problem (2.), too 🙃

Stephan Renatus10:07:03

in line 25 above, it’s "messages" (quotes), because I wanted to make it simpler; ideally, I’d feed it the string from line 22.

Stephan Renatus10:07:38

:man-facepalming: there’s a stray ) there

Stephan Renatus10:07:45

🥳 it works. I don’t think I actually need (1.) urgently now… I can’t pass :in to shell (or my shell wrapper) anyways.

borkdude10:07:39

> I think I’ve realized that I cannot do (2.) with process/shell, huh?

borkdude10:07:10

shell does support this

Stephan Renatus10:07:14

(shell {:in "something"} "command") is possible? I’ve misread the docs then

borkdude10:07:24

yes, it's possible

Stephan Renatus10:07:33

great, thank you.

russmatney20:07:48

very happy to find https://github.com/babashka/instaparse-bb today after getting a parser working against the jvm - dropped it into the bb.edn deps and ran tests against babashka, and they all passed! and it's suspiciously fast 😄 Much gratitude for this and babashka at large!

🎉 8
russmatney20:07:20

❯ time bb test-jvm
[(..................................................................)]
3 tests, 66 assertions, 0 failures.
bb test-jvm  25.42s user 0.94s system 580% cpu 4.539 total

❯ time bb test-bb
Testing godot-edn.parse-test

Ran 3 tests containing 66 assertions.
0 failures, 0 errors.
bb test-bb  0.05s user 0.04s system 14% cpu 0.657 total
catjam