👋 I’m trying out mise (https://mise.jdx.dev/) for a bunch of things, e.g. setting java version per project—does anyone know how to get it to work w/ Emacs + CIDER for cider-jack-in-clj etc.?
I’m running mise in a terminal outsider of emacs—one of the things that mise seems to to in this case is to set JAVA_HOME, which is fine if I start the REPL from the terminal and connect or start emacs from the terminal
I’ve not found a great way to get that picked up semi-automatically form within running emacs session
I can ofc:
• echo $JAVA_HOME | pbcopy
• and in emacs (setenv "JAVA_HOME" …)
which seems to work but wondering if anyone knows / can think of a better way?
(BTW there seems to be mise emacs package but doesn’t seem to work or need to dig deeper to try to actually understand it 🤷)
I've been using mise with Emacs under Linux (run at startup via emacs --daemon) for a while now without issues.
By way of example, here's the stack for one of the projects I'm working on, using Emacs for all of the various dev(ops) workflows:
awscli 2.14.5
clojure 1.11.1.1273
java temurin-17.0.9+9
nodejs 18.16.0
terraform 1.5.4
babashka 1.12.196
A couple of observations/tips that may or may not be relevant to the particular issues you've been having:
Ensure you are including: eval "$(/usr/bin/mise activate zsh --shims)" at the end of your .zshrc (or equivalent).
And are you using exec-path-from-shell package in Emacs? Here's what I have configured:
(use-package exec-path-from-shell
:ensure t
:demand t
:custom (exec-path-from-shell-variables
'(...
"JAVA_HOME"
"JAVA_OPTS"
"PATH"
...
))
:config
(exec-path-from-shell-initialize))
That will probably help things along.
Finally, in case it's relevant to the specifics above, I launch Emacs throughout the day via the following desktop entry:
[Desktop Entry]
Name=Emacs
GenericName=Text Editor
Comment=Edit text
MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++;
Exec=/usr/bin/bash --login -c "cd /usr/local/bin && emacsclient --alternate-editor= --create-frame"
Icon=emacs
Type=Application
Terminal=false
Categories=Development;TextEditor;
StartupWMClass=Emacs
Keywords=Text;Editor;
I don't use any dedicated mise packages within my Emacs config and everything just works as one would expect given the .tool-versions specification of the project I happen to be working on.@codeasone thanks a lot for detailing your setup, will try out mise again tomorrow with your pointers, maybe will have better luck 😉
I have a doubt, so I am in a project, and I have a namespsace cson.cson which is src/cson/cson.clj
and a namespace cson.parse which is src/cson/parse.clj
but the namespace in nRepl is user
shall I need to switch it?
switch it to waht?
how can I use functions of the namespace in cson.cson and cson.parse in the repl?
again I get a similar error, I inserted line 15 in repl, but when I evaluate it, I get error
C-c M-n M-n runs the command cider-repl-set-ns (found in cider-mode-map), which
is an interactive native-compiled Lisp function in 'cider-repl.el'.
It is bound to C-c M-n n and C-c M-n M-n.
(cider-repl-set-ns NS)
Switch the namespace of the REPL buffer to NS.
If called from a cljc buffer act on both the Clojure and ClojureScript REPL
if there are more than one REPL present. If invoked in a REPL buffer the
command will prompt for the name of the namespace to switch to.
You could also try:
user> (in-ns 'main)
#namespace[main]
main> The vars live in namespaces, and in order to access them you need to either be in the namespace they're in, or refer to them by their namespace.
hth
So basically I have to load the namespace in the nRepl
so if I have 3 namespaces, and I want to test their functions, I have to always load them before trying them out
You could also try using "rich comment forms" directly in the source file and evaluating them there without touching the REPL buffer
I see, okay