Fork me on GitHub
#cursive
<
2020-07-30
>
wegi07:07:30

When I have a tools-deps alias which has -m any.cool.class as main-opts the cursive nrepl seems to ignore those, when started with that alias. Am I doing something wrong or is this intended behaviour?

onetom08:07:06

how does your run configuration look like exactly? maybe u can just paste the corresponding XML here from your .idea/runConfiguration or .run folder

wegi08:07:23

Sure.

<component name="ProjectRunConfigurationManager">
  <configuration default="false" name="CLJ REPL" type="ClojureREPL" factoryName="Local" activateToolWindowBeforeRun="false">
    <module name="meetly" />
    <setting name="replType" value="NREPL" />
    <setting name="execution" value="DEPS" />
    <setting name="jvmArgs" value="-Dghostwheel.enabled=true" />
    <setting name="parameters" value="" />
    <setting name="workingDir" value="$PROJECT_DIR$" />
    <setting name="profiles" value="" />
    <setting name="aliases" value="run-server" />
    <setting name="fixLineNumbers" value="false" />
    <method v="2" />
  </configuration>
</component>
The run-server alias has a main-opt -m project.server. Its main is never executed. I even put non-existing function-calls in to see if it breaks. But it does not run at all.

wegi08:07:20

When i do clj -A:run-server it works just fine. But of course I would like to have it inside of my nrepl

onetom08:07:33

okay, so this is a Local nREPL config. IntelliJ have to tell your app to start an nREPL server, so the IntelliJ process can connect and talk to it.

onetom08:07:34

when u start it from the command line, there is no need for a server, because your application process is accepting input from the stdin directly

onetom08:07:23

if u click on the line which appears at the top of your Cursive REPL window, it should expand to a very long command line. at the end of that command-line, there is a -i <some/randomly/named.clj>. that is the program which executes first and enters an nREPL server loop. because of that, no other code has the chance to interpret the -m option from the command-line.

onetom08:07:36

(or something like that; can't remember it precisely)

wegi08:07:47

Thanks, so there is no option to start the -main function inside the newly created nrepl, except of doint it by hand then?

onetom14:07:44

im not sure i understand that question, but at the same time im not sure i can explain it more precisely either. how i understood this was by reading the source code of clojure.main/-main https://github.com/clojure/clojure/blob/master/src/clj/clojure/main.clj#L616-L674 which is referenced from this java entry point: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/main.java#L23

onetom14:07:38

nothing really beats reading the source code, when it comes to understanding how things work 🙂