More generally, there’s basically no way to do anything in IntelliJ without a project. The only thing you get without a project is the welcome splash screen.
The only thing that’s really possible at the moment is the new LightEdit mode (https://blog.jetbrains.com/idea/2020/04/lightedit-mode/), but as far as I know that’s pretty experimental at this stage.
I keep experiencing a namespace loading issue, which seems to be sensitive to timing.
I change a file and if I quickly press Cmd-Shift-L or M, not all my changes are reflected in the REPL process.
It started to manifest more often lately, so I hooked up clojure.tools.namespace/refresh
and kaocha
to a Cursive REPL command and assigned a shortcut to it, hoping to improve the situation.
The result is total chaos.
If I use Cmd-Shift-L and refresh
in alternation, my changes won't be reflected in the REPL anymore.
Has anyone using ctnr/refresh
successfully from Cursive?
Has anyone experienced missed loading of changed files?
How should I approach the problem of creating a minimal reproducible example?
I’ll try to reproduce this - Cursive does save all files before executing these commands, but it’s possible that IntelliJ takes a while to flush to disk? I’m not sure.
In terms of a repro test case, anything I can run would be helpful. Perhaps just a project set up like yours with a simple test (= "Hello" "Hello")
? Then it should be possible to change one of the strings and run the test quickly to see the problem.
it seems the problem is that the current file is not always correctly identified as a modified file.
so if my REPL command is configured to Before executing: Sync all modified files
, then i modify my test source and run my (time ((requiring-resolve 'kaocha.repl/run) :unit))
REPL command, my current test state might not be loaded into the REPL process.
the missing Loading test/ns/xxx_test.clj... done
lines in the REPL tool window correctly reflect what happens.
so, this phenomena is observed without using ctnr/refresh
@cfleming i've emailed you a video recording which demonstrates the issue.
i think for now i can work around the problem by just using the Before executing: Load current file
and try to remember to press Cmd-Shift-M, if I modified dependent files, but haven't reloaded them manually.
pushed the repo, which I used to record the video demonstration here: https://github.com/onetom/cursive-reload-issue
I have one more suspicion; Kaocha itself, since it's not exactly a trivial piece of software. I'm also experiencing something which makes no sense at all. I previous version of my test runs somehow, when I'm only editing and letting the Cursive REPL command load the current file and run kaocha. after manually switching over to the test namespace an load it with Cmd-Shift-L, it finally gets updated in the REPL process. (and I'm not changing the name of the deftest; I know that's a common cause for phantom tests; this is a different situation)
we are at the point, where we have to keep restarting the REPL way too often, because we just can't trust test results anymore. this is the REPL command definition, which I used rather successfully for months, but exhibits a timing issue:
<repl-command name="ginoco Kaocha" executionType="EXPRESSION" commandText="(time ((requiring-resolve 'kaocha.repl/run) :unit))" executeBefore="SYNC_ALL" executionNs="REPL_CURRENT" inNamespace="" saveAll="true" />
I change a character in my test code, trigger the REPL command with a shortcut, but faster than ~700ms, then the changed file is not reloaded, but the tests still run with the previous version of the code, yielding misleading test results :(
the new REPL command looks like this:
<repl-command name="ginoco Kaocha" executionType="EXPRESSION" commandText="(do (try (require 'gini.kaocha) (catch Exception ex))&#10; (clojure.tools.namespace.repl/refresh)&#10; (time ((requiring-resolve 'kaocha.repl/run) :unit)))" executeBefore="SYNC_ALL" executionNs="REPL_CURRENT" inNamespace="" saveAll="true" />
they (require 'gini.kaocha) is just configuring the stack trace filters, but not available in every REPL, that's why the try-catch around it.I use ctnr/refresh-all
but not as part of a repl command
however, I think you need to use the :after
to execute something after the refresh
(repl/refresh-all :after `start)
what does it take to have the Add dependency to project.clj command/action work? ( i believe i never saw anything in the search popup)
You’re right, that seems to be broken, I’ll look at that.
thank you