Fork me on GitHub
Godwin Ko00:08:30

I’m using ns-unmap for easier code reload of defmulti/defmethod within REPL, but it caused exception when invoking uberjar standalone jar, any way I can detect if current environment is dev or not in order to skip those ns-unmap?


Use (def multimethod nil) instead

Godwin Ko01:08:30

@hiredman thx for your advise, although it works as if ns-unmap, packaging with uberjar still throw exception, I guess aot compilation don’t allow variable re-binding…


Don't use ns-unmap at all


Replace it with def the multimethod var to nil first

Godwin Ko01:08:20

ok got it, but yet to find a way to prevent standalone jar exception

Godwin Ko01:08:38

it turns out simply define the dispatch function separately did solve my issue!! 🎉


I would not be super surprised if you had some lurking namespaces issue with your project


Maybe not (trying to remember where and in what order the bytecode to look up vars is emitted)


Hey, I have a date format as "2017-02-14T12:00:00.000+4:00", I need it to convert so that it is in format YYYY-MM-DD, so basically get rid of time and timezone stuff. I used clj-time.coerce/from-string to convert it from String to DateTime Instant.


So how can I extract the year-month-date from this, so I need 2017-02-14 as output


I know how to do it using regex or partly use regex and partly date


but I want to know how to achieve this using the date format entirely

Alex Miller (Clojure team)06:08:34

check out the java.time.format package in the JDK

Alex Miller (Clojure team)06:08:37

user=> (def d (java.time.LocalDateTime/now))
user=> d
#object[java.time.LocalDateTime 0x643ba1ed "2019-08-14T01:23:05.972628"]
user=> (.format d (java.time.format.DateTimeFormatter/ofPattern "yyyy-MM-dd"))


So, how to put LocalDateTime format for this : “2019-07-13T14:00:00.000+10:00”


How to convert this to localDateTiem

Alex Miller (Clojure team)06:08:48

what type are you starting with? what type do you want at the end?


so I am starting with this input - “2019-07-13T14:00:00.000+10:00” output- “2019-07-13"


So, need to convert input to locadateTime first

Alex Miller (Clojure team)07:08:33

so would be best to first parse from string to LocalDateTime, using a DateTimeFormatter (once you create a formatter, it can be used to either parse or format)

Alex Miller (Clojure team)07:08:44

then use a different formatter to format back to a string

Alex Miller (Clojure team)07:08:32

just be careful that you understand what you're doing with the timezone offset


I am using the joda time thing , it’s kind of a standard


here in my organisation, should have specified that

Alex Miller (Clojure team)07:08:26

the same developers that created joda developed the java.time packages which are now part of java

Alex Miller (Clojure team)07:08:46

java.time and joda are similar as they were created by the same people

Alex Miller (Clojure team)07:08:06

same formatter stuff exists


Okay, will have a look. I always had troubles with dates

Brandon Olivier09:08:59

If I’m in namespace app.db.core and I want to use a spec from app.db.entity is there a way to do that that doesn’t involve writing :app.db.entity/foo-spec every time I need to reference it?


You can do (require '[app.db.entity :as e]) and then it'd be just ::e/foo-spec

thanks3 4
ivan minutillo10:08:18

Hi! im stucked trying to use a local library in my clojure project. I created a checkouts folder at the source directory, and symlinked the local lib, but when i run lein ring server, it seems it totally ignores what's in the checkouts...


I've never used checkouts, but running lein do pom, jar, install in your local library directory, then starting your project that depends on it (making sure it's listed as a dependency with the same version number), has always worked for me.


@brandon149 you can also try (:require [app.db.entity :refer [::foo-spec]). I know it works with fn syms, I havent tried it with spec syms, but there is no reason it shouldnt work. You can also do refer-all to alias all the syms from that ns into the current ns.

Brandon Olivier11:08:47

@murtaza52 I tried out some stuff in the repl and it looks like doing a regular ns require will let you do :alias/foo


yes that should work too, and is actually the better option in your case. I did not mention id bcoz @vale had already mentioned it.


Is there a major blog post that people refer to for setting up their Clojure dev environment?

herald15:08:27 is good for getting things installed. after that, you have to search for guides on the build tool you're going for (ie. is good for tools.deps)


if you already use emacs or have been wanting to learn, then check out CIDER. emacs is a lot to learn and rewarding (i think) but has a long learning curve. Cursive is an excellent option and these two dominate the marketshare if i'm remembering the clojure survey results correctly. Outside of this there's Calva for VS code which reuses a lot of CIDER's underlying tooling and Chlorine for Atom. There's a really nice video from @seancorfield using Atom to fix a bug in a lib that is a nice showcase of its benefits and workflow. But once you choose from this list then just follow along with the docs/blogs about that tooling

calva 4

FYI, Clojure survey 2019 results for dev environment can be found at "Q12" here:


Error messages are important to a lot of people!


Didn’t realize, I guess after a while you get so used to them


I think anything unfamiliar, that at first seems confusing and/or you believe was done better in previous dev environments you worked in, you notice and wish for what you used to have 🙂


I agree/disagree with this, and I have a specific why!


tools.deps brought me back into the clojure fold because it drastically changes the Clojure environment imo and isn't talked about enough.

👏 4

which may sound silly


I wouldn't call it silly, but if you feel that strongly about tools.deps bringing you back, have you considered writing an article about it?


(maybe you have, and I didn't notice -- sorry if so)


I haven't!


if that'd be helpful, I'll throw it into my list. 😄


To me, the Clojure environment before tools.deps was so unfamiliar I couldn't justify the time investment with a whole cambrian explosion of many things going on and me having many interests through all of that.


tools.deps just made sense. I can write a deps.edn file {:deps {}} and get rocking.


did I spend some time coming up to speed with lein and project.clj? sure. but the ecosystem to date just has a lot of "this is how I solved it as someone experienced" and a lot less of what @seancorfield has already done with his breakdown of his $HOME level deps.edn


I have to agree, deps was a lot easier to learn than project.clj.


I started using it as a side-effect of using Ions, and now I just default to it where I can. Shadow-cljs has good support for sourcing dependencies from deps.edn as well.