Fork me on GitHub
#clojure
<
2018-09-25
>
unwarysage03:09:13

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 tutorial

unwarysage03:09:56

However, running the jar with

java -jar (the anme of the jar) 
does nothing

unwarysage03:09:16

I have tried it now with a print outside of main, and that print goes off, but nothing in main does...

enforser03:09:45

does it work if you do "lein run"?

unwarysage03:09:25

those are the instructions I followed.

unwarysage03:09:56

Lein run hits the print in the namespace, but none of the prints in main

bbrinck03:09:10

can you share the code? In particular, the signature of -main, the namespace, and the configuration in project.clj?

bbrinck03:09:41

you’re running the standalone jar, yes?

unwarysage03:09:24

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)))))

unwarysage03:09:32

(defproject lab1
  :main lab1.core
  :aot [lab1.core])
is in project.clj

bbrinck03:09:13

looks sensible. Just checking - what happens if you put (println "Hello") as the first line in -main and recompile the uberjar?

bbrinck03:09:36

I just don’t know what the implementation of handle-recursion does - is that going to print something?

unwarysage03:09:48

Yes. It, prints a lot.

bbrinck03:09:56

Just wonder if maybe there is lazyness in that function

rsslldnphy03:09:04

As a guess, it’s maybe because your print statement is at the top level of the namespace rather than in a function?

unwarysage03:09:12

that could be a thing, one moment

bbrinck03:09:57

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.

bbrinck03:09:06

conform->confirm

unwarysage03:09:22

yep, i put a print in, before the let block, and it printed from there

bbrinck03:09:34

cool, then my guess is lazyiness. Can you wrap in a doall?

unwarysage03:09:45

doall
ing handle recursion does not change the behavior

bbrinck03:09:37

Gotcha. Can you share the source for handle-recursion?

unwarysage03:09:45

putting it in a paste so that the lab solution does not become public

unwarysage03:09:16

aside from the already given ns and main, that is the whole file

bbrinck03:09:00

looking now

unwarysage03:09:47

Also, feel free to bounce me over to #leiningen

bbrinck03:09:11

@shawx538 no, it’s fine. I think the issue is with the implementation of handle-recursion, not necessarily with lein, but just confirming now

bbrinck03:09:55

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.

bbrinck03:09:36

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

unwarysage03:09:22

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

bbrinck03:09:43

@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

bbrinck03:09:49

(untested)

bbrinck03:09:06

@shawx538 can I DM you my workaround for the printing issue?

bbrinck03:09:27

(since you mentioned keeping it hidden since it’s a lab)

unwarysage03:09:29

yes, that would be good

bbrinck03:09:52

OK, sent. Good luck!

seancorfield04:09:32

@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)

unwarysage04:09:02

I know, I admire your expectations library, and use it in my own projects. Sorry if this was in the wrong channel.

seancorfield04:09:12

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...

gleisonsilva14:09:18

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...

gleisonsilva14:09:27

for exemple, how to get the exchange object from one step to set the body over the next step

metacritical14:09:42

Why is there a seperate datatype clojure.lang.Conswhen clojure.lang.PersistentListalready exist. Is there a reason for this design decision in clojure?

jmckitrick17:09:36

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?

noisesmith17:09:07

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)

johnj18:09:15

as it should be 😉

noisesmith18:09:10

many people use lein-ring to run for convenience

mike_ananev19:09:28

Java 11 is out, but Clj still on Java 10 or lower due to https://dev.clojure.org/jira/browse/CRRBV-18 😞

ghadi19:09:59

Clojure works fine on Java 11 @mike1452 - that issue is for a library

alexmiller21:09:19

Same issue prevents gvec from building on Java 11 so core can’t build with it. But that will be fixed in next snapshot

alexmiller21:09:39

And doesn’t prevent existing Clojure from running

jaawerth19:09:48

@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

jaawerth19:09:18

though since rrb-vector IS a part of core, albeit not one that ships by default, it should probably still be updated

mike_ananev19:09:52

@ghadi thanks. I need to check deps... Oh, it seems that fipp dependency throws this exception

hiredman19:09:02

"part of core" in what sense?

ghadi19:09:45

yeah anything that pulls in RRB vector will be affected -- just need an upstream release of that library

jaawerth19:09:49

@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?

ghadi19:09:19

it's not part of "core", but a library

ghadi19:09:37

same with core.async

hiredman19:09:01

the historical definition is core is what ships with the clojure runtime (more or less, spec kind of blurs that a little)

jaawerth19:09:12

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

ghadi19:09:24

yeah either way it should get fixed stat

ghadi19:09:39

it's already fixed upstream, just needs a release cut

mike_ananev19:09:04

@bbloom Java 11 is out! Waiting for fipp update. Thanks 🙂

bbloom20:09:11

PR welcome

mike_ananev22:09:59

check my comment on github. version 0.0.12 is already released despite search can't find it on maven central.

jaawerth19:09:15

looks like that lib stagnated a bit before getting some recent love

ghadi19:09:35

I want stability from my data structure libraries, not excitement

👍 1
jaawerth23:09:13

Got me there!

jaawerth19:09:47

the funny thing is it just came up in here the other day

ghadi20:09:09

@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

👍 1
ghadi20:09:32

fipp can update at the maintainer's leisure

dpsutton21:09:02

is it possible to get meta data from a multimethod implementation?

mfikes21:09:49

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))

mfikes21:09:15

This gives {:z 2}

dpsutton21:09:12

thanks so much mike

mfikes21:09:32

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

dpsutton21:09:47

i missed that you were manually adding the method at first 🙂

mfikes21:09:33

Yeah, I cheated by using -add-method

mike_ananev21:09:01

@ghadi Is it correct artifact? quantum/org.clojure.core.rrb-vector {:mvn/version "0.0.12"}

hiredman21:09:51

any official clojure build has org.clojure as the group id

hiredman21:09:01

quantum/org.clojure.core.rrb-vector is some random person's fork

mike_ananev21:09:17

@hiredman there is no org.clojure/core.rrb-vector in repos

hiredman21:09:03

right, that person made a random fork and released their own patch version

hiredman21:09:23

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

mike_ananev21:09:32

@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!!!

sqrel21:09:31

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?

dadair23:09:19

At my company we do java -jar .. inside a docker container on Azure

noisesmith23:09:22

jsvc is good if you need things like restart and control via standard service stuff

the2bears23:09:22

We pass a jar and topology submitter class to Apache Storm.

the2bears23:09:04

^class name, the submitter's in the jar

noisesmith23:09:17

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

noisesmith23:09:11

also you can have multiple launchable -main methods in one jar (whether you use gen-class or clojure.main, either way)