Clojure, Cursive - Resolving "cannot be resolved"

Recently I’ve been using http-kit quite a bit when working with Clojure. The main things I like about it are the sensible defaults, async by default, and being able to set a timeout.

Aside from this I also use Cursive. As such I had a small issue where when using httpkit.client functions, cursive was unable to figure out what the functions under client are. The reason for this looks to be because httpkit.client uses a macro to generate it’s functions relating to requests called defreq.

This defreq is something that Cursive doesn’t seem to recognise as generating a function, so as such you end up with this error: org.httpkit.client/get cannot be resolved although the function will work as expected.

cursive cannot be resolved error

This annoyed me for a little while so I looked into it a bit further and asked around on the lovely Clojurians slack, which is a great community.

It wasn’t long before someone was able to give me an answer on how to resolve this.

You can see the conversation here in the Clojurians slack archive, but I’ve also replicated the instructions below in case that gets lost for whatever reason.

To fix it:

  • Go to the defreq macro definition in httpkit.client
  • Put the cursor on the defreq and alt-enter to bring up the suggestions
  • Choose “Resolve defreq as…”

image

  • Select “Specify” and then type in “Declare” in the var name, picking the one from clojure.core

image

This should then resolve it. You can see a list of your definitions in the settings, too, under Settings → Languages & Frameworks → Clojure → Symbol Resolution

All in all this was another nice interaction with the Clojure community.