clj-kondo

https://github.com/clj-kondo/clj-kondo
ericdallo 2021-05-13T13:40:11.454Z

About https://github.com/clj-kondo/clj-kondo/issues/1281 ๐Ÿงต

ericdallo 2021-05-13T13:40:43.454200Z

@borkdude should we create a new flag since if we change the --copy-configs to accept a file, the old empty --copy-configs will stop working, right?

borkdude 2021-05-13T13:41:26.454600Z

without anything or nil we just use the previous stategy, I'd say: the local .clj-kondo dir

ericdallo 2021-05-13T13:42:10.454800Z

Got it, I'll follow with that so

ericdallo 2021-05-13T14:02:30.455Z

@borkdude it seems there is a place that still treat the ~/.clj-kondo as a global config dir: https://github.com/clj-kondo/clj-kondo/blob/master/src/clj_kondo/core.clj#L102

ericdallo 2021-05-13T14:03:25.455300Z

If we change here to check the XDG/.config dir as well, it would behave the same and fix the issue, right?

ericdallo 2021-05-13T14:04:20.455500Z

so the ~/.clj-kondo has indeed a special handling, I thought clj-kondo was using it because of a recursive call from the project dir

borkdude 2021-05-13T14:04:41.455700Z

oh damn, I don't know where that comes from

๐Ÿ˜† 1
ericdallo 2021-05-13T14:06:12.456Z

I found that checking why it needs to cfg-dir be non-nil: https://github.com/clj-kondo/clj-kondo/blob/master/src/clj_kondo/impl/core.clj#L241

borkdude 2021-05-13T14:58:03.456300Z

Oh btw, that line is correct

borkdude 2021-05-13T14:58:11.456500Z

It just means it searches from the current directory upwards

borkdude 2021-05-13T14:58:26.456700Z

I misread it for user.home

borkdude 2021-05-13T15:00:46.456900Z

if we add the home-config dir as a fallback there, I'm not sure what consequences that has...

borkdude 2021-05-13T15:01:09.457100Z

that's why I would prefer to have an explicit copy-configs destination instead (and use the local dir as the default one)

borkdude 2021-05-13T15:01:46.457300Z

else it would populate .config/clj-kondo/.cache with data which is probably against the rules of XDG_CONFIG, etc

ericdallo 2021-05-13T15:06:44.457600Z

Alright, but that is exactly what I intend to have after I pass the --copy-configs .config/clj-kondo , the cache properly added to that dir, right?

borkdude 2021-05-13T15:07:22.457800Z

configs = stuff exported by libraries, cache = transit files in .cache, those are two totally different things

ericdallo 2021-05-13T15:08:10.458Z

I see, so I think there are 2 issues here haha

ericdallo 2021-05-13T15:08:36.458200Z

because without a clj-kondo .cache folder, things like refered midje macros and things like that doesn't work

ericdallo 2021-05-13T15:08:44.458400Z

because there is no .cache and clj-kondo doesn't persists it on .config/clj-kondo only if threre is a ~/.clj-kondo

borkdude 2021-05-13T15:09:08.458700Z

you can control the cache dir with --cache-dir

ericdallo 2021-05-13T15:10:00.458900Z

hum, so I can --copy-configs ~/.config/clj-kondo --cache-dir ~/.config/clj-kondo on clojure-lsp?

borkdude 2021-05-13T15:10:53.459100Z

you could, but I would not do this by default for all users of course

ericdallo 2021-05-13T15:11:36.459300Z

why? otherwise only if users manually create local .clj-kondo dir or on home things will work like refered symbols

borkdude 2021-05-13T15:12:06.459500Z

yes, they should create that then. or lsp should create it, I have suggested this before

borkdude 2021-05-13T15:12:24.459700Z

user should just read the manual how clj-kondo works, it's all documented pretty well

ericdallo 2021-05-13T15:12:58.459900Z

it is, my point is just that is not IDEish, imagine cursive ask for users create a .cursive dir for things work ๐Ÿ˜•

ericdallo 2021-05-13T15:13:19.460100Z

I just wanna make most things work by default and leave the corner cases optional for users configure it

borkdude 2021-05-13T15:13:42.460300Z

yeah, so because clojure-lsp is an IDEish thing, it could make that decision I guess. clj-kondo doesn't know where the root of your project is because all it sees is a filename

ericdallo 2021-05-13T15:14:07.460500Z

yeah, that's I agree ๐Ÿ™‚

ericdallo 2021-05-13T15:14:35.460700Z

alright, I already implemented on clj-kondo that support as we discussed, I'll make some tests with clojure-lsp to make sure it makes sense

ericdallo 2021-05-13T15:14:39.460900Z

thanks for the help ๐Ÿ˜„

borkdude 2021-05-13T15:15:49.461100Z

:)

borkdude 2021-05-13T15:20:08.461300Z

maybe clj-kondo could borrow some of the IDE-ish stuff from lsp in the future, e.g. how to decide where the root of a project is, but so far clojure-lsp is doing a great job of lifting this burden from clj-kondo itself ;)

ericdallo 2021-05-13T15:25:37.461600Z

hahah yeah, that could make things easier for clojure-lsp and maybe open doors for other libs that use clj-kondo

borkdude 2021-05-13T15:26:15.461800Z

the reason I've refrained from this so far is that I don't like tools that automatically create garbage on my machine

ericdallo 2021-05-13T15:30:39.462Z

yeah, it's sounds good to avoid those things, but as we need a .cache somewhere for things work, we need to choose create a .clj-kondo for the project or a global one (which seems less intrusive as it's one time for all projects?)

borkdude 2021-05-13T15:32:35.462200Z

I'm not a big fan of a global caching dir that multiple projects together use, as this can give clashes with namespaces from different projects

borkdude 2021-05-13T15:33:11.462500Z

adding to the confusion. I think people should just invest 5 minutes to see how it works. this saves everybody time and headaches

ericdallo 2021-05-13T15:36:25.462700Z

clojure-lsp could create a .clj-kondo in the project root, but it would not be enough since the :config-paths config are on ~/.config/clj-kondo and it expects that lib configs would be copied to there, not to the local clj-kondo dir

borkdude 2021-05-13T15:37:40.463200Z

I don't think it makes sense to copy the "configs" to ~/.config/clj-kondo either, since they are specific to the project's dependencies. Just check them into the project's git repo

borkdude 2021-05-13T15:38:16.463400Z

Note that one giant blob of global configs will make clj-kondo slower as well, as it has to parse all these configs every time it's started

ericdallo 2021-05-13T15:39:25.463700Z

the issue is that we would need to add :config-paths for every project manually, but yeah seems more specific

borkdude 2021-05-13T15:40:13.463900Z

I think that is the better thing to do

ericdallo 2021-05-13T15:40:53.464100Z

what happens with lib hook updates? they would be replaced on local clj-kondo as well?

borkdude 2021-05-13T15:41:02.464300Z

yes

ericdallo 2021-05-13T15:41:27.464500Z

alright, I'll give a try to check how it works!

borkdude 2021-05-13T15:41:28.464700Z

so different projects can use different versions

๐Ÿ‘ 1
borkdude 2021-05-13T15:41:34.464900Z

with a global config that wouldn't work anymore

ericdallo 2021-05-13T16:01:44.465200Z

so, I seems to work if the project has a .clj-kondo with the config-paths, and it sounds the cacnonical way to do that, I'll let you know if works for eveybody, thanks!

borkdude 2021-05-13T16:02:24.465400Z

:thumbsup: