cursive icon indicating copy to clipboard operation
cursive copied to clipboard

Dependency cycle error for cljc files that require macros from itself

Open 2food opened this issue 6 months ago • 4 comments

When I try to load a namespace, that has a :require-macros dependency on "itself" I get a dependency cycle error.

For example in replicant.alias from Replicant:

(ns replicant.alias
  (:require [clojure.walk :as walk]
            [replicant.assert :as assert]
            [replicant.core :as r]
            [replicant.hiccup :as h]
            [replicant.hiccup-headers :as hiccup])
  #?(:cljs (:require-macros [replicant.alias])))

When I try to load it, or any namespace that depends on it I get: Image

This "require macros from itself"-pattern is valid in cljc files where the cljs "instance" of the namespace can require macros from the clj "instance" of the same namespace. It shouldn't be an error, as it's a common pattern when working with cljc files.

This is with Cursive built from 2025.1.1

2food avatar Jun 18 '25 07:06 2food

I'm not sure when this error was introduced, but I do remember working with other code a while a go (maybe a year or so) that also had this "require macros from itself"-feature without it being an issue.

2food avatar Jun 19 '25 12:06 2food

Yes Cursive should handle this, I'll try to look at this today.

cmf avatar Jun 19 '25 22:06 cmf

I did fix a related bug in 2025.1.1 (#3026) but it looks like you're already on that version, right?

cmf avatar Jun 19 '25 22:06 cmf

Yes, I'm on 2025.1.1 / 2025.1-251 That bug seems to be related but maybe not quite the same. 🤷

2food avatar Jun 20 '25 09:06 2food

Sorry, it took me a little longer than expected, but I did look at this. Unfortunately, I can't reproduce it. I've run through some of the replicant examples including the alias ones, and it seems to work fine. Looking at your Cursive version, it looks like you might be running IntelliJ 2025.1.1, but Cursive 2025.1-251. You'll need Cursive 2025.1.1-251 for that bug fix. Sorry, these versions are a little complicated!

cmf avatar Jun 30 '25 01:06 cmf

Ahh, so 2025.1-251 and 2025.1.1-251 aren't the same 😅 I upgraded Intellij and Cursive, with the eap build, to 2025.2-eap2-251. Now I don't get the error anymore. Thanks for looking in to it 🙏

2food avatar Jul 01 '25 07:07 2food