This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-08-06
Channels
- # babashka (101)
- # beginners (47)
- # biff (7)
- # calva (36)
- # clj-kondo (19)
- # clojure (11)
- # clojure-europe (1)
- # clojurescript (4)
- # conjure (4)
- # core-typed (3)
- # cursive (24)
- # emacs (22)
- # events (4)
- # gratitude (1)
- # introduce-yourself (1)
- # malli (27)
- # meander (5)
- # off-topic (101)
- # portal (5)
- # shadow-cljs (26)
- # tools-build (4)
- # tools-deps (3)
- # vim (8)
- # xtdb (13)
I'm having an issue with Babashka pods on ARM (I think). I'm using {org.babashka/aws {:version "0.1.2"}}
in an arm64 lambda, and when I try to create a client with (aws/client {:api :s3, :region region})
, I get a stream closed exception with a stacktrace like this: https://gist.github.com/jmglov/4d79f2c9a50e3580b36663c21eaddf5c
My assumption is that the pod is built for amd64 and not arm64, but I don't really know how to resolve this.
In the meantime, I'll try to verify the assumption by seeing if everything works on amd64.
@U054AT6KT Could you paste the long stack trace in a gist instead of in the channel?
There is one release for linux aarch64: https://github.com/babashka/pod-babashka-aws/releases
But if you upload the one you downloaded on your own computer, it might not match that architecture
There is an issue here with some ideas for improvement: https://github.com/babashka/babashka/issues/1316
Makes sense. I did confirm that it worked on amd64, so it is an arch issue. I think I'll switch to awyeah-api so I can make blambda work with deps. š
Does Babashka use the standard tools.deps stuff for handling deps.edn
, or does it use the ported library? I want to set the local Maven cache to something other than ~/.m2/repository
, and I can't figure out how to do that. Setting the M2_HOME
env var has no effect (though I'm not sure that's how Maven finds the cache anyway).
it does use the standard tools deps stuff for bb.edn
- the only thing that has been ported is the bash script which was converted to clojure and is part of bb
I vaguely remember that there's some environment variable that one can set to tell clojure
to look for the local cache, but I can't craft the right search to find it.
:mvn/local-repo
In the deps.edn, not an env var
clojure has -Sdeps
to merge options, but bb doesn't have this yet. What you can however do is create another bb2.edn
and then refer to that with --config
For posterity, I found :mvn/local-repo
documented here: https://clojure.org/reference/deps_and_cli
yes, the "reference" usually has all the stuff documented, where "guide" is usually a gentle introduction which covers a lot but doesn't cover all of the options
It took me a few levels of searches before I realised that "maven cache" is the magic term. š
I think the easiest way out for me is probably to use :mvn/local-repo
in deps.edn
. Thanks both of you for the help! š
Hrm, setting :mvn/local-repo "/tmp/deps-mvn-repo"
in my deps.edn
and running bb help
still seems to use ~/.m2/repository
.
or unless you write something like {:deps {current/deps.edn {:local/root "."}}}
in bb.edn
Here's my bb.edn
:
{:paths ["."]
:deps {local/deps {:local/root "."}}}
and deps.edn
{:deps {com.cognitect.aws/endpoints {:mvn/version "1.1.12.206"}
com.cognitect.aws/s3 {:mvn/version "822.2.1109.0"}
com.grzm/awyeah-api {:git/url ""
:git/sha "0fa7dd51f801dba615e317651efda8c597465af6"}}
:mvn/local-repo "/tmp/deps-mvn-repo"}
yeah, hmm, this ain't gonna work I realize, I think because the :mvn/local-repo isn't inherited from external deps
you could keep the deps local/root thing to refer to deps.edn, but the mvn/local-repo isn't inherited from other files
Added a comment here: https://github.com/babashka/babashka/issues/808
Whoa, more weirdness! With a bb.edn
like this:
{:paths ["."]
:deps {com.cognitect.aws/endpoints {:mvn/version "1.1.12.206"}
com.cognitect.aws/s3 {:mvn/version "822.2.1109.0"}
com.grzm/awyeah-api {:git/url ""
:git/sha "0fa7dd51f801dba615e317651efda8c597465af6"}}
:mvn/local-repo "/tmp/deps-mvn-repo"}
I ran bb help
and saw this, as expected:
Downloading: com/cognitect/aws/s3/822.2.1109.0/s3-822.2.1109.0.pom from central
Downloading: org/clojure/clojure/1.11.1/clojure-1.11.1.pom from central
Downloading: com/cognitect/aws/endpoints/1.1.12.206/endpoints-1.1.12.206.pom from central
Downloading: org/clojure/core.specs.alpha/0.2.62/core.specs.alpha-0.2.62.pom from central
Downloading: org/clojure/pom.contrib/1.1.0/pom.contrib-1.1.0.pom from central
Downloading: org/clojure/spec.alpha/0.3.218/spec.alpha-0.3.218.pom from central
Downloading: com/cognitect/aws/s3/822.2.1109.0/s3-822.2.1109.0.jar from central
Downloading: org/clojure/clojure/1.11.1/clojure-1.11.1.jar from central
Downloading: com/cognitect/aws/endpoints/1.1.12.206/endpoints-1.1.12.206.jar from central
Downloading: org/clojure/spec.alpha/0.3.218/spec.alpha-0.3.218.jar from central
Downloading: org/clojure/core.specs.alpha/0.2.62/core.specs.alpha-0.2.62.jar from central
When I removed /tmp/deps-mvn-repo
and ran bb help
again, it didn't re-download the deps. Any idea why?That worked. Oddly enough bb help --force
didn't download the deps, but bb tasks --force
did. :man-shrugging::skin-tone-2:
That may be because bb help
just prints the help and doesn't process any other flags
[jmglov@laurana:~/Documents/code/clojure/s3-log-parser/src]$ bb --force tasks
Downloading: com/cognitect/aws/s3/822.2.1109.0/s3-822.2.1109.0.pom from central
Downloading: com/cognitect/aws/endpoints/1.1.12.206/endpoints-1.1.12.206.pom from central
Downloading: org/clojure/clojure/1.11.1/clojure-1.11.1.pom from central
Downloading: org/clojure/core.specs.alpha/0.2.62/core.specs.alpha-0.2.62.pom from central
Downloading: org/clojure/pom.contrib/1.1.0/pom.contrib-1.1.0.pom from central
Downloading: org/clojure/spec.alpha/0.3.218/spec.alpha-0.3.218.pom from central
Downloading: org/clojure/clojure/1.11.1/clojure-1.11.1.jar from central
Downloading: com/cognitect/aws/endpoints/1.1.12.206/endpoints-1.1.12.206.jar from central
Downloading: com/cognitect/aws/s3/822.2.1109.0/s3-822.2.1109.0.jar from central
Downloading: org/clojure/spec.alpha/0.3.218/spec.alpha-0.3.218.jar from central
Downloading: org/clojure/core.specs.alpha/0.2.62/core.specs.alpha-0.2.62.jar from central
----- Error --------------------------------------------------------------------
Type: java.lang.Exception
Message: File does not exist: tasks
I meant, we should migrate the CLI handling of bb to the bb.cli library - it's all manual right now
OK, so I thought a little more about what I want to do. Here's the situation:
⢠I have a bb app (project? dunno what to call it) that will run as a AWS Lambda. It has its deps specified in lambda/bb.edn
⢠I have another bb.edn
which is used for provisioning the lambda and associated layers; let's call it infra/bb.edn
⢠infra/bb.edn
should have a deploy-deps-layer
task that reads lambda/bb.edn
, uses the Clojure CLI to download JARs from Maven and/or Git into a scratch directory (`/tmp/lambda-deps`, for example), then zips that directory up and creates a layer for it.
So I need to set both :mvn/local-repo
and the GITLIBS
environment variable. My current thinking is that I have a task in infra/bb.edn
that reads lambda/bb.edn
, writes a /tmp/lambda-deps.edn
, then invokes clojure
to do the deps downloads.
Does this make sense? If so, what clojure
command would I run from Babashka to make this work?
Btw, I think #holy-lambda has figured all of this stuff out already for bb on AWS ;)
Fyi, you can also set gitlibs via Java system property clojure.gitlibs.dir
Although I guess you can't set that in the jvm that would matter so nvm
Holy Lambda is awesome, but: a) it uses Docker, which I don't wanna, and b) it lets me get away with not understanding how all this stuff works. š
no, it executes deps.clj's main function: https://github.com/borkdude/deps.clj
If I want to use deps from a bb task, would you recommend doing the same? Does bb provide any helper functions for this?
Haha, I'm about to link a gist that will make you lose your lunch. Do not look directly at this gist!
@U054AT6KT You can use (with-out-str (babashka.deps/clojure ["-Spath" "-Sdeps" ...]))
as well, if you like. babashka.deps/clojure is basically the same as invoking deps.clj's main function
So the next arg after -Sdeps
is the literal EDN string, right? So then I don't have to spit deps.edn
to the work-dir.
@U054AT6KT FWIW i've had luck using clojure.tools.build/uber
, passing it :exclude ["^clojure[/].+"]
to make zips(uberjars) to deploy babashka projects to lambda (I also had an aversion to using docker for this)
@U064UGEUQ babashka supports bb uberjar
for this as well
yup I have a version using that too š Currently using the build tool one because it's more similar to the non-bb deploy code and avoids shelling out
I also have the requirement to be able to edit the code in the AWS Console, so I want to deploy the deps as a layer but not include the lambda sources. Maybe this can be accomplished with an uberjar, but it would require removing paths from the bb.edn
or deps.edn
as far as I can tell.
For my use case, Iād need to preprocess bb.edn
to remove the lambda sources, though. Or maybe you weren't replying to me?
I made a channel for those who are enthusiastic about making CLI tools in Clojure over at #cli-makers if anyone's interested.
Btw, ffz comes to mind as well. Some people use it in combination with #babashka-neil
sorry, fzf was the name: https://github.com/babashka/neil/issues/16
TUI is difficult in Java-ish environments. Better luck with #nbb probably: See https://github.com/babashka/nbb#reagent
@lilactown What's also exciting to try (but more experimental) is bun with FFI. E.g. here it uses blipgloss which is a bun library which wraps lipgloss, a go library, and calls it via FFI: https://github.com/babashka/nbb/blob/main/examples/bun/blipgloss.cljs I've also got an ncurses example here: https://github.com/babashka/nbb/blob/main/examples/bun/ffi.cljs Again, note, experimental (because bun) ;-)