Fork me on GitHub
#cursive
<
2023-07-27
>
danm13:07:13

I'm having a weird issue with Cursive. I've finally decided to do something about the warning that pops up every time I launch a REPL:

WARNING: Use of :main-opts with -A is deprecated. Use -M instead.
This is because my REPL config is to Run with Deps, and then has options -A:dev:portal:test, where the portal alias is one I have specified in my ~/.clojure/deps.edn to include
:main-opts ["-e" "(require '[portal.api :as portal])"]
because I got fed up trying to use it and then realising I'd forgotten to require it when I started the REPL. The warning is actually from clj and just being passed back to me via Cursive. On the CLI I can do as it suggests and everything works (I need to add a -r otherwise it immediately exits, which I don't need with -A):
clj -M:dev:portal:test -r
But in Cursive I can't do that. If I specify options as -M:<some_alias_with_main_opts> then Cursive tells me
REPL cannot be run with main options
when I try to edit or run the configuration, and refuses to load a REPL. I also tried removing :main-opts from the alias and specifying -e (require '[portal.api :as portal) directly in the options in Cursive, but it still told me the same thing. I'm perfectly willing to accept that I'm doing something bad here and misusing :main-opts, but in that case how am I supposed to do what I want (run a small set of Clojure commands by default within the REPL whenever one is started)

cfleming11:07:04

Hmm, so this is a bit tricky. You’re right that this doesn’t seem to be possible in Cursive right now without receiving that warning. This is because Cursive checks that the REPL options are used, but then behind the scenes switches to a main invocation using -M to load a script which starts the nREPL server. I’ll think about the best way to manage that validation.