Fork me on GitHub

@thheller if I evaluate something that isn't bound like foo or (foo) with cider-eval-last-sexp, it shows nil rather than complaining about not being able to resolve the symbol. Is that likely to be related to your answer above too?


@ben735 with regular shadow-cljs node-repl I get

cljs.user=> foo
------ WARNING - :undeclared-var -----------------------------------------------
 Resource: <eval>:1:1
 Use of undeclared Var cljs.user/foo

cljs.user=> (foo)
------ WARNING - :undeclared-var -----------------------------------------------
 Resource: <eval>:1:2
 Use of undeclared Var cljs.user/foo


cider is getting the same info. if it doesn't show it I don't know where it goes


@thheller thanks - and I appreciate that you don't use cider - I might report a bug for cider and see what others think


shadow-cljs might be doing something cider doesn't expect. could easily change that if somebody tells me what it expects instead.

🙌 1
Drew Verlee19:06:32

When i start cider via cider-jack-in how is it picking a version of java and clojure to use? this is what i see at the top of the buffer in emacs

;; CIDER 1.5.0-snapshot (package: 20220531.616), nREPL 0.9.0
;; Clojure 1.9.0, Java 11.0.11

Drew Verlee19:06:10

the clojure version matches the one in my deps.edn file, so i'm curious about the java version.

Drew Verlee19:06:11

i'm guessing emacs is just searching my OS according to some set of rules. This is frustrating because it's probably not going to play nice with jenv


• java: it just invokes whatever process your project is based on: clj, lein, etc and does that. It doesn’t choose, just execs the program. Same as if you typed into a terminal clj. The environment dictates the java version • clojure: always from the project tool you are using, lein or clj


easiest way to figure this stuff out is to start an eshell and then which java


Welcome to the Emacs shell

~/projects/work/metabase $ which java
~/projects/work/metabase $ 


an easy way to remove this indirection. cider-jack-in. grab the jack in command from the *Messages* buffer. Save this form into a shell function. Then use that shell function to start the process and cider-connect to it


oh, and that startup form is also at the top of the repl banner message

Drew Verlee19:06:52

which java from my emacs shell is saying ..jenv/shims/java and jenv version is openjdk...1.8 but the repl was starting with java 11.0.11 maybe it's ideal to just cider-connect (which is what your saying i suppose)


yeah i’d say its far more predictable without the extra exec-path of emacs


you might have to get into nitty gritty as to why you are getting different versions


might be the default java at the time you launched emacs


emacs might not be “in the directory” you expect when it execs the process so maybe not getting the settings for that dir?

Drew Verlee19:06:16

it's a thought, ill look into it more later 🙂 thanks for the help.


I believe the Clojure executable file will search the operating exec path, $PATH, to look for a java executable, so it may find a java on the PATH before it finds jenv Also check to see if JAVA_HOME is set to a particular path (although this is less used now)


To use cider-connect there is an example deps.edn alias here (remove the -i option if you want a headless process (i.e. no repl prompt in the terminal)

Drew Verlee18:06:05

Thanks John. I'll take a look. Maybe i should use something that updates path to...


Depending on the environment, it may also be possible to set the java.runtime.version=17 or other version of Java in a file in the root of the project, which can be useful when several versions of Java are available to the system. There are other properties, but it depends on the tooling as to if these properties are consulted.

👍 1

Or that property may be able to be set with a -J option on the command line, or with Cider including a :jvm-opts key in an alias that is added to the cider-jack-in command (i.e. I am assuming an alias would be something like the following (but I havent tried this myself yet)

:jvm/report {:jvm-opts ["-Djava.runtime.version=17"]}
This might need "-Djava.home;/path/to/directory/containing/java" to work, or that may work by itself...

👍 1