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.
The Clojure CLI uses JAVA_CMD as I recall, which is normally $JAVA_HOME/bin/java
Here is the error. Looks like an lsp thing, but lsp documentation doesn't really enlighten me either.
Oh.
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.So it's probably just the shell process that Calva invokes not actually having either set.
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.
When you ssh into the dev box manually, does java -version work? What about env | fgrep JAVA?
Yup, that sounds about right.
Was not that 😞
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"What about the commands I suggested running above?
(to test what your ssh'd env actually has)
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.
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)
Good catch. Doesn't seem to be set there.
Does your .bashrc file start with this?
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esacOh my god it does.... Should I just put the java home declaration before that?
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...?
I use zsh and custom hooks, but my .bashrc actually points to documentation, I might find what I need there.
What's in your .zshrc file then?
Lots of irrelevant thing (oh my zsh), and literally just an export of JAVA_HOME and JAVA_CMD .
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 😅
I also have this export in /etc/profile.d/jdk21.sh, so it should run on non-interactive shells...
Oh my god I'm dense. I had to change /etc/zsh/zshenv. Now it's set.
And it works. Thank you very much for your help and time @seancorfield.
Remote shell stuff is always weird. Bites me from time to time, even after all these years.
(the first *nix I worked on was back in 1979 🙂 )
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.Posting this here because npx shadow-cljs browser-repl does work.