Fork me on GitHub

Hi guys, is there any example project who completely abuses clojure.spec. I would like to study it!


How can I install Clojure dependencies from command-line?


@stardiviner Do you have the clj command line tool installed? Or boot?


(or do you mean you want to install some basic Clojure tooling, via a command line? If so, what O/S are you on?)


I'm running Arch Linux


I want to add/install Clojure dependencies through Emacs Org-mode babel. It is a kind of literate programming style.


I tried clj with deps.edn. Got an error. Here is what I do: I create a file deps.edn in a abritry directory (not clojure project dir). it is {:deps {clj-time {:mvn/version "0.14.2"}}} Then I run command clj -Sdeps deps.edn. Here is the error:

Error building classpath. Don't know how to create ISeq from: clojure.lang.Symbol
java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol
        at clojure.lang.RT.seqFrom(
        at clojure.lang.RT.seq(
        at clojure.core$seq__5124.invokeStatic(core.clj:137)
        at clojure.core$merge_with$merge2__5685.invoke(core.clj:3058)
        at clojure.lang.ArrayChunk.reduce(
        at clojure.core$reduce1.invokeStatic(core.clj:934)
        at clojure.core$reduce1.invokeStatic(core.clj:926)
        at clojure.core$merge_with.invokeStatic(core.clj:3051)
        at clojure.core$merge_with.doInvoke(core.clj:3043)
        at clojure.lang.RestFn.applyTo(
        at clojure.core$apply.invokeStatic(core.clj:659)
        at clojure.core$apply.invoke(core.clj:652)
        at clojure.lang.RestFn.applyTo(
        at clojure.lang.Var.applyTo(
        at clojure.core$apply.invokeStatic(core.clj:657)
        at clojure.main$main_opt.invokeStatic(main.clj:317)
        at clojure.main$main_opt.invoke(main.clj:313)
        at clojure.main$main.invokeStatic(main.clj:424)
        at clojure.main$main.doInvoke(main.clj:387)
        at clojure.lang.RestFn.applyTo(
        at clojure.lang.Var.applyTo(
        at clojure.main.main(


The -Sdeps arg is to provide an EDN string on the command line that provides additional deps etc. clj automatically reads the deps.edn file in the current directory.


You can use -Sdeps when you don't have a deps.edn file (or when you want to provide additional dependencies).


I see. I misunderstand the clj --help part -Sdeps EDN. I thought it is a file. So it is a string. Thanks


For example, if you didn't have that deps.edn file, you could do

clj -Sdeps '{:deps {clj-time {:mvn/version "0.14.2"}}}'
and it would start a REPL with clj-time loaded.


@stardiviner If you're interested, I have my ~/.clojure/deps.edn file on GitHub


Those aliases let me run various versions of Clojure, various dev and test tools, various REPLs...


@seancorfield This looks great. Helped me a lot. glad you share it.


@seancorfield Does those alias used like clj -A:1.8 ?


@stardiviner Yes, so, for example, you can drop into a project and say clj -A:test:runner:1.8 and you'll get the :test alias to bring in the test directories and test.check, and the :runner alias to get Cognitect's test-runner, and the :1.8 alias to bring in Clojure 1.8.


Want to get started with web development


Any books ?


Hello all. I haven't done much with Clojure, and what I did was 4 years ago. I'm trying to follow an old Datomic tutorial on Youtube, but I'm running into this problem when I try to do

lein expectations
Could not locate expectations__init.class or expectations.clj on classpath


I'm not behind a proxy


I've got [lein-expectations "0.0.8"] in my .lein/profiles.clj and [expectations "2.2.0-rc3"] in my project.clj


hey guys, which editor are you using? I'd like something simple that just works. I've been using Sublime for everything, but the clojure plugin seems weird :thinking_face:


It might not satisfy your definition of simple but after jumping between vanilla emacs and Cursive several times I ended up with spacemacs. It's really cool and provides most of the configuration out of the box.


I've tried out spacemacs before. it's cool, but one needs to learn a lot to use it - and I can't handle learning a language + an editor at once. thanks for the suggestion though, maybe someday :)


I also use Spacemacs, but I have a Vim background already so it didn’t seem too onerous. You could try Atom with Proto-REPL or Cursive which is a Clojure plugin for IntelliJ.


spacemacs +++


Cursive gives me no problems and "just works"


thanks 👍


hi, in spacemacs, can I select some lines of code and send them to the repl? Evaluating the whole file is not an option since it has not matching parenthesis below


not sure but you can do it in cursive


haven't tried cursive. In fact, I don't customize emacs/spacemacs, maybe I'll give it a spin. Do you find it superior to emacs? in what aspects?


emacs has the potential to be superior to cursive and any other program out there, unfortunately for us mere morals with limited lifespans it's usually more practical to use something that works, like Cursive


@lum Yes, though you usually don’t “select” lines of code, you instead put your cursor at the expression you want and invoke the “send to repl” command — are you using CIDER? Vim or Emacs mode?


@lum In Spacemacs, you can explore the available functions by hitting space twice (SPC SPC), then start typing, e.g. cider- — you will find cider-eval-region, cider-eval-defun-at-point, cider-eval-last-sexp — and their keyboard shortcut for future reference.


I'm going through Brave Clojure, and I'm having some trouble understanding this function:

(defn symmetrize-body-parts
  "Expects a seq of maps that have a :name and :size"
    (loop [remaining-asym-parts asym-body-parts
            final-body-parts []]
      (if (empty? remaining-asym-parts)
        (let [[part & remaining] remaining-asym-parts]
          (recur remaining
            (into final-body-parts
              (set [part (matching-part part)])))))))
why is loop being recured with only one argument?


oh, it's being called with two arguments. silly me :^)


just curious, is the clj tool supposed to be replacing leiningen and boot for modern clojure projects?

Alex Miller (Clojure team)19:03:11

They have different goals. Lein and boot are intended to be full build/project management tools. clj is designed to build classpaths and launch programs. As people have since noticed, being able to set deps for your classpath and run arbitrary programs also means you can program your own build tools in any way you like.


@idas I don't think that is the full intent. But, for projects that can work fine with deps.edn, the simplification is nice.

Russ Olsen16:03:04

@idas I think it's fair to say that there is tremendous overlap. One of the big benefits of the new clj tools is that it provides a much simpler "get to the repl" experience for people just starting out.

Russ Olsen16:03:22

And @mfikes Beat me to it. Again.


gotcha. thanks @mfikes and @russ767! the reason I ask is that on the clojure subreddit ( i seem to see a few new things using clj: * * * but books like Clojure Brave and True still suggesting boot and lein: * *


in cursive, parenthesis are unbalanced, how to add closing parenthesis? Using vim keybindings

Russ Olsen17:03:35

@idas Possible it's just inertia - the clj tools have not been out all that long.


It's easy to try out for fun. Using clj is tangibly faster to start than lein or boot.


brew install clojure on macos

Russ Olsen17:03:11

Also, at least IMO books need to explain what is as much as they explain what's about to be. At least that is the tact I took with Getting Clojure, where I mention the clj tools, boot and lein but mostly stick to lein for the bigger examples on the theory that that is what you will come across most often.


Does anyone still use Expectations, and does it currently work? I can't get a tiny simple project to build/run with it. I get Could not locate expectations__init.class or expectations.clj on classpath


Is it possible to reference a map property inside of itself in clojure? For example:

(def duration {:second 1000 :minute (*  (:second duration) 60)})

Russ Olsen19:03:51

That will only work if duration is already defined, but sure, your new definition of duration will pick up the old one when you rerun do the def.

Russ Olsen19:03:54

But that would imply that you are re'defing duration which is not something you would really want to do. Def'ed bindings are meant to be mostly stable in production. In debugging/repl work we tend to honor that rule more in the breach but re'def is something you want to avoid in real programs.


Yeah, that was something I was hoping to avoid.


FWIW, the root issue is that map constructors are eager. There are lazy implementations. For example:

user=> (require '[lazy-map.core :refer [lazy-map]])
user=> (def duration (lazy-map {:second 1000 :minute (*  (:second duration) 60)}))
user=> (:second duration)
user=> (:minute duration)


Interesting. I am going to avoid this, but this is good to know!


If I used that in the scenario I am working in, I feel it would be in the spirit of being clever over anything else.


Yeah, I wouldn't recommend it. Planck and Lumo make use of it to replace the gigantic compiler environment map associated with the cljs.core namespace with a lazily-loaded implementation, in order to shave off a few milliseconds from launch time. In that case, they are using it truly for its lazy characteristic, and the fact that it looks like any other map, to a high enough fidelity to fool the ClojureScript compiler.


For your case, I would probably just construct the map in the scope of a let.


(def duration (let [second 1000
                   minute (* second 60)]
  {:second second :minute minute}))


That is pretty neat.


@lum I think there's a plugin for that


and if not, there's always shift-0


I'm just kidding. there's probably something like rainbow parentheses and/or paredit