Fork me on GitHub
#clojure-nl
<
2020-08-24
>
Kevin07:08:09

Morning 👋

Mno11:08:55

Btw my emacs (prelude) keeps freezing on me for some reason, is this a very common issue? I haven’t found a way to fix it, or exactly what’s triggering it.

Mno11:08:43

If I get frustrated enough I’ll ask around en the #emacs channel. 😅

Kevin12:08:35

I used to have that with Spacemacs / Doom. Then I switched to my own configuration and haven't had that issue since

Kevin12:08:41

No idea what caused it

yannvahalewyn13:08:28

@kevin.van.rooijen Just switched from my own config to Doom. Why did you switch back?

Kevin13:08:34

Doom was really slow in my experience, and froze every now and then. I also didn't like the whole commandline thing

Kevin13:08:33

With use-package, Straight.el, and commander, it's pretty easy to set something up. But on the other hand I've used Emacs for a long time

Kevin13:08:08

I also just like having full control over Emacs

borkdude13:08:21

The only time I have emacs hell freezing over with prelude is when visiting a server with dired in tramp mode. Not all the time, but sometimes.

borkdude13:08:04

The VSCode ssh plugin is so devil-ish nice, all your (linter) plugins will work on the remote machine as if you're working locally. I wish we had that for emacs

tvaughan15:08:07

I use tramp to access a linux container that contains all of my devtools. Except for a few oddities everything works fairly seamlessly

borkdude15:08:27

I had to hack my zsh scripts because it doesn't understand its prompt or something

borkdude15:08:32

But even then it was glitchy

borkdude15:08:46

Also clj-kondo doesn't work over tramp

tvaughan15:08:12

I use clj-kondo inside a linux container

tvaughan15:08:24

How does it not work?

tvaughan15:08:47

One of the oddities is that the running container needs to be named "localhost" otherwise cider gets very confused

borkdude15:08:42

@U0P7ZBZCK where does clj-kondo run, locally or in the container, when editing a file?

tvaughan15:08:04

Runs in the container

borkdude15:08:20

but your emacs runs on your local computer?

tvaughan15:08:05

For example, you could clone this https://gitlab.com/tvaughan/kibit-runner, run make shell, open /opt/kibit-runner inside the running container (I use https://github.com/masasam/emacs-counsel-tramp), and then run cider-jack-in

tvaughan15:08:56

From there just make sure to use tramp to open the clojure source code, don't open locally on your laptop

tvaughan15:08:29

e.g. from an open tramp dired buffer

borkdude15:08:37

yes, kibit runs as part of your JVM process, but clj-kondo does not. So once more, just to make sure: does the clj-kondo process run in your container, did you explicitly install it there?

borkdude15:08:58

Just want to make sure we're talking about the same thing

tvaughan16:08:32

clj-kondo runs in the container. The project contains a deps.edn which includes clj-kondo. Dependencies are downloaded as needed (and stored in a persistent volume for use on subsequent runs). I can run clj-kondo via make kondo (probably should change that to make clj-kondo) or flycheck-clj-kondo, again both inside the running container with emacs running on my laptop

borkdude16:08:24

@U0P7ZBZCK I'm interested in your setup, because that's exactly the part that didn't work for me. How does your emacs run locally, but flycheck-clj-kondo isn't?

borkdude17:08:05

e.g. how do you connect your local emacs / flycheck to kibit-runner? flycheck has to connect to your docker container via ssh somehow?

borkdude17:08:56

I guess in the kibit-runner example it works via cider-nrepl probably. How do you do it for clj-kondo?

tvaughan17:08:06

I use counsel-tramp to connect emacs on my laptop (macOS) to the running container (also running on my laptop). Don't use ssh

borkdude17:08:51

ok, that's fine, you can find files that way, but how does the flycheck integration work?

tvaughan17:08:59

For some reason emacs does't see the clj-kondo executable (not on my laptop, not in a running container over tramp, nowhere) so flycheck-clj-kondo isn't working right now. I just upgraded to emacs 27 so maybe I broke something, dunno know

tvaughan17:08:23

There's nothing to do to get it to work. Provide the executable can be found 😞

borkdude17:08:47

By default in tramp mode flycheck is disabled

borkdude17:08:12

And flycheck-clj-kondo will execute your local clj-kondo executable. So I still don't understand what you are doing

borkdude17:08:18

This does work, but clj-kondo will only see your local buffer via stdin, not your config files on the other machine

borkdude17:08:30

So I'm wondering all the time if you didn't just see that

borkdude17:08:37

or if you are in fact doing something else

tvaughan17:08:35

> And flycheck-clj-kondo will execute your local clj-kondo executable. If the buffer was opened over tramp then the clj-kondo executable in the running container should be used. The same way running cider-jack-in or evaluating expressions in the buffer are run/evaluated in the running container

borkdude17:08:48

> If the buffer was opened over tramp then the clj-kondo executable in the running container should be used. Should be, as in, that would be the correct implementation, or "that's what it's like now"?

borkdude17:08:37

cider works over a (networked) REPL, of course that's evaluated in whatever you are connected to

tvaughan17:08:46

That's how I understand tramp to work

borkdude17:08:54

clj-kondo isn't tied to your REPL

tvaughan17:08:22

I use cider over the same connection to the running container. counsel-tramp simply uses docker exec

borkdude17:08:29

Well, if that were the case, I would be very happy

tvaughan17:08:36

I understand clj-kondo isn't tied to a repl

borkdude17:08:07

Maybe for Docker it's different. My use case is actually running it on another "real" machine.

tvaughan17:08:45

tramp should work the same regardless, over ssh or docker exec

borkdude18:08:31

So I open a file /ssh:[email protected]/~/dev/foobar/src/foobar.clj and then edit. Flycheck by default disables all linters. I enable flycheck-mode. Clj-kondo is executed, but it's my local one, linting only what flycheck gives it via stdin

borkdude18:08:49

ok, let me try

tvaughan18:08:18

Except clj-kondo should be installed "on the remote machine"

tvaughan18:08:42

The goal in my case is that everyone should be running the same version of clj-kondo, everything is tested and deployed using this version, and one change is required to upgrade everywhere

borkdude18:08:56

You can easily see with flycheck-compile and then clj-kondo-clj that it doesn't do what you expect.

borkdude18:08:10

-*- mode: compilation; default-directory: "/ssh:[email protected]:/home/borkdude/test/" -*-
Compilation started at Mon Aug 24 20:09:27

/Users/borkdude/Dropbox/bin/clj-kondo --lint - --lang clj --cache < /ssh\:borkdude\@eetvoorjeleven.nu\:/home/borkdude/test/foo.clj
/bin/sh: 2: cannot open /ssh:[email protected]:/home/borkdude/test/foo.clj: No such file

Compilation exited abnormally with code 2 at Mon Aug 24 20:09:29

borkdude18:08:34

As you can see it starts my local clj-kondo in /Users/borkdude/Dropbox/bin/clj-kondo while linting a file over ssh

borkdude18:08:58

So what I wish it would do is invoke clj-kondo on the remote machine and return the output back to the local emacs

borkdude18:08:08

But that's not the case right now

tvaughan18:08:28

I think something like (setq flycheck-executable-find #'tramp-handle-executable-find) is needed, https://github.com/flycheck/flycheck/blob/master/flycheck.el#L489 Although it didn't "just work" for me

borkdude18:08:00

aha.

funcall: Symbol’s function definition is void: tramp-handle-executable-find

tvaughan18:08:30

I did require tramp though :thinking_face:

tvaughan18:08:47

I think that function is no longer provided. I'll have to look-up the newer alternative

tvaughan22:08:05

This works for me:

(defun tvaughan/executable-find (command)
  (executable-find command t))
(setq flycheck-executable-find #'tvaughan/executable-find)

tvaughan22:08:42

clj-kondo is not installed on my laptop. clj-kondo was installed inside the running container, e.g. npm install --global clj-kondo

tvaughan22:08:11

Unfortunately I'm getting other errors:

Suspicious state from syntax checker clj-kondo-clj: Flycheck checker clj-kondo-clj returned non-zero exit code 127, but its output contained no errors: 
Try installing a more recent version of clj-kondo-clj, and please open a bug report if the issue persists in the latest release.  Thanks!
Error while checking syntax automatically: (error "Process flycheck-clj-kondo-clj not running")

tvaughan22:08:02

I'm not familiar with this error message. I installed the latest clj-kondo using npm. I'm not sure what the problem is

tvaughan23:08:08

clj-kondo runs just fine on the command-line, fyi

tvaughan23:08:33

Also, which is required by executable-find. which is not installed by default in some default container images, like Fedora 32

borkdude18:08:09

I'm getting: > Error while checking syntax automatically: (wrong-number-of-arguments (1 . 1) 2)

Mno14:08:56

Dang well then hopefully it’s just because my machine is over 10 years old and it’ll fix itself if I free up some ram