Fork me on GitHub
#clj-kondo
<
2021-05-13
>
ericdallo13:05:43

@U04V15CAJ 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?

borkdude13:05:26

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

ericdallo13:05:10

Got it, I'll follow with that so

ericdallo14:05:30

@U04V15CAJ 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

ericdallo14:05:25

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

ericdallo14:05:20

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

borkdude14:05:41

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

๐Ÿ˜† 3
borkdude14:05:03

Oh btw, that line is correct

borkdude14:05:11

It just means it searches from the current directory upwards

borkdude14:05:26

I misread it for user.home

borkdude15:05:46

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

borkdude15:05:09

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

borkdude15:05:46

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

ericdallo15:05:44

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?

borkdude15:05:22

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

ericdallo15:05:10

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

ericdallo15:05:36

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

ericdallo15:05:44

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

borkdude15:05:08

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

ericdallo15:05:00

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

borkdude15:05:53

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

ericdallo15:05:36

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

borkdude15:05:06

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

borkdude15:05:24

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

ericdallo15:05:58

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

ericdallo15:05:19

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

borkdude15:05:42

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

ericdallo15:05:07

yeah, that's I agree ๐Ÿ™‚

ericdallo15:05:35

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

ericdallo15:05:39

thanks for the help ๐Ÿ˜„

borkdude15:05:08

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 ;)

ericdallo15:05:37

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

borkdude15:05:15

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

ericdallo15:05:39

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?)

borkdude15:05:35

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

borkdude15:05:11

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

ericdallo15:05:25

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

borkdude15:05:40

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

borkdude15:05:16

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

ericdallo15:05:25

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

borkdude15:05:13

I think that is the better thing to do

ericdallo15:05:53

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

ericdallo15:05:27

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

borkdude15:05:28

so different projects can use different versions

๐Ÿ‘ 3
borkdude15:05:34

with a global config that wouldn't work anymore

ericdallo16:05:44

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!