Fork me on GitHub
#babashka
<
2023-05-29
>
Colin (fosskers)04:05:05

Hi there, new to BB: what's the canonical way to "exit with failure"?

Colin (fosskers)04:05:35

i.e. exit the script immediately and yield an error code of 1

Bob B04:05:26

you can (System/exit 1)

borkdude07:05:10

or (throw (ex-info "My error" {:babashka/exit 1}))

🆒 2
Colin (fosskers)07:05:53

Let's see if that barfs a trace too... :thinking_face:

Colin (fosskers)07:05:41

Ah it doesn't! Lovely

Colin (fosskers)06:05:25

Looks like cider-debug-defun-at-point doesn't work when connected to a BB nrepl?

borkdude07:05:04

The bb nREPL doesn't support all of CIDER. What you can do alternatively is to use print-deps to create a deps.edn, develop using your normal Clojure tools and then run with bb again

Colin (fosskers)07:05:24

bb nrepl-server is at least handy for making sure everything is built-in and "just works"

Colin (fosskers)07:05:30

Also no project structure necessary

fjsousa08:05:06

hey! has anyone else had a go at writing webpages in shared hosts based on @jayzawrotny post https://eccentric-j.com/blog/clojure-like-its-php.html

🎉 2
jaide14:05:19

That reminds me there’s some aspects of borkdude’s example I like better, like the way it uses a php script to dispatch to babashka over cgi. The cgi approach works but debugging it is not as straight forward

chromalchemy15:05:47

@jayzawrotny are you using your solution actively? Any big takeaways or tradeoffs to note after a few years experience?

jaide15:05:19

Been keeping busy with other projects in the cljs and nbb space as I generally like the npm\node ecosystem. It has been great for quick prototypes though when I need a backend really quick but don’t want to setup a running app with ring

jaide15:05:14

Trade offs are mostly performance and debugging, but the php wrapper borkdude came up with makes that part better

fjsousa22:05:40

@U09D96P9B I implemented this based on @jayzawrotny blog post last year and has been running stress free.

fjsousa22:05:16

thanks for the links, will look at it tomorrow with more attention

chromalchemy22:05:45

@U0KKRRLCB Did you have a link?

fjsousa13:05:04

actually just pushed a contact form with htmx and I'm quite happy with the was I was able to reuse "frontend" hiccup in the rendered response from the server. almost felt like a component abstraction

chromalchemy15:05:15

Nice. Refactoring a basic PHP contact form (without knowing PHP!) was my first potential use case.

👍 2
fjsousa17:05:03

This old thread on HN is related

wilkerlucio13:05:13

hello, I'm trying to follow the setup described here: https://github.com/babashka/babashka/issues/733#issue-811939787, but when I run this script with babashka I get the following error (in 🧵 )

wilkerlucio13:05:26

wilker.lucio@wilker script % bb bbcp.clj
Error building classpath. Local lib babashka/babashka.core not found: /Users/wilker.lucio/script/babashka.core
----- Error --------------------------------------------------------------------
Type:     clojure.lang.ExceptionInfo
Message:
Data:     {:proc #object[java.lang.ProcessImpl 0x18d576bb "Process[pid=69139, exitValue=1]"], :exit 1, :in #object[java.lang.ProcessBuilder$NullOutputStream 0x51ce0f42 "java.lang.ProcessBuilder$NullOutputStream@51ce0f42"], :out #object[java.lang.ProcessImpl$ProcessPipeInputStream 0x7181ac7a "java.lang.ProcessImpl$ProcessPipeInputStream@7181ac7a"], :err #object[java.lang.ProcessBuilder$NullInputStream 0x271997af "java.lang.ProcessBuilder$NullInputStream@271997af"], :prev nil, :cmd ["/usr/bin/java" "-XX:-OmitStackTraceInFastThrow" "-classpath" "/Users/wilker.lucio/.deps.clj/1.11.1.1273/ClojureTools/clojure-tools-1.11.1.1273.jar" "clojure.main" "-m" "clojure.tools.deps.script.make-classpath2" "--config-user" "/Users/wilker.lucio/.clojure/deps.edn" "--config-project" "deps.edn" "--basis-file" "/Users/wilker.lucio/.clojure/.cpcache/FE7218DAF1D4CA40D578DF03FDE86C4F.basis" "--cp-file" "/Users/wilker.lucio/.clojure/.cpcache/FE7218DAF1D4CA40D578DF03FDE86C4F.cp" "--jvm-file" "/Users/wilker.lucio/.clojure/.cpcache/FE7218DAF1D4CA40D578DF03FDE86C4F.jvm" "--main-file" "/Users/wilker.lucio/.clojure/.cpcache/FE7218DAF1D4CA40D578DF03FDE86C4F.main" "--manifest-file" "/Users/wilker.lucio/.clojure/.cpcache/FE7218DAF1D4CA40D578DF03FDE86C4F.manifest" "--config-data" "{:deps {selmer/selmer {:mvn/version \"1.12.50\"}, org.clojure/clojure {:mvn/version \"1.11.1\"}, org.clojure/tools.logging {:mvn/version \"1.1.0\"}, insn/insn {:mvn/version \"0.5.2\"}, org.clojure/tools.cli {:mvn/version \"1.0.214\"}, borkdude/graal.locking {:mvn/version \"0.0.2\"}, rewrite-clj/rewrite-clj {:mvn/version \"1.1.46\"}, babashka/babashka.core {:local/root \"babashka.core\"}, org.flatland/ordered {:mvn/version \"1.5.9\"}, org.postgresql/postgresql {:mvn/version \"42.2.18\"}, babashka/clojure-lanterna {:mvn/version \"0.9.8-SNAPSHOT\"}, org.babashka/babashka.impl.java {:mvn/version \"0.1.8\"}, hiccup/hiccup {:mvn/version \"2.0.0-alpha2\"}, org.babashka/cli {:mvn/version \"0.7.51\"}, seancorfield/next.jdbc {:mvn/version \"1.1.610\"}, org.clojure/data.xml {:mvn/version \"0.2.0-alpha8\"}, org.clojure/data.csv {:mvn/version \"1.0.0\"}, com.taoensso/timbre {:mvn/version \"6.0.1\"}, com.cognitect/transit-clj {:mvn/version \"1.0.333\"}, babashka/babashka.curl {:mvn/version \"0.0.3\"}, clj-commons/clj-yaml {:mvn/version \"1.0.26\"}, org.clojure/core.rrb-vector {:mvn/version \"0.1.2\"}, org.babashka/sci.impl.types {:mvn/version \"0.0.2\"}, cheshire/cheshire {:mvn/version \"5.11.0\"}, org.clojure/core.match {:mvn/version \"1.0.0\"}, org.babashka/sci {:local/root \"sci\"}, datascript/datascript {:mvn/version \"1.0.1\"}, org.babashka/http-client {:mvn/version \"0.3.11\"}, org.hsqldb/hsqldb {:mvn/version \"2.5.1\"}, org.clojure/test.check {:mvn/version \"1.1.1\"}, babashka/fs {:mvn/version \"0.0.5\"}, org.clojure/data.priority-map {:mvn/version \"1.1.0\"}, nrepl/bencode {:mvn/version \"1.1.0\"}, org.clojure/core.async {:mvn/version \"1.6.673\"}, http-kit/http-kit {:mvn/version \"2.6.0-RC1\"}}}"], :type :babashka.process/error}
Location: /Users/wilker.lucio/script/bbcp.clj:14:24

----- Context ------------------------------------------------------------------
10:                    'babashka/babashka.curl {:mvn/version "0.0.3"})
11:       deps (update deps :deps dissoc 'borkdude/sci)
12:       deps {:deps (:deps deps)}
13:       ;; _ (clojure.pprint/pprint deps)
14:       cp (with-out-str (deps/clojure ["-Spath" "-Sdeps" deps]))]
                           ^---
15:   (println cp))

----- Stack trace --------------------------------------------------------------
babashka.process/check         - <built-in>
babashka.process/shell         - <built-in>
clojure.core/apply             - <built-in>
babashka.impl.process/shell    - <built-in>
babashka.deps/clojure/fn--6019 - <built-in>
borkdude.deps/-main            - <built-in>
clojure.core/apply             - <built-in>
babashka.deps/clojure          - <built-in>
user                           - /Users/wilker.lucio/script/bbcp.clj:14:24
user                           - /Users/wilker.lucio/script/bbcp.clj:7:1

wilkerlucio13:05:45

what am I doing wrong?

borkdude13:05:04

@U066U8JQJ This workaround should not be necessary at all anymore for bb + lsp. Just a bb.edn should be sufficient

wilkerlucio13:05:18

gonna try that 🙂

borkdude13:05:56

Just tried it, still works :)

wilkerlucio13:05:08

also got it working fine here 😄

wilkerlucio13:05:26

maybe its worth updating that comment? because that was the link I've found when I googled for clojure lsp babashka dev

borkdude13:05:54

ok, feel free to post the info there

wilkerlucio13:05:01

add, but still think editing the main one will have a better result, because its already an edited content pointing to the workaround solution

borkdude13:05:49

ok, cool, made a comment in the original message

🙏 2