BetterThanTomorrow / calva

Clojure & ClojureScript Interactive Programming for VS Code
https://marketplace.visualstudio.com/items?itemName=betterthantomorrow.calva
Other
1.64k stars 216 forks source link

Jack-in process exited on main-opts "-e" option #2551

Open lensgolda opened 4 months ago

lensgolda commented 4 months ago

Cheers!

;; deps.edn dev alias
{:dev {:extra-paths ["dev"]
       :extra-deps {integrant/repl {:mvn/version "0.3.3"}
                    hashp/hashp {:mvn/version "0.2.2"}}
       :main-opts ["-e" "(require,'hashp.core)(require,'user.my)"]}

my job project has this :dev alias with main-opts "-e" eval option, under the Git. When i starting Calva Jack-in process, it exited with Status 0.

Connection log:

⚡️ Starting the REPL ⚡️ using the below command line:
(cd /Users/lens/dev/project; clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version,"1.0.0"},cider/cider-nrepl {:mvn/version,"0.28.5"}}}' -M:dev:test)
...
# ;;some logs
07:56:45,417 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml]
07:56:45,417 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy]
...
Jack-in process exited. Status: 0

If i comment line with ;; :main-opts ["-e" "(require,'hashp.core)(require,'user.my)"] everything works fine (REPL starts). If i comment line with ;; :main-opts ["-e" "(require,'hashp.core)(require,'user.my)"]and add connect sequence like so, everything also works fine:

"afterCLJReplJackInCode": "(require 'hashp.core) (require 'user.my) (in-ns 'user.my)",

The problem is i have to comment line each time starting a project, beacause i don't control deps.edn, and it coming from Git for me and i can't push changes like this to Git. I have to revert changes in deps.edn each time.

Is there any way to leave deps.edn unchanged to Start Calva REPL this :dev alias, with or without this option

:main-opts ["-e" "(require,'hashp.core)(require,'user.my)"]

Best! Thanks!

lensgolda commented 4 months ago
VSCodium
Version: 1.88.1
Release: 24104
Commit: 0d01a72525276e5e3771fe5851b9c83de0de1e2b
Date: 2024-04-13T02:09:27.708Z
Electron: 28.2.8
ElectronBuildId: undefined
Chromium: 120.0.6099.291
Node.js: 18.18.2
V8: 12.0.267.19-electron.0
OS: Darwin x64 23.4.0
PEZ commented 4 months ago

Hi!

What may work is to define a :job-dev alias in your user deps.edn and then specify that alias in menuSelections.cljAliases of the connect sequence. If that doesn't work (not recalling whether Calva insists on that these aliases are defined in the project) there is also a setting calva.myCljAliases, but having that in your user settings may mess up your work with other projects...

Probably the best solution would be to agree with the team mates that :load-hashp should be its own alias.

Also, I may be missing something. Could be interesting to learn what your team mates do. Because it seems most people will be using nREPL and that :dev alias will be shutting the door to start the nREPL server via main-opts for them as well.

lensgolda commented 4 months ago

i think it's because of main-opts in :dev alias and the way Calva starts nrepl

-M:dev:test ->|-m|<- nrepl.cmdline

and my :main-opts ["-e" "(require,'hashp.core)(require,'user.my)"] should or

For some reasons, it works for my teammates without pain, beacause they mainly use Cursive or neovim, maybe beacause REPL starts for them another way, i don't know.

Anyway, the only one way i know it works like a charm - if i remove :main-opts-key at all, and, for example, add this code to eval under afterCLJReplJackInCode": "(require 'hashp.core) (require 'user.my)"

So if the best solution is to agree with the team mates, i will. There was a hope about another way.

Thanks!

P.S. i think you may close.

PEZ commented 4 months ago

Today Calva throws in the towel if the alias has a main opts. (It should inform/warn you about this in the alias select menu.) Maybe we could make that more sophisticated and merge if we can see that the main opts do not have a -m option and then merge the opts. Maybe that is what the other tools do, even.

Let's keep this issue open until we have figured out if we should fix anything.

Meanwhile, since you know what command line would fix it for you, I think you could leverage Jack-in custom command lines to dodge the problem.