Fork me on GitHub
#clj-kondo
<
2020-07-04
>
futurile16:07:31

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?

borkdude16:07:11

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

borkdude16:07:30

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

borkdude16:07:16

that doesn't look right

borkdude16:07:57

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

borkdude16:07:11

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

borkdude16:07:40

also the cache-dir looks weird.

borkdude16:07:08

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

borkdude16:07:06

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

futurile16:07:17

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

slimslenderslacks19:07:25

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)

futurile16:07:11

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

👍 3