Fork me on GitHub

I'm using deps.edn, trying to require a library into the repl and it results in Execution error (FileNotFoundException) at user/eval3 (REPL:1).


Tried with a few different libraries and the same thing, running on linux. Using different clojure versions doesnt make a difference. Am I missing something?

Alex Miller (Clojure team)03:02:25

Can you post your deps.edn and what you’re doing in the repl


{:deps {selmer {:mvn/version "1.12.33"}}}


(require '[selmer.parse :as sp])


i think you want selmer.parser with a trailing r


oof i wasnt certainly missing something, thank you for reaffirming my sanity


no worries. i went to the github page and saw what namespaces were there. and saw the easy to make typo

Rowan Barnard04:02:53

Hi guys, I'm using the clj command line tools and REPL from Powershell commandline in Windows with Clojure 1.10.1 and I've typed (doc clojure.set/intersection) into the REPL and it just returns nil with no documentation. The only thing I've required into the default user namespace is clojure.specs.alpha aliased as s. Any ideas what's going on?


@flyingpython You'll need to require clojure.set first


It isn't loaded by default.

Rowan Barnard04:02:30

Oh and I've just found out Clojure can't find clojure.set when I tried to run the intersection function: Execution error (ClassNotFoundException) at .URLClassLoader/findClass ( clojure.set

Rowan Barnard04:02:44

I'm not sure why it can't find it; I opened clj from a Powershell terminal in a folder I created for practising from the Programming Clojure book


seanc@DESKTOP-30ICA76:~/clojure$ clj
Clojure 1.10.2
user=> (doc clojure.set/intersection)
user=> (clojure.set/intersection #{:a :b} #{:a :c})
Execution error (ClassNotFoundException) at (
user=> (require 'clojure.set)
user=> (doc clojure.set/intersection)
([s1] [s1 s2] [s1 s2 & sets])
  Return a set that is the intersection of the input sets
user=> (clojure.set/intersection #{:a :b} #{:a :c})
^ @flyingpython


Like I said, you need to require clojure.set first. It is not loaded by default.

Rowan Barnard04:02:27

OK I didn't realise I thought it would find it if you qualified it with the namespace

Rowan Barnard04:02:42

Thanks Sean 🙂


No. That happens to work for a few of the core namespaces but you should never rely on it.

Rowan Barnard04:02:28

Ah OK that is what was confusing me probably because was pretty sure that usually worked


Here's what is currently loaded by default in a REPL:

seanc@DESKTOP-30ICA76:~/clojure$ clj
Clojure 1.10.2
user=> (->> (all-ns) (map str) (sort))
("clojure.core" "clojure.core.protocols" "clojure.core.server" "clojure.core.specs.alpha" "clojure.edn" "clojure.instant" "" "" "" "" "clojure.main" "clojure.pprint" "clojure.repl" "clojure.spec.alpha" "clojure.spec.gen.alpha" "clojure.string" "clojure.uuid" "clojure.walk" "user")
(but don't rely on that)

Rowan Barnard04:02:45

That is all the ones that you can use without explicitly loading them?

Rowan Barnard04:02:23

Oh sorry didn't read your first line


That is the ones that you can coincidently use without requiring them. But don't. It could easily change at any time.

Rowan Barnard04:02:41

OK thank you very much Sean 🙂


It's always better to explicitly require a namespace and give it an alias and use the alias.


Why is it better to alias?


Better than using the full namespace name in qualifiers everywhere? Makes the code easier to read. Better than referring a name into your current namespace? Gives a clear indication at the point of use that a name comes from another namespace. Explicitly requiring all the namespaces you use (and giving them aliases) in your ns form? Provides a straightforward checklist of all your dependencies in one place at the top of the file.


Thanks. It was the “always” that intrigued me. I tend to most often alias things, but with some of the clojure ones I don’t. I get confused with aliases like [clojure.string :as str] and [clojure.set :as set], so I require them w/o aliases. In code bases where I am the one making the call, at least. I also refer in some stuff. Not sure what my criteria are, but anyway. 😃


I will :refer in a handful of symbols that work better as syntax (like >! etc from core.async) and we've adopted a set of standard aliases for many of the namespaces we used (enforced by clj-kondo`). In tests, I tend to refer in all the parts of clojure.test that I use so there's less "distraction" in the test code. Overall though, I still start from the position that every namespace should be required and aliased -- so, yes, there are exceptions (as there are to every "rule") -- but knowing when to break the rules comes with experience.



Rowan Barnard04:02:00

OK will remember this 🙂

Old account10:02:28

I wonder is there a predicate opposite to nil? something like not-nil? or something like that...



💪 4

quick question about core async, assuming I have a coll and want to push the values to a channel, is the idiomatic way (map #(async/>!! ch %) coll)or is there something more concise?

Alex Miller (Clojure team)13:02:35

Look at the to-chan / onto-chan stuff in the core.async api

Alex Miller (Clojure team)13:02:02

Here, I think you want onto-chan!!


yeah what I figured as well. Was hoping for a blocking variant but this works. Thanks!

Alex Miller (Clojure team)15:02:19

onto-chan!! will block?

Alex Miller (Clojure team)15:02:46

oh, I see what you mean

Alex Miller (Clojure team)15:02:07

can you get that by taking from the channel returned by onto-chan?

Alex Miller (Clojure team)15:02:33

seems like that's the return of the thread fn and all puts should be done by then


Yeah, you can take from the returned channel, but at that point the conciseness vs map is starting to suffer. Anyways, thanks for sorting out the options. Looking at this I think i might stick with map for now.

Alex Miller (Clojure team)19:02:57

vs map, run! is probably preferred for this case btw


Wow. Never ran across run! (ha!). Thanks! And yes, a better match when we don't care about the return values.


I saw the onto-chan variants, but they all seem to involve concurrency (as in starting threads, go loops) which is not what I wanted here


Is there a recommended way to use date/time in clojure on the JVM?


Interop 🙂


Esp if you are using Java 8 and above


I should say, that's my perferred way 🙂


is there a way to have an add-watch only on part of an atom? (Say an atom is a map, and I want to see when the value of a key changes, but I'm not concerned about other changes and would like to not do useless computation)


There is nothing like that built into Clojure that I can see. You can begin a watch function with the quickest code that determines whether it is an "interesting" change to you or not, and return as quickly as you can if it is uninteresting.


e.g. the body of the watch function could be something like (if-not (identical? (:foo old-val) (:foo new-val)). <useful code here>)


Or often you would care more about = than identical?


thanks @U0CMVHBL2, I'll use this approach!


I find myself repeatedly importing the same convenience namespaces (like [com.fulcrologic.guardrails.core :refer [>defn >def =>]]) in each namespace. Is there a way of doing that once and forall?


There might be some IDE hotkey thing that does something like that, but I suspect that most folks probably just copy and paste those from another existing namespace, when creating a new namespace.


Good ol copy and paste, works every time.


Yes a snippet is possible in most ide. It is what i done for test namespace as it is often the same code...


thanks, I can set a snippet in emacs, it's probably a good idea

Eric Le Goff13:02:14

What function would you use to transform a vector like

[:a :b :c :d :e]
into a list of the consecutive pairs , like
[(:a :b) (:b :c) (:c :d) (:d :e)]
? While it is simple to apply functions I already know , on my learning curve I am currently struggling with inferring which core function I could use to solve specific use cases...


(vec (partition 2 1 v))

👍 4

Where v is the input.

Eric Le Goff13:02:40

I knew about partition [n coll] but overlooked partition [n step coll], thanks a lot :)


@U7ESL5ANN this fits my style, YMMV, but I found it very useful to read and understand every function here when I was getting started:

👍 4

Hello, I have a question about automatically restarting agents. clojuredocs shows that restart-agent needs to be called in a separate thread, so shows it being called in a future in the :error-handler. Before I stumbled across this, I tried supplying this error-handler: (fn [ag ex] (send ag (constantly foo))) (where foo is the initial state of the agent), which seems to work fine. Is there any reason to prefer calling restart-agent in a future to my approach?

Alex Miller (Clojure team)14:02:14

have you looked at just using (set-error-mode! ag :continue) ?


I have, but that results in the agent keeping the state it had before the error


In my case, I want to throw the towel in and revert the agent to how it was at the beginning, I think


thanks 🙂


I'm an ex-Rails dev looking at adding user auth & roles to a clojure webapp. In rails I'd just use Devise and basically be done with it. I've poked around a bit and found and, but neither seems fully featured (though buddy is closer, it still has a lot in the TODO section of the readme) Is there a recommended library for Devise-like functionality that I'm missing or is the standard practice to roll your own?


Nothing like Devise, to my knowledge. Do manual atop buddy.


i'm not aware of a Devise-like library, but it has been some time since i looked


i prefer buddy over friend


thanks for the replies @chrisblom & @claudius.nicolae - both of you prefer buddy over friend - could you say why ?


i found buddy easier to use


it has some pre-built middleware that was easy to integrate:


I prefer buddy because I'm cargoculting.


But it's also newer (so it had the opportunity to consider what can be improved in friend), and more modular - piece-wise.


Something Devise-like could be implemented as a module (with buddy for warden, and ring for rack).


thanks for the pointers you two.. much appreciated. I need some hammock time to process 😛 hammock

hammock 15

friend is not really maintained anymore, and was forked and updated by clj-commons to fix a CVE in a dependency: