Fork me on GitHub
#cider
<
2022-06-15
>
Sturm03:06:54

@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?

thheller06:06:02

@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
--------------------------------------------------------------------------------

thheller06:06:32

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

Sturm06:06:00

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

thheller06:06:24

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

dpsutton19:06:33

• 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

dpsutton19:06:51

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

dpsutton19:06:11

Welcome to the Emacs shell

~/projects/work/metabase $ which java
/Users/dan/.sdkman/candidates/java/current/bin/java
~/projects/work/metabase $ 

dpsutton19:06:05

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

dpsutton19:06:20

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)

dpsutton19:06:27

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

dpsutton19:06:43

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

dpsutton19:06:52

might be the default java at the time you launched emacs

dpsutton19:06:09

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.

practicalli-johnny18:06:04

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)

practicalli-johnny18:06:53

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) https://github.com/practicalli/clojure-deps-edn/blob/live/deps.edn#L118

Drew Verlee18:06:05

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

practicalli-johnny20:06:44

Depending on the environment, it may also be possible to set the java.runtime.version=17 or other version of Java in a system.properties 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. https://practical.li/clojure-web-services/app-servers/java-system-properties.html

đź‘Ť 1
practicalli-johnny20:06:41

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. https://practical.li/spacemacs/clojure-projects/project-configuration.html). 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