clj-kondo

https://github.com/clj-kondo/clj-kondo
futurile 2020-07-04T16:05:31.118900Z

I'm trying to use clj-kondo with the docker file. I can't seem to get it to use the cache directory. I'm running this command:

sudo docker run -v $PWD/src:/src -v $HOME/.m2:$HOME/.m2 -v $HOME/.clj-kondo:$PWD/.clj-kondo borkdude/clj-kondo clj-kondo --cache-dir=$HOME/.clj-kondo --lint "$(lein classpath)" 
The way I'm reading the project setup section, I'm expecting to see it generate files in the project's .clj-kondo directory but it's not creating anything in there. Am I running the command incorrectly or have I misunderstood?

borkdude 2020-07-04T16:13:11.119300Z

The way you mount files into the docker container looks a bit inconsistent maybe

borkdude 2020-07-04T16:13:30.119600Z

-v $HOME/.clj-kondo:$PWD/.clj-kondo

borkdude 2020-07-04T16:14:16.120400Z

that doesn't look right

borkdude 2020-07-04T16:14:57.121100Z

should probably be -v $PWD/.clj-kondo:/.clj-kondo or something?

borkdude 2020-07-04T16:15:11.121500Z

since you also mount: -v $PWD/src:/src

borkdude 2020-07-04T16:15:40.121700Z

also the cache-dir looks weird.

borkdude 2020-07-04T16:16:08.122100Z

Note that $HOME gets expanded in your shell before it goes into docker, at least I think so

borkdude 2020-07-04T16:17:06.122600Z

Might be best to just bash into the container and look around

futurile 2020-07-04T16:19:17.123100Z

makes sense - I'll try and attach to the container and poke around

slimslenderslacks 2020-07-04T19:16:25.129900Z

I would think something like

docker run -v $HOME:$HOME borkdude/clj-kondo clj-kondo --cache-dir=$PWD/.clj-kondo --lint "$(lein classpath)"
should work as long as PWD is somewhere in HOME. Since lein classpath evaluates outside of docker, that classpath string has to end up making sense to clj-kondo running inside docker. I think you might be able to add -w $PWD to set the working dir, and then not have to set --cache-dir since .clj-kondo is the default. So
docker run -v $HOME:$HOME -w $PWD borkdude/clj-kondo clj-kondo --lint "$(lein classpath)"
When I ran this on my project, I found that it gave me the same results as if I ran without docker (including running the hooks in my local .clj-kondo)

futurile 2020-07-05T16:04:11.130Z

@slimslenderslacks thank-you! that worked, wrote to my cache dir. It makes sense, I've got it checking my source properly now I believe.

👍 1