Fork me on GitHub
#clj-kondo
<
2020-12-15
>
Sam Stowers05:12:57

Hey! Beginner here with a possibly dumb question. Trying to get clj-kondo going in emacs, but flycheck says the executable isn't found. Have already checked that clj-kondo is present in the emacs path etc - any thoughts on how I might get it working? Here's what M-x flycheck-verify-setup says:

Syntax checkers for buffer core.clj in clojure-mode:

  clj-kondo-edn
    - may enable: Automatically disabled!
    - predicate:  nil
    - executable: Not found

  clj-kondo-clj
    - may enable: Automatically disabled!
    - predicate:  t
    - executable: Not found

Flycheck Mode is disabled.  Use C-u M-x flycheck-disable-checker to
enable disabled checkers.

--------------------

Flycheck version: 31
Emacs version:    28.0.50
System:           x86_64-pc-linux-gnu
Window system:    x

Sam Stowers05:12:25

Tried this, didn't work unfortunately. Just says the checker doesn't exist, or no selected checker

Sam Stowers05:12:47

Or "no syntax checkers disabled in this buffer"

Sam Stowers05:12:34

Interestingly, if I M-x flycheck-disable-checker on clj-kondo-clj, it then shows up in the C-u M-x command, but I still can't enable it from there.

Sam Stowers05:12:21

My apologies if I'm missing something obvious - I'm learning both Emacs and Clojure at the moment

sogaiu05:12:12

i noticed you mentioned that clj-kondo is in the emacs path. would you mind elaborating on that point? i am not sure i understood it.

sogaiu05:12:26

may be you were alluding to the somewhat common issue that occurs when emacs is started not from a terminal but from some kind of launcher or other means that doesn't happen to have an appropriate value for PATH.

Sam Stowers06:12:37

The installation docs mentioned an issue that could happen if the $PATH in Emacs was different from the $PATH in a regular terminal. But I checked and the paths seemed identical

sogaiu06:12:38

thanks for the clarfication. so you did the M-x shell thing followed by echo $PATH i guess are you able to invoke clj-kondo via the sort-of-terminal buffer associated with invoking M-x shell?

sogaiu07:12:42

so i'm revisting when i had what seemed like a similar issue before: https://clojurians-log.clojureverse.org/clj-kondo/2019-10-24 borkdude mentioned that doing M-x flycheck-compile might be useful -- i think it may give more detailed output.

sogaiu07:12:10

oh, i see "Flycheck Mode is disabled" in your initial output. have you done M-x global-flycheck-mode and/or is there a (global-flycheck-mode) somewhere in your emacs initialization setup?

sogaiu07:12:59

i guess so as flycheck-verify-setup might otherwise not show up

Sam Stowers07:12:17

I haven't yet. Will try that after a good night's sleep lol. Thanks for your assistance

sogaiu07:12:22

hope you rest well!

tvaughan09:12:09

This is the error you’ll see if you’re using flycheck over TRAMP, https://github.com/flycheck/flycheck/pull/1842, FYI

Sam Stowers21:12:03

@U0P7ZBZCK Thanks for the reply, but I'm not working on a remote host, and I don't think I'm using TRAMP.

Sam Stowers21:12:32

I guess I could try using M-x flycheck-set-checker-executable, but I'm not sure how to find the relevant executables

Sam Stowers21:12:58

flycheck-default-executable-find doesn't seem to be exposed to M-x

sogaiu22:12:43

re: finding the appropriate executable -- for clj-kondo it should just be the full path to the clj-kondo binary. if you want to try out flycheck-default-executable-find, the following may work: * M-: * (flycheck-default-executable-find "clj-kondo") * RET then proceed through the interaction

Sam Stowers01:12:31

Tried calling executable-find, it says there's a Lisp error.

Sam Stowers01:12:57

Update: solved

Sam Stowers21:12:54

Thanks @U04V15CAJ, but my echo $PATH output is identical when run in a regular terminal and run in M-x shell, so I don't think this is my issue. Unless there are other environmental variables that could be affecting this

borkdude21:12:02

So when you type clj-kondo in the shell it works?

dakra10:12:49

Is the path correct if you M-x getenv -> "PATH"?

Sam Stowers01:12:30

...no, actually, seems to be missing node - which could be why it's not finding clj-kondo since I installed it with Node. That's interesting, I had assumed M-x echo $PATH would show the Emacs path

Sam Stowers01:12:57

I'll try installing the tool @U04V15CAJ recommended, will see if that fixes the problem

sogaiu01:12:28

have you considered installing clj-kondo some other way?

Sam Stowers01:12:59

@UG1C3AD5Z If this doesn't work will try that

👍 3
Sam Stowers01:12:31

It's working! Thanks for the assistance @UG1C3AD5Z @U04V15CAJ @UFAP0C8KU 🙂

Sam Stowers01:12:25

Turns out I had exec-path-from-shell already installed as part of the emacs starter template I was using, but it lacked a necessary line in init.el

sogaiu01:12:36

congratulations!

sogaiu01:12:57

so perhaps for the installed-via-node pathway, exec-path-from-shell is important

👍 3
sogaiu01:12:59

thanks for sharing the solution! fwiw, i also use some linux and i don't install from node, nor do i use exec-path-from-shell, so i was finding it quite curious.