This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-06-07
Channels
- # announcements (1)
- # babashka (79)
- # beginners (177)
- # cider (27)
- # cljdoc (24)
- # cljs-dev (4)
- # clojure (43)
- # clojure-norway (7)
- # clojure-uk (3)
- # clojurescript (52)
- # conjure (12)
- # cryogen (1)
- # cursive (5)
- # data-science (7)
- # datahike (1)
- # datomic (1)
- # dirac (2)
- # helix (14)
- # jobs-discuss (130)
- # juxt (4)
- # liberator (4)
- # malli (2)
- # mxnet (2)
- # news-and-articles (1)
- # nrepl (19)
- # off-topic (27)
- # pathom (3)
- # practicalli (1)
- # re-frame (4)
- # reagent (2)
- # ring (7)
- # shadow-cljs (21)
- # spacemacs (11)
- # vim (38)
- # xml (2)
- # xtdb (17)
anyone having problems with clj-http lite?
I couldn't require the client ns
using babashka
deps.edn =>
:paths ["src"]
:deps {medley {:mvn/version "1.3.0"}
org.clojure/data.xml {:mvn/version "0.0.8"}
com.amazonaws/aws-java-sdk-s3 {:mvn/version "1.11.796"}
org.martinklepsch/clj-http-lite {:mvn/version "0.4.3"}
clj-http {:mvn/version "3.10.1"}
;;potemkin {:mvn/version "0.4.5"}
}
:aliases {:test {:extra-paths ["test"]}}}
repl script =>
#!/bin/bash
export BABASHKA_CLASSPATH=$(clojure -Spath)
#export BABASHKA_PRELOADS="(require '[new.namespace])"
bb --classpath src:test --nrepl-server 1666
I want a library that I can use both in clj and bb
I'll try to use babashka.fcurl in clj then
I'm trying to migrate ancient-clj to bb / clj
yup but It's not working on cider =(
I was saying about the less opaque part of the #?()
that bb has to be lighter than clj
but thanks 😃
Invoke vim in the middle of a script, discovered by @marques.goncalves.fel :
#!/usr/bin/env bb
(require '[ :as io])
(defn vim [file]
(->
(ProcessBuilder. ["vim" file])
(.inheritIO)
(.start)
(.waitFor)))
(def readme
(let [f (io/file "README.md")]
(when (not (.exists f))
(vim (.getPath f)))
(slurp f)))
(println readme)
I am publishing my very first Babashka pod that uses multigrep
library.
https://github.com/agilecreativity/pod-b12n-mgrep
@agilecreativity nice! any reason you're not just using it directly?
borkdude@MBP2019 ~ $ export BABASHKA_CLASSPATH=$(clojure -Sdeps '{:deps {clj-commons/multigrep {:mvn/version "0.5.0"}}}' -Spath)
borkdude@MBP2019 ~ $ rlwrap bb
Babashka v0.1.1-SNAPSHOT REPL.
Use :repl/quit or :repl/exit to quit the REPL.
Clojure rocks, Bash reaches.
user=> (require '[multigrep.core :as mg])
nil
user=> (first (mg/grep #"babashka" "/Users/borkdude/Dropbox/dev/clojure/babashka/README.md"))
{:file "/Users/borkdude/Dropbox/dev/clojure/babashka/README.md", :line "<img src=\"logo/babashka.svg\" width=\"425px\">", :regex #"babashka", :re-seq ("babashka"), :line-number 1}
Wow, forgot about -Spath
, I want to added one more function to it to my use-case. e.g. greplace-all!
in this case. And just want to learn how to leverage the pod
system with it. I know it is very simple library (easy for me to start with).
Thanks for creating Babashka and the pod system. It is really nice to be able to interact with many library via the cli.
qq: I am getting the error when I remove the following pr-str
in the calling of the function. e.g.
https://github.com/agilecreativity/pod-b12n-mgrep/blob/master/src/pod/b12n/mgrep.clj#L68
e.g. if I remove the pr-str
from the last line I am getting some errors:
(defn grep
[pattern file]
(-> (mgrep/grep (re-pattern pattern) file)
pr-str))
Here is the errors:
#error {
:cause "No dispatch macro for: \""
:via
[{:type java.lang.RuntimeException
:message "No dispatch macro for: \""
:at [clojure.lang.Util runtimeException "Util.java" 221]}]
:trace
[[clojure.lang.Util runtimeException "Util.java" 221]
[clojure.lang.EdnReader$DispatchReader invoke "EdnReader.java" 552]
[clojure.lang.EdnReader readDelimitedList "EdnReader.java" 757]
[clojure.lang.EdnReader$MapReader invoke "EdnReader.java" 680]
[clojure.lang.EdnReader readDelimitedList "EdnReader.java" 757]
[clojure.lang.EdnReader$ListReader invoke "EdnReader.java" 654]
[clojure.lang.EdnReader read "EdnReader.java" 145]
[clojure.lang.EdnReader read "EdnReader.java" 111]
[clojure.lang.EdnReader readString "EdnReader.java" 67]
[clojure.edn$read_string invokeStatic "edn.clj" 46]
[babashka.pods.impl$processor$fn__15148 invoke "impl.clj" 82]
[babashka.pods.impl$processor invokeStatic "impl.clj" 94]
[babashka.pods.sci$fn__15240$fn__15273 invoke "sci.clj" 63]
[sci.impl.vars$binding_conveyor_fn$fn__7581 invoke "vars.cljc" 142]
[clojure.core$binding_conveyor_fn$fn__5758 invoke "core.clj" 2032]
[clojure.lang.AFn call "AFn.java" 18]
[java.util.concurrent.FutureTask run "FutureTask.java" 264]
[java.util.concurrent.ThreadPoolExecutor runWorker "ThreadPoolExecutor.java" 1128]
[java.util.concurrent.ThreadPoolExecutor$Worker run "ThreadPoolExecutor.java" 628]
[java.lang.Thread run "Thread.java" 834]
[com.oracle.svm.core.thread.JavaThreads threadStartRoutine "JavaThreads.java" 517]
[com.oracle.svm.core.posix.thread.PosixJavaThreads pthreadStartRoutine "PosixJavaThreads.java" 193]]}
I push my changes to develop
branch:
The diff was:
(defn grep
[pattern file]
(-> (mgrep/grep (re-pattern pattern) file)
- pr-str))
+ #_pr-str
+ identity
+ ))
The code to replicate the issue is in smoke-test.clj
in the root of the project:
#!/usr/bin/env bb
(require '[babashka.pods :as pods])
(pods/load-pod ["pod-b12n-mgrep"])
(require '[pod.b12n.mgrep :as mgrep])
{:mgrep-project
(mgrep/grep "defproject" "project.clj")
:mgrep-deps
(mgrep/grep "mvn" "deps.edn")
When run directly I am getting the correct result:
(grep "defproject" "project.clj")
;;=>
({:file "project.clj", :line "(defproject net.b12n/pod-mgrep \"1.0.0\"", :line-number 1, :regex #"defproject", :re-seq ("defproject")})
your error seems to indicate you're trying to send a regex over the wire?
user=> (edn/read-string (pr-str #"foo"))
Execution error at user/eval5 (REPL:1).
No dispatch macro for: "
The protocol uses EDN or JSON. So arguments serialized as EDN should be also readable as EDN
E.g. you can define (defn foo [x] (if (regex? x) {:regex (str x)})
and then decode :regex
as a regex in your pod.
I'm also using this in the sql pods to send connections between bb and the pod. connections are just represented as a map with an id in it
one other tip if you weren't aware of it: you can test your pod with the pod library on the JVM before natively compiling it
In the case of regex above, I guess I can also use reader
to handle it
{"readers" {"my/tag" "clojure.core/identity"}}
like the example from the doc?Just my two 2 cents for improvement for babashka. This is only a personal feedback, so I hope you do not take it personally, it is probably only me. One of my biggest issue is about adding library to Babashka. I know there is documentation, but somehow, it does not feel easy (as you have to export the classpath as a string and everything, and it might be harder to make transportable). For example, I wanted to use clj-http-lite and I find it convoluted. Is there a way babashka could leverage on deps.edn for building the cp
?
@neo2551 using https://github.com/borkdude/deps.clj this is possible
@neo2551 Btw, any reason you're using clj-http-lite and not the built-in babashka.curl? Maybe besides the point of using libs as a general question
I tried it at work, and I just wanted to make a post request with some arguments and somehow with a similar code clj-http-lite managed to return me the correct response while babashka.curl could not.
It was about content length from the header request
I think
I was a bit in a rush, so I did not took the time to perfectly found the cause, sorry.
please report any issues with babashka.curl at https://github.com/borkdude/babashka.curl
I would need to find the exact cause, otherwise I don't want to waste your time!
I will try that 🙂 Thanks a lot
Does deps start faster than clojure?
similar. there are two flavors: one that runs as a babashka script and natively compiled binaries for linux, mac and windows.
the bb script runs a few ms slower than the bash equivalent, the binary might be slightly faster
Thanks!