Fork me on GitHub

Is clj different from "java -jar clojure.jar"? I created deps.edn but the dependency is not picked up with "java -jar clojure.jar"?


clojure doesn't come with any dep resolution


also, newer versions of clojure need at least one other jar (for spec) so can't just run with clojure.jar

Alex Miller (Clojure team)00:07:45

they need two - spec.alpha and core.specs.alpha


ahh, I always conflate the two

Alex Miller (Clojure team)01:07:11

as outlined in the clojure readme, there is a build profile to build a local clojure uberjar (including the spec jars) that can be invoked with java -jar. we intentionally do not publish that anywhere.


so yes, clj is different from just using java on clojure.jar


When you run the java command like that, it has no reason to read your deps.edn file at all, and will ignore its contents.


The clj and clojure commands look for and read deps.edn files.


well, in an alternate implementation if deps were part of clojure.core, it could - but deps.edn is not part of clojure and it doesn't

Alex Miller (Clojure team)00:07:33

incidentally, this would require clojure to depend on 9000 maven libraries, so you should be glad it's not included :)


yeah - not saying it would be a good idea at all


I dont want to install clj on windows as that will require extra permissions I just want to copy or build and run clj?


It only requires the elevated permission for the install -- not for general running -- I have the Powershell version installed on both my Windows machines.


you could make your own uberjar with the deps you want pre-bundled


I liked the idea of editing deps.edn to add the deps so If I want to add new deps I need to do uberjar again


Is there an idiomatic way of joining two things where both can be either a collection or a single item? (Impractical approaches also welcome, as long as you point them out!)


the best thing is don't allow that kind of polymorphism, but when you can't choose (eg. comes from input following a spec you don't control) you probably want to start with a coercion function that checks for coll? and then wraps in a collection if it isn't one already


there's also seqable? but that eg. thinks "foo" is a collection of characters (hardly ever what you want)


coll? works for the built in clojure collection types, which is what you'd usually see in clojure code anyway


That's what we're currently doing, down to coll?! I was mostly hopeful there'd be a better way... thank you!


yeah - I think the fear was that if (fn [x] (if (coll? x) x [x])) was provided it might make people think code like that is a good idea (it's not, but sometimes when bad data is coming in it's the least bad option)


is there any easy wayto get clojuredocs offline?


why do you want to do that?


I thought you're referring to


@ramblurr Assuming you can run a REPL while you're offline, all the docs are available in the REPL -- because they're part of the code -- via doc, find-doc, apropos etc.


i think cursive downloads them for you and displays them with control-Q. some info here:


If you want an app that provides offline documentation, take a look at Dash -- for macOS and iOS (not sure if it is Android/Windows?) -- which I believe includes Clojure docs.


I use Zeal, a linux clone of Dash, and it looks like there are some clojuredoc docsets! Great!


hi people, I'm using the library docjure to read xlsx files, but I have some inconsistencies when reading. Sometimes the map which were to get an string with "05/02/2019" reads it as "Fri Fev 05 00:00:00 BRT 2019" for example.


I would like to pass an expected datatype to the library parse each column with a predefined type, idk if this is possible actually, the docs in the library are not clear

Alex Miller (Clojure team)05:07:15

I think xlsx data types are per-cell

Alex Miller (Clojure team)05:07:36

so my guess would be that doesn't exist

Alex Miller (Clojure team)05:07:01

unless docjure adds something over the top of that


do you have a suggestion of a better way to treat xlsx files?


I noticed values that are sometimes integer and sometines numbers as well

Alex Miller (Clojure team)05:07:42

I haven't used docjure but I've done a bunch of work against poi directly (the Java lib docjure uses) via Java interop

Alex Miller (Clojure team)05:07:15

just depends what you want and need


I was expecting to use spec to validate the data from the file, but I get a lot of false-positives and they are not consistent. For example (s/def ::field integer?) and I read a value as '2.0' one time and later '2'

Alex Miller (Clojure team)05:07:57

I suspect that's more due to the xlsx file, which often has inconsistent per-cell data types and values

Alex Miller (Clojure team)05:07:33

that is, your data is actually messy; it's not the library's fault

Alex Miller (Clojure team)05:07:13

in that case, sounds like your validation is working :)


yes, the data is in very bad state. I have a client that is sending me this through FTP and they create the xlsx via macros.. yea


I wanted to send back to them whatever they mess up really big. Like, date value inside a integer field


which have happened =(


the real problem is that the same xlsx file does not show the same inconsistent cells to me.


every time I run the code, a different cell in this file might have a problem or not. But the file is the same


sorry, the same cell in this file**


Any suggestions on this error: java.lang.ClassCastException: class clojure.lang.AFunction$1 cannot be cast to class clojure.lang.Associative (clojure.lang.AFunction$1 and clojure.lang.Associative are in unnamed module of loader 'app'? It points to the following line in my code: at ring_app.core$wrap_nocache$fn__13142.invoke(core.clj:12), which is:

(defn wrap-nocache [handler]
  (fn [request]
    (-> request
        (assoc-in [:headers "Pragma"] "no-cache"))))      ;; line 12 in source


I would guess (handler request) returns a function and assoc-in doesn't like that.


are you tring to add that header in the request? or in the response?


Trying to add Pragma: no-cache to the headers of the response map the handler returns. So, response, would be the answer. Sorry about delayed response


Nevermind. Found the error


Could someone clarify to me what these different packages do and how they interact with oneanother: figwheel-main, figwheel-sidecar and lein-figwheel?


Let me know if I should ask this in some more specific channel.


Hi FiVo! As I understand it, figwheel-main is a standalone version of lein-figwheel. The latter originated as a leiningen plugin and was later rewritten to be used in other tooling


that rewrite, it's figwheel main


ok, so I am trying to move from lein-figwheel to figwheel-main with some luminus generated project, but end up on some page that tells me to run lein figwheel. I tried to follow the instructions on for Leiningen but it doesn't work. I remove the lein-figwheel plugin and added the figwheel-main dependency.


I guess I still need to run some comment on the figwheel repl.




I'm new to clojure but not to lisps, so far I'm a big fan! Wondering what the state of development for android is at the moment. Are there good options? From what I've seen this is a tricky subject, and clojurescript + react I the way to go. It seems to me that there is a larger diversity of libraries in the JVM than through javascript. Are there good JVM based options?


Android has their own jvm-like thing, but I don't think clojure works well there because of startup time


@markgdawson I would look at cljs + react native


That's what I've heard. Shame, because the l libraries available on clojure "proper" seem (at a first glance) to be more extensive than the javascript alternatives for isoteric things. For example, I looked for a library to read emails over imap. Easy to find in clojure. Couldn't find anything in cljs.

Renan Oliveira16:07:58

Hello Guys, how to access system map of stuart components in REPL?


it's not required that it have any globally visible binding (and it's often recommended that in prod it doesn't) but you can easily give it a global binding via def during development


there's no default way to find it - you need to put it somewhere visible yourself


(there are examples in the readme)

Renan Oliveira16:07:50

OK @noisesmith I got it, Its just to learn how stay the map after start component.


the simple way to do it is with def - this is what the readme shows


(def system (example-system {:host "" :port 123}))
;;=> #'examples/system

(alter-var-root #'system component/start)
;; Starting database
;; Opening database connection
;; Starting scheduler
;; Starting ExampleComponent
;; execute-query
;;=> #examples.ExampleSystem{ ... }

(alter-var-root #'system component/stop)
;; Stopping ExampleComponent
;; Stopping scheduler
;; Stopping database
;; Closing database connection
;;=> #examples.ExampleSystem{ ... }
(quoted from that page)

Renan Oliveira02:07:30

Great @noisesmith, helped me a lot! 😃, I 'm tried adapter in my code this form.


Not surpringly I guess, as this is complied to javascript, whilst clojure can leverage any JVM language.


I'm only using deps.edn with aliases for running my things in my projects, like an interactive nrepl instance, but I find myself always doing (use 'clojure.repl) in my nrepl to be able to do things like (doc). Is there a better way? How does lein repl automate that for example?



(apply require clojure.main/repl-requires)
gives you all the things clojure itself would put in your initial ns (clojure.repl, clojure.pprint, javadoc)


also it's "future proof" as it gives you the right bindings for any future enhanced clojure


lein repl relies on the "reply" lib to do ns initialization iirc, I wouldn't use lein's code as an example for elegant ways to do things generally - it's a big complex project with a lot of contributors that are relatively new to the project, its features work but it's not a tidy codebase


(eg. there's a lot of blatant copy/paste code)


Wow nice! So if I start nrepl with -e "(apply require clojure.main/repl-requires)" it'll have all that?


nrepl itself should be giving all of that to you in your first ns - unless your first ns fails to load properly


oh - I see, you start nrepl programatically and it isn't neccessarily giving your user the same ns that was initial to the program itself


No I start it with clj -m nrepl.cmdline, and it starts in a user namespace


right, user is the default if you don't make it start up with any other ns, and has all the things in repl-requires (clojure itself makes sure of this)


you can also tell nrepl to start with a different ns (and then you get that same initialization for free in that ns)


but that's fragile because if the code for that ns breaks you can have a broken repl sometimes


Yes makes sense. Don't know why it doesn't start with repl-requires loaded already then


it does - but only in the initial ns


not to every ns


Ok, thanks a lot @noisesmith I'll investigate all that


I think adding -i some.ns for your ns to the command line does everything you want


What would be some.ns ?


your namespace


Shouldn't I be fine with the user one ?


that's up to you - as I said clojure itself makes sure that user has clojure.repl etc.


maybe I don't understand your problem (or you changed your mind about how to fix it)


So I think something silently goes wrong because when starting in the user namespace, I need to manually use clojure.repl from the interactive repl session to be able to type (doc map) for example


that's weird - that could be a bug in that nrepl lib


so yeah, maybe you do want to add that apply require to your startup


Thanks, I'll try and figure out what's best with your precisions in mind


@noisesmith it it is of any interest to you this is how I can reproduce it clj -Sdeps '{:deps {nrepl {:mvn/version "0.6.0"}}}' -m nrepl.cmdline --interactive

👀 4


justin.smith@C02RW05WFVH6: /tmp/foo$ clj -Sdeps '{:deps {nrepl {:mvn/version "0.6.0"}}}' -m nrepl.cmdline --interactive
nREPL server started on port 60807 on host localhost - 
nREPL 0.6.0
Clojure 1.10.0
Java HotSpot(TM) 64-Bit Server VM 1.8.0_171-b11
Interrupt: Control+C
Exit:      Control+D or (exit) or (quit)
(ins)user=> ('doc (ns-refers *ns*))
(ins)user=> ('pprint (ns-refers *ns*))
(ins)user=> (apply require clojure.main/repl-requires)
(cmd)user=> ('doc (ns-refers *ns*))
(cmd)user=> ('pprint (ns-refers *ns*))


I believe it should behave the same for you


Oh you aren't using the lambdaisland lib, you are just using nrepl, ok


yes, I noticed lein repl runs REPL-y rather than the default nrepl client


and nrepl doc suggests to do so


which I presume must insert the interesting stuff in the user namespace


and this indeed seems to do the trick clj -Sdeps '{:deps {reply {:mvn/version "0.4.3"} nrepl {:mvn/version "0.6.0"}}}' -m reply.main


I guess I'll use repl-y as well in my projects now


Would anyone be willing to work with me a little while until I get the gist of some things?

Danny Almeida23:07:22

Hello Everyone!!

Danny Almeida23:07:37

need help with running repl from emacs using cider ...when I use cider-jack-in i get an error ..but when i type the exact command on the command works fine

Danny Almeida23:07:57

error in process sentinel: nrepl-server-sentinel: Could not start nREPL server: Error building classpath. Don't know how to create ISeq from: clojure.lang.Symbol