This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-11-17
Channels
- # aleph (4)
- # announcements (2)
- # babashka (85)
- # beginners (136)
- # calva (72)
- # clj-commons (32)
- # clj-kondo (7)
- # cljs-dev (3)
- # clojure (117)
- # clojure-europe (38)
- # clojure-nl (3)
- # clojure-norway (1)
- # clojure-uk (4)
- # clojurescript (19)
- # conjure (38)
- # core-logic (2)
- # cursive (10)
- # datalevin (1)
- # datalog (1)
- # datomic (6)
- # events (2)
- # fulcro (16)
- # google-cloud (5)
- # graphql (10)
- # gratitude (3)
- # hugsql (3)
- # luminus (5)
- # membrane-term (12)
- # missionary (2)
- # nextjournal (5)
- # off-topic (3)
- # pedestal (2)
- # polylith (7)
- # portal (3)
- # re-frame (6)
- # reagent (26)
- # reclojure (8)
- # releases (3)
- # reveal (5)
- # shadow-cljs (14)
- # spacemacs (20)
- # sql (3)
- # tools-build (3)
- # web-security (9)
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?
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?
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 10.29.136.22
[weatherapi@sensor-access01 ~]$ 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
[weatherapi@sensor-access01 ~]$ 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!
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.Are there global .cpcaches?
Works
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. https://github.com/babashka/markdown-clj I tried this in my blog and it works well. All markdown-clj tests are also passing.
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 equivalentThe London Clojurians are happy to announce: nbb: ad-hoc scripting for Clojure on Node.js (by Michiel Borkent) https://www.meetup.com/London-Clojurians/events/282138836/
many thanks to @borkdude for another great tool! 👏:skin-tone-2:
@shem Not sure. You can try to write it to a temp file first and then use (io/file ...)
Alternatively you can use java.net.http
or org.httpkit.client
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).
Thank, you. load-file works.
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.
New blog post: making markdown-clj babashka compatible. https://blog.michielborkent.nl/markdown-clj-babashka-compatible.html
Now it also works with #nbb:
$ nbb -cp src/clj:src/cljc:src/cljs -e "(require '[markdown.core :as md]) (md/md->html \"# 100\")"
"<h1>100</h1>"
markdown-clj on clojars now works with babashka and nbb: https://clojars.org/markdown-clj/versions/1.10.7
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.
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
See https://book.babashka.org/#_classpath https://book.babashka.org/#main-function and https://book.babashka.org/#tasks
but it's also fine to just run immediately when running bb foo.clj
the pattern for this is:
https://book.babashka.org/#main_file
(when (= *file* (System/getProperty "babashka.file"))
(apply -main *command-line-args*))
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
It can't find the namespace of the package
E.g.
{:paths ["src" "resources"]
:deps {org.clojure/clojure {:mvn/version "1.10.3"}
com.cognitect.aws/api {:mvn/version "0.8.524"}
com.cognitect.aws/endpoints {:mvn/version "1.1.12.110"}
com.cognitect.aws/s3 {:mvn/version "814.2.991.0"}}
:aliases
{: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"}
io.github.cognitect-labs/test-runner
{:git/tag "v0.5.0" :git/sha "48c3c67"}}}}}
And my ns import:
(ns org.s3-commands
(:require
[clojure.java.shell :refer [sh]]
[clojure.tools.cli :refer [parse-opts]]
[cognitect.aws.client.api :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 https://github.com/babashka/pod-babashka-aws
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 "."}}}
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: https://twitter.com/borkdude/status/1461060105722552321
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 com.microsoft.sqlserver.jdbc.SQLServerResource, locale en_US. Register the resource bundle using the option -H:IncludeResourceBundles=com.microsoft.sqlserver.jdbc.SQLServerResource.
Not sure how to proceed. Any tips?I'm not an expert on mssql, but perhaps @U08JKUHA9 can weigh in here?
to add some more clarity. It's a windows server 2016 box with 4GB of ram and no jdk or jre installed.
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: https://github.com/xledger/pod_sql_server
@U06GMV0B0 The SQL pod is built in this repo: https://github.com/babashka/babashka-sql-pods I'd be happy to receive PRs but I'm not able to test properly I think the edge case you run into.
@borkdude running into this issue again with the same error. I looked into the babashka-sql-pods repo to see if i could resolve it. Can this be the cause? https://github.com/babashka/babashka-sql-pods/blob/2b73a9dc448736710576d69829c11eca3c43e997/script/compile.clj#L71
@U06GMV0B0 Cool. Which OS are you on?
Can you test the pod manually by downloading it from CI to check if it works for you now?
@borkdude Tested successfully on the following! https://output.circle-artifacts.com/output/job/5348d60b-9e41-4068-bb81-a9e26c19e3d2/artifacts/0/release/pod-babashka-mssql-0.1.2-macos-amd64.zip on Apple Silicon (Mac Mini m1, 2020) https://ci.appveyor.com/api/buildjobs/2h2tvtk7yv79vtm4/artifacts/pod-babashka-mssql-0.1.2-windows-amd64.zip on (Windows Server 2019 DataCenter)
@U06GMV0B0 https://clojurians.slack.com/archives/C015AL9QYH1/p1686827297207279 Thanks for contributing