This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-10-23
Channels
- # aws-lambda (1)
- # bangalore-clj (3)
- # beginners (80)
- # boot (8)
- # clojars (1)
- # clojure (200)
- # clojure-dev (37)
- # clojure-greece (26)
- # clojure-italy (11)
- # clojure-norway (3)
- # clojure-russia (14)
- # clojure-spec (21)
- # clojure-uk (30)
- # clojurescript (50)
- # core-logic (10)
- # core-matrix (1)
- # cursive (15)
- # data-science (21)
- # datomic (45)
- # devcards (2)
- # emacs (4)
- # fulcro (12)
- # garden (2)
- # jobs (5)
- # juxt (1)
- # lambdaisland (1)
- # leiningen (4)
- # luminus (20)
- # lumo (26)
- # off-topic (33)
- # onyx (27)
- # parinfer (1)
- # pedestal (3)
- # perun (5)
- # re-frame (20)
- # reagent (27)
- # ring (1)
- # ring-swagger (21)
- # shadow-cljs (259)
- # spacemacs (14)
- # yada (3)
@rcustodio I can't recall having seen that particular error, but offhand my guesses are that either 1) you don't have a gen-class
in your main ns, and/or 2) that ns doesn't have a fn named -main
, and/or 3) you've failed to declare a main class in project.clj
.
You can find info about all of those at http://www.flyingmachinestudios.com/programming/how-clojure-babies-are-made-lein-run/
(see especially the section How to Build and Run a Clojure Program Without Leiningen
)
gen-class and aot fits with service to execute -main
then, otherwise it not necessary to use gen-class
You don't need gen-class/aot. You can specify clojure.main
as your :main
and then run the uberjar with -m your.namespace
and it will run clojure.main
's -main
and then that will run your.namespace/-main
.
The other thing, i get this message
Warning: specified :main without including it in :aot.
Implicit AOT of :main will be removed in Leiningen 3.0.0.
If you only need AOT for your uberjar, consider adding :aot :all into your
:uberjar profile instead.
Ignore the warning.
(Leiningen has a very fixed view of the world; it's why I switched to Boot!)
The comments show the three changes I made (changed :main
in project.clj
, remove :aot :all
from the :uberjar
profile there, removed (:gen-class)
from ns
in quux.core
).
AOT causes a lot of problems, partly because it also compiles transitive dependencies (i.e., more than just your main namespace).
Several people will strongly advise against AOT 🙂
It's unfortunate that it became the default because that's how Leiningen's templates worked.
(and, I think, long ago, there was no -m
option to clojure.main
perhaps?)
Yes, Boot provides much more flexibility.
Boot also doesn't force you to deal with GPG like Leiningen (when you get to deploying libraries).
Boot also lets you run your newly created app directly:
(! 1221)-> boot -s src call -f quux.core/-main
Hello, World!
Boot can easily build libraries too.
I just ran this in that Leiningen project:
(! 1240)-> boot -d org.clojure/clojure -r src uber jar -m clojure.main target
Adding uberjar entries...
Writing project.jar...
Writing target dir(s)...
Sun Oct 22 17:50:22
(sean)-(jobs:0)-(~/clojure/quux)
(! 1241)-> java -jar target/project.jar -m quux.core
Hello, World!
Didn't even need to create a build.boot
file (which would just serve to provide defaults for that).
@ashnur I haven't used it myself, but it looks like it's basically just a stylesheet. You should be able to just include it in your index.html (or possibly use :npm-deps
to get it from npm).
i am trying, but nothing works. i decided to start over from scratch yet again. just need a coffee break before 🙂
Exception in thread "main" clojure.lang.ExceptionInfo: Call to clojure.core/ns did not conform to spec: In: [2] val: ((require [clojure.pprint :as pp] [clojure.string :as str] [clj-time.core :as time] [clj-time.format :as fmt])) fails at: [:args] predicate: (cat :attr-map (? map?) :clauses :clojure.core.specs.alpha/ns-clauses), Extra input ...
hey @seancorfield, what is the problem of AOT transitive dependencies, is related with time/slow to compile ? > AOT causes a lot of problems, partly because it also compiles transitive dependencies (i.e., more than just your main namespace).
( feel free if you know the answer ( asked to sean because he talked about that and I’m curious about that ^^ )
@wpcarro basically (fn [] false)
throws if you pass any args while constantly
isn't.
@U5WDMBTUJ that was my suspicion. What’s interesting to me is that ((fn [] false) 1 2 3 4)
works but (let [func (fn [] false)] (func 1 2 3 4))
does not…
Weird, it throws for me
@oliv that is a good question, @seancorfield i would like to know it too
is this supposed to be 404 http://clojure.github.io/clojure/clojure.spec-api.html ?
probably needs to be updated to this: https://clojure.github.io/clojure/branch-master/clojure.spec-api.html
i just wanted to generate the alphabet using that generator from test.check or how it is called, but it's not as easy as one might wish
@oliv @rcustodio if a dependency you use uses AOT, they override your control of all their transitive dependencies, because AOT is contagious and effects all namespaces used by the AOT compiled code. At the time the lib is compiled, (on the provider’s build machine) they decide which version of every lib you will be forced to use.
which means you can maybe use one library that does AOT - but using two is pretty much guaranteed to break things unless they take extreme measures to avoid using dependencies directly in their code
When using core.matrix
, is there a way to populate a matrix in rows when I define it using matrix
? Basically, I'm looking to make [[1] [2]]
instead of [[1 2]]
. I realise I can use (transpose [[1 2]])
for what I'm looking for, but I was wondering if it's possible to define a matrix this way to begin with?
You'll probably get an answer much faster if you post this in #core-matrix . Good luck!
hey
I am trying to use https://github.com/mzabriskie/react-draggable library in my cljs app (pretty new to web dev)
the usage instruction on cljsjs tell me to use (js/GlobalName.someFunction)
how do i figure out what the global name of the library is?
i’ve already tried (reagent/adapt-react-class js/Draggable)
@dhruv1 you might get better luck in clojurescript, but based on the Readme I would expect something like (def draggable (js/require "react-draggable"))
and then calling methods on draggable
after that
@noisesmith
i tried (def draggable (js/require "react-draggable"))
and get #object[ReferenceError ReferenceError: require is not defined]
what if you add react-draggable
to your :require
form in your ns declaration, and then use react-draggable
after that?
OK - then use cljsjs.react-draggable
since that’s what it’s currently named
you might want an :as though
something like this?
(:require [cljsjs.react-draggable :as draggable]
[reagent.core :as reagent])
that would be draggable/blah if it came in via your ns require form I believe
things with dots vs. slashes get a little messy in interop, especially on the cljs side because it’s more flexible (and thus it’s easier to form bad intuitions about how it works)
understood.
looks like my environment is messed.
trying thisL draggable/blah
i now get #object[ReferenceError ReferenceError: cljsjs is not defined]
yeah- I’d ask on #clojurescript I’m doing my best to help but not the most qualified at this point 😄
Is it ok to use *agent*
inside an agent update function to re-enqueue an update on an agent?
My agent is a Java ServerSocket
, and my update function is basically: accept a client, put it somewhere and repeat.
My two thoughts were: a) the described above; b) an infinite loop
Seems like that should be fine to me
To shutdown the server, I would enqueue a function that would close the socket
when I say enqueue, I mean send-off
What’s the most beginner-friendly way to write a desktop GUI app with clojure? Is one of the java frameworks recommended or is there a clojure library for this
is there a loop version of if-let
?
for is a list-comprehension and not a loop, sadly there is while
but that doesn't bind its condition, and there is loop
but that doesn't allow you to say "stop recurring when this binding is nil"
close is (loop [] (when-let [foo (f)] ... (recur)))