Fork me on GitHub
#calva
<
2023-04-28
>
p-himik10:04:55

I'm probably blind but I can't find a way to specify the java binary path, preferably on a per-project basis. Got back to trying Calva with one of my projects and the Getting Started REPL doesn't work because it tries to use JDK that I no longer have. I have no clue where it could possibly be specified. It's not in the settings, not in the project's files, not in the environment variables.

p-himik10:04:21

Getting this:

⚡️ Starting the REPL ⚡️ using the below command line:
pushd /tmp/betterthantomorrow.calva/1bbwhb ; java -jar '/home/p-himik/.vscode/extensions/betterthantomorrow.calva-2.0.353/deps.clj.jar' -Sdeps '{:deps {nrepl/nrepl {:mvn/version,"1.0.0"},cider/cider-nrepl {:mvn/version,"0.28.5"}}}' -M -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]" ; popd
Exception in thread "main" java.io.IOException: Cannot run program "/home/p-himik/soft/adopt-open-jdk-11.0.12+7/bin/java": error=2, No such file or directory
        at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1143)
        at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1073)
        at borkdude.deps$shell_command.invokeStatic(deps.clj:103)
        at borkdude.deps$_main.invokeStatic(deps.clj:797)
        at borkdude.deps$_main.doInvoke(deps.clj:589)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at borkdude.deps.main(Unknown Source)
Caused by: java.io.IOException: error=2, No such file or directory
        at java.base/java.lang.ProcessImpl.forkAndExec(Native Method)
        at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:315)
        at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:245)
        at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1110)
        ... 6 more
Jack-in process exited. Status: 1

p-himik10:04:59

Tried both ways of starting that REPL - with and without reusing the existing temp directory. Same outcome.

pez10:04:45

Sometimes VS Code gets started with a weird environment. You can try open it from a terminal which has an environment you recognize, using the code command. There is also a setting calva.jackInEnv, where you could specify JAVA_HOME, if all else fails.

p-himik10:04:37

Same outcome. And the stacktrace above suggests that java was found. But it then tried to launch another java subprocess, for some reason with a completely different JDK specified who knows where. :)

p-himik10:04:10

Oh, that's totally calva.jackInEnv!

p-himik10:04:27

Apparently, VSCode doesn't use JSON settings when searching for things.

p-himik10:04:27

Thanks! But a part of the question is still open - is there a way to specify JDK on a per-project basis? Without having to start VSCode in the right environment. I prefer to start it from the menu of my window manager and then use VSCode's built-in UI to open the right project instead of opening a terminal, navigating to the right project, and then starting code there.

pez10:04:48

I just start VS Code from a terminal, without regard to wether it is the right project root or not. If calva.jackInEnv worked for specifying Java version (a bit unclear to me if it did) you can use it in Workspace settings. You can also copy the jack-in command line (there’s a command for this) and start it from a terminal, and then connect Calva to the REPL. The copied command line will contain a step for changing the directory to the project root, so you don’t need to cd there first.

p-himik11:04:38

Yeah, I just removed the ancient calva.jackInEnv section that I had specified for whatever reason at some point. > you can use it in Workspace settings Oh! Of course. Thanks!

pez11:04:06

Ah, I see. Yeah, I guess that can happen too. 😃

skylize12:04:37

You should also be able to specify env vars by prepending them to the exec line of Code's *.desktop file. Doesn't help with project-specific settings while using Code's UI to move between projects. But you could make separate *.desktop files for each project.

👍 4