This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-01-13
Channels
- # admin-announcements (1)
- # announcements (40)
- # aws (2)
- # babashka (46)
- # babashka-sci-dev (106)
- # beginners (31)
- # cider (5)
- # circleci (2)
- # clj-kondo (48)
- # clojure (118)
- # clojure-belgium (1)
- # clojure-chicago (3)
- # clojure-europe (19)
- # clojure-ireland (3)
- # clojure-losangeles (2)
- # clojure-nl (2)
- # clojure-spec (10)
- # clojure-uk (4)
- # clojurescript (18)
- # community-development (5)
- # core-async (159)
- # cursive (16)
- # datomic (16)
- # etaoin (1)
- # fulcro (21)
- # funcool (14)
- # graalvm (5)
- # gratitude (4)
- # holy-lambda (28)
- # jobs (1)
- # jobs-discuss (1)
- # kaocha (1)
- # lsp (12)
- # malli (21)
- # meander (12)
- # music (1)
- # off-topic (8)
- # portal (5)
- # react (18)
- # reitit (1)
- # releases (4)
- # remote-jobs (1)
- # shadow-cljs (56)
- # timbre (4)
what is the best way to start a long running shell command in the background / async? (async/go (shell/sh "sh" "pretend-server.sh"))
?
@U02CV2P4J6S You can just use babashka.process
directly for this which is already async:
(require '[babashka.process :refer [process]])
(process ["sh" "pretend-server.sh"] {:inherit true})
Yes - nice indeed. Babashka terminates, but the process keeps running. Like cmd &; disown
.
#!/usr/bin/env bb
(require '[babashka.process :refer [process]])
(process ["bash" "-c" "sleep 5 && echo done"] {:inherit true})
bb finishes up, done
is printed to the terminal afterwards.is there a good way to determine what platform a babashka script is being run on (windows/linux/etc) ?
@maximilian babashka now has babashka.core/windows?
Type: java.util.MissingResourceException
Message: Could not load any resource bundle by com.sun.org.apache.xerces.internal.impl.msg.XMLMessages
jo when I use xml
from inside babashka/babashka:0.5.0-alpine
docker@U02CV2P4J6S try with 0.7.1 alpine if youre trying docker. theres an issue in our CI which hasnt pushed the docker images for 0.7.2 and 0.7.3 alpine
Step 1/4 : from babashka/babashka:0.7.1-alpine
manifest for babashka/babashka:0.7.1-alpine not found: manifest unknown: manifest unknown
@U7ERLH6JX do I put the version wrong?ah sorry 0.7.0
yeah this one works for me:
$ docker run --rm babashka/babashka:0.7.0-alpine bb -e "(+ 1 2 3)"
6
theres no 0.7.1
#xml/element{:tag :testsuites, :attrs {:name "jest tests", :tests "2", :failures "1", :errors "0", :time "0.23"}, :content ["\n " #xml/element{:tag :testsuite, :attrs {:name "undefined", :errors "0", :failures "1", :skipped "0", :timestamp "2022-01-13T16:23:28", :time "0.203", :tests "2"}, :content ["\n " #xml/element{:tag :testcase, :attrs {:classname " adds 1 + 2 to equal 3", :name " adds 1 + 2 to equal 3", :time "0.016"}, :content ["\n "]} "\n " #xml/element{:tag :testcase, :attrs {:classname " rand is 1", :name " rand is 1", :time "0.002"}, :content ["\n " #xml/element{:tag :failure, :content ["Error: expect(received).toBe(expected) // equality\n\nExpected: 1\nReceived: 0.12556658976995672\n at Object.<anonymous> (/home/benj/repos/js/gitlab-ci-tests-demo/sum.test.js:9:25)\n at Promise.then.completed (/home/benj/repos/js/gitlab-ci-tests-demo/node_modules/jest-circus/build/utils.js:391:28)\n at new Promise (<anonymous>)\n at callAsyncCircusFn (/home/benj/repos/js/gitlab-ci-tests-demo/node_modules/jest-circus/build/utils.js:316:10)\n at _callCircusTest (/home/benj/repos/js/gitlab-ci-tests-demo/node_modules/jest-circus/build/run.js:218:40)\n at processTicksAndRejections (node:internal/process/task_queues:96:5)\n at _runTest (/home/benj/repos/js/gitlab-ci-tests-demo/node_modules/jest-circus/build/run.js:155:3)\n at _runTestsForDescribeBlock (/home/benj/repos/js/gitlab-ci-tests-demo/node_modules/jest-circus/build/run.js:66:9)\n at run (/home/benj/repos/js/gitlab-ci-tests-demo/node_modules/jest-circus/build/run.js:25:3)\n at runAndTransformResultsToJestFormat (/home/benj/repos/js/gitlab-ci-tests-demo/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:170:21)"]} "\n "]} "\n "]} "\n"]}
bit unvieldy can try to narrow it down further
(require '[clojure.data.xml :as xml])
(and (xml/parse-str
"<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>")
(xml/parse-str
(slurp "junit.xml")))
content of junit:
<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="jest tests" tests="2" failures="1" errors="0" time="0.23">
<testsuite name="undefined" errors="0" failures="1" skipped="0" timestamp="2022-01-13T16:23:28" time="0.203" tests="2">
<testcase classname=" adds 1 + 2 to equal 3" name=" adds 1 + 2 to equal 3" time="0.016">
</testcase>
<testcase classname=" rand is 1" name=" rand is 1" time="0.002">
<failure>Error: expect(received).toBe(expected) // equality
Expected: 1
Received: 0.12556658976995672
at Object.<anonymous> (/home/benj/repos/js/gitlab-ci-tests-demo/sum.test.js:9:25)
at Promise.then.completed (/home/benj/repos/js/gitlab-ci-tests-demo/node_modules/jest-circus/build/utils.js:391:28)
at new Promise (<anonymous>)
at callAsyncCircusFn (/home/benj/repos/js/gitlab-ci-tests-demo/node_modules/jest-circus/build/utils.js:316:10)
at _callCircusTest (/home/benj/repos/js/gitlab-ci-tests-demo/node_modules/jest-circus/build/run.js:218:40)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at _runTest (/home/benj/repos/js/gitlab-ci-tests-demo/node_modules/jest-circus/build/run.js:155:3)
at _runTestsForDescribeBlock (/home/benj/repos/js/gitlab-ci-tests-demo/node_modules/jest-circus/build/run.js:66:9)
at run (/home/benj/repos/js/gitlab-ci-tests-demo/node_modules/jest-circus/build/run.js:25:3)
at runAndTransformResultsToJestFormat (/home/benj/repos/js/gitlab-ci-tests-demo/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:170:21)</failure>
</testcase>
</testsuite>
</testsuites>
@U02CV2P4J6S With 0.7.0 I get:
$ docker run --rm -v $PWD:/tmp babashka/babashka:0.7.0-alpine bb /tmp/script.clj
#xml/element{:tag :testsuites, :attrs {:name "jest tests", :tests "2", :failures "1", :errors "0", :time "0.23"}
if you can make a repro in a github repo or so including the docker command, then I can try again
indeed for me too. Then the difference was that I ran it with a gitlab runner - will try with 0.7.0 to check
Can I hide the output when a process finishes?
{:proc #object[java.lang.ProcessImpl 0x2d8bcb "Process[pid=6547, exitValue=0]"], :exit 0, :in #object[java.lang.ProcessBuilder$NullOutputStream 0x48c6e255 "java.lang.ProcessBuilder$NullOutputStream@48c6e255"], :out #object[java.lang.ProcessBuilder$NullInputStream 0x60a9b89 "java.lang.ProcessBuilder$NullInputStream@60a9b89"], :err #object[java.lang.ProcessBuilder$NullInputStream 0x60a9b89 "java.lang.ProcessBuilder$NullInputStream@60a9b89"], :prev nil, :cmd ["clojure" "-X:dev" "flyway/migrate"]
Hello! First time in the channel. I'm dropping in to inquire about some bb
behavior we ran into in the last couple days re: CLI-argument handling.
I see a change in behavior at version 0.6.5, which is that --
is passed as the first argument to the -main
, rather than being interpreted as a separator. See below for illustration
$ cat f.clj
(ns f)
(defn -main [& args] (prn args))
$ cat test.sh
#!/bin/sh
VERSION=${1:-0.7.1}
echo $VERSION
docker run -v `pwd`:`pwd` -w `pwd` --rm -it babashka/babashka:${VERSION} bb -cp . --main f -- hi
$ for version in 0.3.0 0.4.0 0.5.0 0.6.0 0.6.1 0.6.2 0.6.3 0.6.4 0.6.5 0.6.6 0.6.7 0.6.8; do sh test.sh $version; done
0.3.0
("hi")
0.4.0
("hi")
0.5.0
("hi")
0.6.0
("hi")
0.6.1
("hi")
0.6.2
("hi")
0.6.3
("hi")
0.6.4
("hi")
0.6.5
("--" "hi")
0.6.6
("--" "hi")
0.6.7
("--" "hi")
0.6.8
("--" "hi")
This caused us some breakage as we moved past the 0.6.5 version. I'm wondering if this was intended behavior or the consequence of some other change. Thanks!
(@U0EHU1800 helped me narrow this down, BTW)
@U02TYRYJC6N Thanks for reporting. I think this is a glitch which should be fixed in bb.
Thanks @U04V15CAJ, absolutely will do. Is the above sufficient for the description in the issue, or is there anything else you'd like added?