This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-04-14
Channels
- # aleph (2)
- # announcements (11)
- # aws (4)
- # babashka (42)
- # babashka-sci-dev (81)
- # beginners (90)
- # biff (2)
- # calva (40)
- # cider (16)
- # clj-kondo (26)
- # clj-on-windows (1)
- # cljdoc (4)
- # cljfx (1)
- # cljsrn (2)
- # clojure (92)
- # clojure-austin (2)
- # clojure-europe (23)
- # clojure-nl (5)
- # clojure-uk (3)
- # clojured (3)
- # clojurescript (19)
- # community-development (3)
- # conjure (1)
- # cursive (4)
- # datalevin (3)
- # datomic (5)
- # emacs (13)
- # events (1)
- # fulcro (26)
- # graphql (1)
- # hugsql (15)
- # introduce-yourself (5)
- # leiningen (1)
- # lsp (29)
- # minecraft (19)
- # music (1)
- # off-topic (36)
- # pathom (12)
- # podcasts (2)
- # portal (8)
- # re-frame (12)
- # reagent (11)
- # rewrite-clj (4)
- # shadow-cljs (56)
- # spacemacs (2)
- # vim (12)
- # windows (3)
- # xtdb (43)
GM. I'm trying to build an Uberjar for my project and it's coming out to 1GB. It's a pretty small project so I figure this size is coming from somewhere in the dependencies. How would I go about figuring out where its coming from?
I guess it’s a jar file in the end so you can unzip it and take a look whats inside.
Oh thanks, is a JAR a zip under the hood?
yes, jars are just zips. If you rename it from foo.jar to foo.zip, you can just unzip it to see what's inside
Yes, JAR file is just an ordinary zip file.
Not 100% sure about uberjar thought, haven’t tested it.
If you're trying to find out which dependencies are contributing the most to your uberjar, I wrote small lib to help called https://github.com/phronmophobic/snowball
Leiningen @U2FRKM4TW
@U4ZDX466T I saw that command yesterday but I don't have jar
installed and can't find it in my OS package manager.
I guess it comes with JDK installation.
oh, snowball doesn't work with lein projects directly
Try using lein deps :tree
then. I don't think it will report the size of the dependencies, but it'll at least show why things are in the uberjar.
Ah OK, I'll reinstall openjdk, mine is probably ancient.
Thanks @U2FRKM4TW.
There's also lein deps :why some/coord
where some/coord
is group/artifact-id of a specific jar - it'll tell you why specifically that jar was included.
And if you're still discovering things, I would recommend checking out tools.deps as well - i.e. Clojure CLI along with a deps.edn
file instead of project.clj
. It's overall simpler and more flexible, and for this particular task, you'll be able to use https://github.com/phronmophobic/snowball and https://github.com/clojure/tools.deps.graph with its size
option.
Thanks, I've been meaning to check out tools.deps as everyone seems to be moving to it these days.
There is a workaround for using snowball with lein, https://github.com/phronmophobic/snowball#usage-with-lein-projects
@U03BA00LJ9L To be the naysayer, I haven’t noticed that 🙂 Of course here on Clojurians and the libraries closer to the core ecosystem are moving to those tools, but a few steps further away everyone still seems to prefer Leiningen, mostly because as a tool it is “a solved problem”. Optics, perspective, positive reinforcement, statistics…things like this can get complicated quite quickly.
that seems crazy
That's what I thought!
My suspect is clojure2d because I found something else mentioning it making huge JARs.
any recommendation for a s3 library thats works for aws gcp and do kind of want something for just storage instead of pulling in an entire suite of libs like the aws library
Would https://github.com/cognitect-labs/aws-api work in this case?
well I am aware of that but would i not be bringing in api's for all the aws services instead of just s3
although
{:deps {com.cognitect.aws/api {:mvn/version "0.8.539"}
com.cognitect.aws/endpoints {:mvn/version "1.1.12.192"}
com.cognitect.aws/s3 {:mvn/version "822.2.1109.0"}}}
make's me think perhaps not I wonder how well it works with GCP and doYep, it's modular and rather small. But no clue about your specific needs - personally, I use it only for S3.
my need is basically to use storage but work for any platform instead of tying the library to a specific cloud provider
If conceptually S3 serves you, I'd definitely go with it - quite a few other providers have picked it up.
yeah it may be fine I will have to test, looking around not finding any uptodate alternatives anyway
seems this does not work overly well outside amazon ecosystem https://github.com/cognitect-labs/aws-api/issues/150
I guess there's really no "official" documentation for user.clj
? The only page I can find is this https://clojure.org/guides/dev_startup_time, which is useful, but only touches on user.clj
rather briefly.
There's a deps and cli guide in the same place
Oh sorry, misread
I don't know if there is any user.clj “guide”
It's kind of a weird historical artifact. The Clojure runtime loads user early in startup, if it exists
Yes, I'm familiar with how it works. I'm just looking for something to link to in a blog post that (also) discusses user.clj
, really. 🙂
Don't think I have anything you can point to
it is literally unmentioned in the reference section, I'll add a doc issue for that
What’s the proper way of converting a namespaced keyword to its qualified name string
:a/b => a/b
Given a function foo
that returns a new val. If the val is not nil, return the val, other wise return default.
(let [val (foo)]
(if (some? val)
val
default-value)
Possible to avoid the temporary val variable?maybe with or? (or (foo) default-value)
?
Is there a good way to create a Clojure sequence that implements the java.lang.Iterable
interface? Using clojure.reflect/reflect
on things like [], ’() shows that many of these sequences have an iterator member but they don’t have other things like a forEach method required by the java.lang.Iterable
interface.
The context here is that I’m writing mocking code for a java library that returns an Iterable from one of its methods.
forEach is a default method provided by the interface so you don't need that
Oh, I see. So then is it safe to say that things like clojure.lang.PersistentVector
implement Iterable since they have the iterator member?
you just have an Iterable from some other source, not a type you're making yourself?
I’m writing a wrapper around some google Firestore code that returns a Iterable of documents in one of its functions. That part is straightforward; I’m also writing a mocked-up version that uses an atom for unit-testing code that interacts with the database.
iterator-seq
is a tool for making a seq that wraps an iterator, but I think you want the reverse?
Exactly. I need to grab a node out of the mock db-atom and make it into something that implements Iterable.
But if clojure.lang.PersistentList
implements Iterable (like it sounds like it does) then I can just return (get-in @db-atom path)
.
most seqs are Iterable so you're probably set in most cases just returning one
Thanks 🙂
No clue which slack channel would be better for the following apart from this one: I'd love to get the new-ish github feature where you can directly click on symbols to get jump to Definition/References when viewing code. I know it involves the github libraries Tree-Sitter and CodeStacks (or something like that, not at computer rn). Would anyone be interested in exploring contributing clojure to the set of supported languages? No idea how herculean it might be tho tbh
I feel like it's been mentioned and someone is working on it? Maybe hit the search here
I imagine you'd need to get clojure as an official language in tree-sitter first?
afaik this is the most popular tree-sitter clojure attempt https://github.com/sogaiu/tree-sitter-clojure
apparently the scope is a problem due to supporting "higher level constructs" https://github.com/sogaiu/tree-sitter-clojure/blob/master/doc/scope.md
and of course Michiel has experimented with it https://github.com/borkdude/analyze-reify
Not surprised that he has hahah! I'll take a look around here and in those repos. Cant wait to spread myself thin with how much opportunity there is in the clojure DX effort !
oh wait there's #tree-sitter! It's not exactly pertaining to using it for GH DX, but prob a first order requirement to get to that anyways
I feel the issues they mention might not matter that much for just jumping around inside GitHub.
I think if you're talking about defs it probably will? I mean jumping around is usually "jump to definition" and "jump to references" and so supporting defs is required, I'd think?
Dumb, jokey, trivial question—does anyone know why java.lang.AutoCloseable doesn’t seem to be resolvable without a namespace (unlike the other java.lang interfaces and classes)?
$ clojure -M -e "(println Cloneable) (println Iterable) (println Runnable) (println java.lang.AutoCloseable) (println AutoCloseable)"
java.lang.Cloneable
java.lang.Iterable
java.lang.Runnable
java.lang.AutoCloseable
Syntax error compiling at (REPL:1:93).
Unable to resolve symbol: AutoCloseable in this context
Oh, it may just be anything newer than 1.6
Forgot these were brought in with that big map in clojure.lang.RT
Yeah, it's just missing. We have a patch for this, keep forgetting to get it in a release
What is the best way to unit test a ring response that returns a stream?
Ah, nice! I see that in the notes now. I’ll give that a shot!
Hmm, no good. The slurp
just returns a text-based rendering of the stream object: #object[java.io.PipedInputStream 0x37ca9a1c “
slurp should call http://clojure.java.io/reader https://clojuredocs.org/clojure.java.io/reader
I agree, it makes sense on paper. But I’m getting empty string content with no reflection warnings or exceptions, etc.
oh so with a PipedInputStream there is another thread dumping contents - maybe its a race condition?
Hmm. Not sure how to address that one. It’s a unit test, so even if the app spins off a thread, the response should still be on the original thread. At least that makes sense to me. If it’s not, I’m not sure what to try next.
So I found out I cannot slurp
the stream from the response
body returned during the unit test, but I can slurp
from the stream itself if I break the ring-io/piped-input-stream
call out into a separate function and return that in the unit test.