Fork me on GitHub

How to overcome the problem of "curl: (60) The certificate issuer's certificate has expired"? (I'm not sure if this is unique of bb or Clojure in general) In a new virtual machine (production) after setting of bb 0.6.5 (without Clojure), running the repl with trace below: user=> (require '[babashka.curl :as curl]) nil user=> (let [api-host "" api-version "v1" service "current" output-format "json" key "xxxxxx" latitude -122.2284271 longitude 123.812209 endpoint (str api-host "/" api-version "/" service "." output-format "?key=" key "&q=" latitude "," longitude)] (curl/get endpoint)) clojure.lang.ExceptionInfo: curl: (60) The certificate issuer's certificate has expired. Check your system date and time. More details here: curl performs SSL certificate verification by default, using a "bundle" of Certificate Authority (CA) public keys (CA certs). If the default bundle file isn't adequate, you can specify an alternate file using the --cacert option. If this HTTPS server uses a certificate signed by a CA represented in the bundle, the certificate verification probably failed due to a problem with the certificate (it might be expired, or the name might not match the domain name in the URL). If you'd like to turn off curl's verification of the certificate, use the -k (or --insecure) option. The same code it works on my development machine with bb (0.6.5) repl. Could you give me some pointer how to make it work with bb? Thanks!


It works for me, on my machine, using bb 0.6.5. My guess is that there is a proxy somewhere in production that is intercepting the requests and doing a MITM?


(I copy and pasted your example and ran it without any issues)


You're right. In my development environment, it also works. But for the production environment, it doesn't. I wonder how to fix it for the production machine.


Probably not related to babashka. I bet you get the same error if you run the curl command directly from the shell. ssh to the machine and run curl -V. What version is it?


Well, you could pass a raw argument to curl, with -k


that will make the https request insecure


whether or not you're happy with that...


Thanks for the helpful tips! I'll try to pass -k as a raw argument. Here is the curl's version, and performing it to another host: Last login: Tue Nov 16 20:18:43 2021 from [[email protected] ~]$ curl --version curl 7.29.0 (x86_64-redhat-linux-gnu) libcurl/7.29.0 NSS/3.21 Basic ECC zlib/1.2.7 libidn/1.28 libssh2/1.4.3 Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smtp smtps telnet tftp Features: AsynchDNS GSS-Negotiate IDN IPv6 Largefile NTLM NTLM_WB SSL libz unix-sockets [[email protected] ~]$ curl "" <html> <head><title>301 Moved Permanently</title></head> <body bgcolor="white"> <center><h1>301 Moved Permanently</h1></center> <hr><center>CloudFront</center> </body> </html> It seems to be host specific. I'll try to do command line with the host of my interest. The production machine with the same script, it used to work, but stop working at the end of September.


Yes, --insecure in :raw-args works: (curl/get endpoint {:raw-args ["--insecure"]}) Now, I need to understand what the implication of "insecure", to avoid security trouble. Thanks again!

Karol Wójcik09:11:11

I'm trying to use the newest neil, but I'm receiving the following error:

➜  frisco-react git:(master) neil help   
----- Error --------------------------------------------------------------------
Type:     java.nio.file.NoSuchFileException
Message:  /home/fierycod/.m2/repository/borkdude/rewrite-edn/0.0.2/rewrite-edn-0.0.2.jar
Location: 13:1
I'm sure this is problem with deps caching and I'm curious if there is some way to resolve it once and forever.


did you wipe your m2 while not wiping .cpcache folders?

Karol Wójcik10:11:23

Are there global .cpcaches?




this is where bb saves all the invocations

Karol Wójcik10:11:50

Thank you so much


I tried running markdown-clj with babashka and it almost worked, barring one small detail which I will PR back to the original repository. I tried this in my blog and it works well. All markdown-clj tests are also passing.

🤓 1

Is there a way to dispatch a command with something like shell/sh asynchronously and get the stdout as stream so I can do something with it? I essentially just want it to pipe it back out to stdout.


@finn.volkel You can use babashka.process with :inherit true or use babashka.tasks/shell


(require '[babashka.process :as p])
(-> (p/process "ls -la" {:inherit true}) p/check)
(babashka.tasks/shell "ls -la")
That is pretty much equivalent

👍 1

Awesome, didn't know about the two.


The London Clojurians are happy to announce: nbb: ad-hoc scripting for Clojure on Node.js (by Michiel Borkent)


many thanks to @borkdude for another great tool! 👏:skin-tone-2:


i'm trying to feed data to influx but curl gives me this


Cannot run program "curl": error=7, Argument list too long


the input is a text atom, given as :body


@shem which OS are you on


@shem Not sure. You can try to write it to a temp file first and then use (io/file ...) Alternatively you can use or org.httpkit.client


ok, i'll check these. thanks


passing an (io/file ..) will make babashka.curl use that option


works perfectly!


Hello! I have two files: bb.edn with tasks, script.clj for code used in tasks. How to load script.clj from bb.edn?


You can do it two ways. Add :paths ["."] in bb.edn and then use :requires ([script]) (use (ns script) at the top).


Or you can use (load-file "script.clj")


Thank, you. load-file works.


I wondered, did you already give the presentation at the meetup?


The meetup did not take place because of the covid. To make a reference I'm writing an article about babashka in Devops pipelines in a bank. I send it to PR department at the end of this week. When article will be published on behalf of bank I'll send you a link.


Thank you :)


New blog post: making markdown-clj babashka compatible.

😎 3
borkdude 1

great job!


Now it also works with #nbb:

$ nbb -cp src/clj:src/cljc:src/cljs -e "(require '[markdown.core :as md]) (md/md->html \"# 100\")"


markdown-clj on clojars now works with babashka and nbb:

Jacob Rosenzweig20:11:49

Does babashka have a concept of a main function? I see alot of examples define a function and then invoke said function at the end of a script.

Jacob Rosenzweig20:11:49

I'm writing a bunch of aws-cli abstractions and they're essentially CLI scripts for me to run. Just want to know what the idiomatic way of doing that would be.


yes, it has. you can invoke any function using bb -m foo/bar or just foo -m foo if you want to include foo/-main


usually you will put those in bb.edn so you can just write bb foo


but it's also fine to just run immediately when running bb foo.clj the pattern for this is:


(when (= *file* (System/getProperty "babashka.file"))
  (apply -main *command-line-args*))

👍 1
Jacob Rosenzweig21:11:50

That worked. Another dumb question but I tried adding a dep to the deps.edn but I can't seem to import it when I run my script via bb /src/org/script.clj

Jacob Rosenzweig21:11:55

It can't find the namespace of the package

Jacob Rosenzweig21:11:40


{:paths ["src" "resources"]
 :deps {org.clojure/clojure {:mvn/version "1.10.3"} {:mvn/version "0.8.524"} {:mvn/version ""} {:mvn/version "814.2.991.0"}}
 {:build {:deps {io.github.seancorfield/build-clj
                 {:git/tag "v0.4.0" :git/sha "54e39ae"}}
          :ns-default build}
  :test {:extra-paths ["test"]
         :extra-deps {org.clojure/test.check {:mvn/version "1.1.0"}
                      {:git/tag "v0.5.0" :git/sha "48c3c67"}}}}}
And my ns import:
(ns org.s3-commands
   [ :refer [sh]]
   [ :refer [parse-opts]]
   [ :as aws]))


@U02313K7TSL For libraries you're going to use in babashka, put those in bb.edn


The cognitect aws-api library isn't compatible with babashka unfortunately. For babashka you will need to use


If you want to share all top level libraries from deps.edn in bb.edn , you can put this in bb.edn:

{:deps {current/project {:local/root "."}}}

Jacob Rosenzweig22:11:43

That's all great info. I think I'm going to give this another go when I have more time to burn. Thank you. 🙂


Emacs highlighting tip for a babashka shebang script:


Trying to use Babashka on a server at work

(require '[babashka.pods :as pods])
(pods/load-pod 'org.babashka/mssql "0.0.8")
(require '[pod.babashka.mssql :as sql])
(def db {:dbtype "mssql" :host "localhost" :dbname "widgets" :integratedSecurity true})
(sql/execute! db "select * from dbo.users")
and i get the following error
; clojure.lang.ExceptionInfo: Resource bundle not found, locale en_US. Register the resource bundle using the option
Not sure how to proceed. Any tips?


I'm not an expert on mssql, but perhaps @U08JKUHA9 can weigh in here?


We could try to add the resource bundle like the error suggests


to add some more clarity. It's a windows server 2016 box with 4GB of ram and no jdk or jre installed.


Oh I think I remember trying this and it worked on windows via WSL, but not otherwise


in your case the integrated security didn't work, right?


Otherwise, I didn't really expect JDBC to work without a lot of caveats/effort on windows, especially with integrated authentication, so I just made a pod in C# to make it work more easily for scripting:


You may be right, it was a while ago I tried the official pod


@U06GMV0B0 The SQL pod is built in this repo: I'd be happy to receive PRs but I'm not able to test properly I think the edge case you run into.

👍 1

The builds for Windows are done in appveyor.yml


If you want to share all top level libraries from deps.edn in bb.edn , you can put this in bb.edn:

{:deps {current/project {:local/root "."}}}