calva

Maravedis 2025-07-24T15:14:02.059849Z

Hello. Very stupid issue but I'm not seeing a setting to fix it: My calva extension cannot find my java home, despite the JAVA_HOME being set. I'm connecting through remote-ssh with vs-code. Both my clojure and java installs are in /usr/local. Do I have to set something somewhere ? I'm not finding any setting related to this.

seancorfield 2025-07-24T15:15:14.425669Z

The Clojure CLI uses JAVA_CMD as I recall, which is normally $JAVA_HOME/bin/java

Maravedis 2025-07-24T15:15:16.203039Z

Here is the error. Looks like an lsp thing, but lsp documentation doesn't really enlighten me either.

Maravedis 2025-07-24T15:15:21.030479Z

Oh.

seancorfield 2025-07-24T15:16:49.566459Z

Ah, if you don't have JAVA_CMD set, it should set it from JAVA_HOME if available:

set +e
JAVA_CMD=${JAVA_CMD:-$(type -p java)}
set -e
if [[ -z "$JAVA_CMD" ]]; then
  if [[ -n "$JAVA_HOME" ]] && [[ -x "$JAVA_HOME/bin/java" ]]; then
    JAVA_CMD="$JAVA_HOME/bin/java"
  else
    >&2 echo "Couldn't find 'java'. Please set JAVA_HOME."
    exit 1
  fi
fi
So I was wrong.

seancorfield 2025-07-24T15:17:09.918849Z

So it's probably just the shell process that Calva invokes not actually having either set.

Maravedis 2025-07-24T15:18:11.631009Z

Ooh. I think I have an idea. I set my java env in my oh my zsh hook scripts. 10 to 1, code runs under that. I'll try to set it in .bashrc or something.

seancorfield 2025-07-24T15:18:13.373719Z

When you ssh into the dev box manually, does java -version work? What about env | fgrep JAVA?

seancorfield 2025-07-24T15:18:29.567289Z

Yup, that sounds about right.

Maravedis 2025-07-24T15:20:08.910489Z

Was not that 😞

Maravedis 2025-07-24T15:27:02.298219Z

Even forcing via the ssh config doesn't work 😖 :

Host MyServer
  <..>
  SetEnv "JAVA_HOME=/usr/local/jdk-21.0.2"
Still having "Please set JAVA_HOME"

seancorfield 2025-07-24T15:41:00.116929Z

What about the commands I suggested running above?

seancorfield 2025-07-24T15:41:13.290569Z

(to test what your ssh'd env actually has)

Maravedis 2025-07-24T15:45:34.405479Z

Any terminal I open on this server has JAVA_HOME set and can access the java binary, whether it is through a my terminal in which I manually ssh or the vscode terminal window.

seancorfield 2025-07-24T15:48:41.802279Z

What about ssh user@server env? Does that still show it set? (I'm trying to establish whether it is set for all shells or only interactive ones)

Maravedis 2025-07-24T15:51:38.980799Z

Good catch. Doesn't seem to be set there.

seancorfield 2025-07-24T15:54:37.434639Z

Does your .bashrc file start with this?

# If not running interactively, don't do anything
case $- in
    *i*) ;;
      *) return;;
esac

Maravedis 2025-07-24T15:55:32.200709Z

Oh my god it does.... Should I just put the java home declaration before that?

seancorfield 2025-07-24T15:56:25.093319Z

I'm not sure what to suggest. I have most of my setup in .profile but I might be using a different shell to you...?

Maravedis 2025-07-24T15:57:00.177659Z

I use zsh and custom hooks, but my .bashrc actually points to documentation, I might find what I need there.

seancorfield 2025-07-24T16:01:27.171809Z

What's in your .zshrc file then?

Maravedis 2025-07-24T16:05:23.188729Z

Lots of irrelevant thing (oh my zsh), and literally just an export of JAVA_HOME and JAVA_CMD .

Maravedis 2025-07-24T16:06:10.213269Z

What I don't get is that on my other linux installation with Arch, it works out of the box. I didn't expect Debian to give me so much grief 😅

Maravedis 2025-07-24T16:07:55.793069Z

I also have this export in /etc/profile.d/jdk21.sh, so it should run on non-interactive shells...

Maravedis 2025-07-24T16:11:50.979329Z

Oh my god I'm dense. I had to change /etc/zsh/zshenv. Now it's set.

👍🏻 1
Maravedis 2025-07-24T16:12:49.139629Z

And it works. Thank you very much for your help and time @seancorfield.

seancorfield 2025-07-24T16:32:03.615349Z

Remote shell stuff is always weird. Bites me from time to time, even after all these years.

seancorfield 2025-07-24T16:32:34.363279Z

(the first *nix I worked on was back in 1979 🙂 )

Maravedis 2025-07-24T19:21:31.975489Z

Hello. Trying to learn clojurescript, and I'm trying to follow [this guide](https://blog.agical.se/en/posts/shadow-cljs-clojure-cljurescript-calva-nrepl-basics/). I get an error:

;
; ; clj  starter.browser
; Syntax error compiling at (src/main/starter/browser.cljs:5:3).
; No such namespace: js
; Evaluation of file browser.cljs failed: class clojure.lang.Compiler$CompilerException
I'm completely useless at cljs and I 'm really having a hard time finding why this is failing.

Maravedis 2025-07-24T19:24:02.751699Z

Posting this here because npx shadow-cljs browser-repl does work.