This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-09-25
Channels
- # 100-days-of-code (3)
- # beginners (80)
- # cider (53)
- # cljdoc (9)
- # cljs-dev (66)
- # cljsrn (6)
- # clojure (108)
- # clojure-austin (5)
- # clojure-dusseldorf (1)
- # clojure-italy (9)
- # clojure-losangeles (2)
- # clojure-nl (4)
- # clojure-spec (40)
- # clojure-uk (46)
- # clojurescript (60)
- # cursive (119)
- # datomic (28)
- # emacs (10)
- # events (1)
- # figwheel-main (21)
- # fulcro (16)
- # hyperfiddle (10)
- # immutant (2)
- # leiningen (1)
- # liberator (5)
- # nyc (1)
- # off-topic (36)
- # onyx (4)
- # pedestal (52)
- # portkey (5)
- # re-frame (11)
- # reagent (11)
- # shadow-cljs (46)
- # sql (1)
- # unrepl (2)
Okay, I have a clojure project, I have run
lein uberjar
on it, and I have put gen-class on the name space, marked main in project.clj and also marked it as AOT, as per the leiningen tutorialI have tried it now with a print outside of main, and that print goes off, but nothing in main does...
Hm, the instructions here worked for me on a new project - https://github.com/technomancy/leiningen/blob/master/doc/TUTORIAL.md#uberjar
can you share the code? In particular, the signature of -main
, the namespace, and the configuration in project.clj?
This is for a class project, so it's really simple. Hence frustrating when it does not work
(ns lab1.core
(:gen-class))
---code here---
(println "Hello")
(defn -main [& args]
(let [n (inc (Integer/parseInt (first args)))]
(handle-recursion [] (vec (range 1 n)))))
looks sensible. Just checking - what happens if you put (println "Hello")
as the first line in -main
and recompile the uberjar?
I just don’t know what the implementation of handle-recursion
does - is that going to print something?
As a guess, it’s maybe because your print statement is at the top level of the namespace rather than in a function?
Just wondering if you put a basic println
inside the -main
, that would help conform if the issue is with the -main
or with the handle-recursion
function.
Thank you both, @bbrinck and @rsslldnphy
@shawx538 no, it’s fine. I think the issue is with the implementation of handle-recursion
, not necessarily with lein
, but just confirming now
Basically, it looks to me like handle-recursion
is using lazy sequences but also trying to do effects (namely println
). I’m not immediately seeing why doall
isn’t helping here - probably I’m missing something.
Nonetheless, I think a good solution would be to make handle-recursion
just return the results as data, then print them out in -main
. I’ll see if I can come up with an example
I'll hammer at it too. That is more functional, we just also did not want to have handle-recursion ever have to hold the full return in memory
@shawx538 Hm, I wonder if lazy-seq might be a good fit here if you want to avoid having everything in memory https://clojuredocs.org/clojure.core/lazy-seq
@shawx538 Since you're brand new to Clojure, you will find #beginners to be a good place to ask questions. Folks there have opted in to helping beginners with these sorts of questions. Folks are very patient and helpful in that channel. (I'm one of the moderators her, BTW)
I know, I admire your expectations library, and use it in my own projects. Sorry if this was in the wrong channel.
Thanks 🙂 Re: the channel -- not wrong, and out of "mainstream" office hours it's fine, just trying to set expectations for where you'll get the best help for that sort of question...
hello! anyone have some examples of using clj-camel
library? i'm facing some issues to understand how to make use of things like getting/setting values to pass along the pipeline...
for exemple, how to get the exchange object from one step to set the body over the next step
Why is there a seperate datatype clojure.lang.Cons
when clojure.lang.PersistentList
already exist. Is there a reason for this design decision in clojure?
A very nice explanation for the above https://gist.github.com/finalfantasia/b20a2a2d3a3ac445e456fbbf2db38cae
I’m doing a presentation for a Clojure meetup, and I’d like to demo CLI deps. However, most of my work has been based on leiningen and Luminus (for web apps). Would it be simple to spin up a REST backend using CLI deps only, that would be suitable for a demo?
it should be reasonable as long as you can spin up your webserver without using a lein plugin (just invoking a -main that starts the server)
many people use lein-ring to run for convenience
Java 11 is out, but Clj still on Java 10 or lower due to https://dev.clojure.org/jira/browse/CRRBV-18 😞
Same issue prevents gvec from building on Java 11 so core can’t build with it. But that will be fixed in next snapshot
And doesn’t prevent existing Clojure from running
@mike1452 I actually just looked into this the other day, because rrb-vector
was available from my repl despite it not being a part of core that ships with clojure by default. turns out it's a dependency of fipp, which in turn is a dependency of cider-nrepl
though since rrb-vector
IS a part of core, albeit not one that ships by default, it should probably still be updated
@ghadi thanks. I need to check deps... Oh, it seems that fipp dependency throws this exception
yeah anything that pulls in RRB vector will be affected -- just need an upstream release of that library
@hiredman as in it's on the clojure.core namespace and maintained under https://github.com/clojure/core.rrb-vector , so I dunno if you only count things if they're shipping with clojure, but I'd say it counts the same way core.async does, no?
the historical definition is core is what ships with the clojure runtime (more or less, spec kind of blurs that a little)
fair enough! seems like you could describe it either way without technically being wrong but I do see the importance of the distinction for obvious reasons
@bbloom Java 11 is out! Waiting for fipp update. Thanks 🙂
check my comment on github. version 0.0.12 is already released despite search can't find it on maven central.
@jesse.wertheim @mike1452 Michal just cut a release for core.rrb-vector 0.0.12 - if you put that in your top level dependencies, it should get you going on JDK 11
It seems you can hack it in ClojureScript. Not by a Clojure REPL now.
(defmulti my-multi :x)
(-add-method my-multi :a (with-meta (fn []) {:z 2}))
(meta (get-method my-multi :a))
If you look at defmethod
(in ClojureScript) you can see it doesn’t pass in any meta you might try to specify on the method
@ghadi Is it correct artifact? quantum/org.clojure.core.rrb-vector {:mvn/version "0.0.12"}
@hiredman there is no org.clojure/core.rrb-vector in repos
ver 0.0.12
the new 0.0.12 version of the official release was just pushed to sonatype's oss repo, and I dunno what the lag might be between the push and becoming available
https://search.maven.org/artifact/org.clojure/core.rrb-vector/0.0.11/jar (no 0.0.12 there yet)
@hiredman Ha! Search still shows 0.0.11. But I put org.clojure/core.rrb-vector 0.0.12 in deps.edn and ta-da...downloaded. Yeah, now my project works under Java 11. Thanks!!!
Hi guys. I searched through the slack but couldn’t find anything. How do you guys deploy your apps? A little background - I’m from non-java world. Tried to dig into it, failed. I figured out there are plenty of options - bare metal (deploy jar), docker, tomcat, wildfly - how do you deploy your apps?
jsvc is good if you need things like restart and control via standard service stuff
one useful trick is that often instead of using gen-class you can submit clojure.main as your main, and ask it to find and run your ns -main
also you can have multiple launchable -main methods in one jar (whether you use gen-class or clojure.main, either way)