Fork me on GitHub

Hi, I have updated Malli to the latest version and clj-kondo now reports “insufficient input” (that map in image for example). This is the schema: [:map {:closed true} [:name string?] [:description string?] [:created-by {:optional true} [:maybe string?]] [:id {:optional true} int?]]


This is kondo’s config


Can you make a clj-kondo only repro that I can clone locally so I don’t have to copy or type code from screenshots? Then I’ll have a look later today

👍 1

I don’t get this error in a new project, so I won’t even upload it. The definition in malli-types-clj/config.edn is same for both projects. I tried to delete clj-kondo .cache and also .lsp from the original project, no luck. Unfortunately I can’t share the original project and it is really complex, so there are a lot of variables. Do you have any idea where I could look?


If you can't make a repro, I can't help you fix it, unfortunately, but maybe you can downgrade malli and ask in #CLDK6MFMK - seems like a downstream problem

👍 1

Interesting, the downgrade didn’t help. So I thought to delete .clj-kondo/metosin and it worked (with old and new version as well).

Noah Bogart15:03:47

Hook question: I have a macro that acts like def but takes a namespaced symbol and strips the namespace from it and then uses def to make a var: (defrule style/some-var ...) macroexpands to (simplified): (def some-var ...). i wrote a simple hook for this, and for some reason, clj-kondo/clojure-lsp seem to treat the whole block now as a single unit instead of parsing/analyzing each sub expression:

(ns hooks.noahtheduke.splint.rules
    [clj-kondo.hooks-api :as api]))

(defn defrule-hook
  [{:keys [node]}]
  (let [[rule-name & body] (next (:children node))
        node (api/list-node (list* (api/token-node 'def)
                                   (api/token-node (symbol (name (api/sexpr rule-name))))
    {:node node}))

Noah Bogart15:03:10

that's a demonstration of "show docs" called on ->violation displaying the docs for this whole top-level form

Noah Bogart15:03:32

is there a better way to do this?

Noah Bogart15:03:39

if I switch the hook to (api/token-node 'defrule) instead of 'def , then go to definition and show docs work but the whole form has an "unresolved symbol: sorted-rules-require" error


Why write such a macro in the first place? Maybe ^:dev name could also work?

😂 1

regardless of that, let's take a look at your hook code

Noah Bogart15:03:15

🤷 it's the api i've decided on, it's shortest and simplest and communicates the intentions


This is wrong:

(list* (api/token-node 'def)
                                   (api/token-node (symbol (name (api/sexpr rule-name))))


list* expects the last thing to be a collection of nodes

Noah Bogart15:03:03

I have "body" at the end, doesn't that expand properly?


I recommend using (println node) before you return it, and then execute this on the command line


then you will see what I mean probably


oh yes, body, I missed that


I think you can fix stuff by preserving more original locations via the metadata

👍 1

with with-meta or vary-meta

Noah Bogart15:03:02

(defn defrule-hook
  [{:keys [node]}]
  (let [[defrule rule-name & body] (:children node)
        new-node (api/list-node
                   (list* (with-meta (api/token-node 'def) (meta defrule))
                          (with-meta (api/token-node (symbol (name (api/sexpr rule-name))))
                                     (meta rule-name))
    {:node (with-meta new-node (meta node))}))

Noah Bogart15:03:05

there we go, that works

👍 1
Noah Bogart15:03:31

thank you for the help

Patrick Brown21:03:42

I’ve got a clj-kondo/clojure-lsp issue with emacs. It stopped working. I did something, what I do not know. All components work in isolation, just not together. Deleting and reinstalling did not help. How do I go about troubleshooting this? I’m a little lost in where to start digging. Any advice is appreciated.


Is it possible to create a repro repository?


Are you running clojure-lsp or do you also run clj-kondo separately somehow?

Patrick Brown21:03:47

I could make a repro repo, but I think the issue is much deeper. I’ve gone into the repro repo I sent you when I had issues with defn-spec. It doesn’t work. I’ve messed something up at the global/emacs config level or something else deeper in the well than the project. That’s why I’m a little lost as to how I should continue


the first thing I usually recommend people to try it clj-kondo on the command line


are you able to run this:

clj-kondo --lint src


and maybe clojure-lsp as a command line tool:

clojure-lsp diagnostics

Patrick Brown21:03:43

It gives me an output similar to linting filled with how not perfect my code is


in your emacs config folder, can you maybe do this: mv elpa elpa.bak


and then restart your emacs

Patrick Brown21:03:30

I’m assuming that’s the same as moving my straight repos folder.?


I guess so. This reminds me. #CPABC1H61 has a minimal emacs config to debug things


you could try that one. @UKFSJSM38 knows where it is probably


Yes, and if it's a problem with not even starting clojure-lsp check this

Patrick Brown21:03:23

Lsp starts, the server info gives me a clojure-lsp version of 2.27, and lsp of 2.17, the classpath settings is nil.

Patrick Brown21:03:38

scratch that, clj-kondo of 2.17


I think both versions are wrong, they should be dates

Patrick Brown22:03:30

Yes, I was referring to the dates, feb 17th and 27th

👍 1
Patrick Brown22:03:56

I can’t copy the server info, because I’m not sure how to open it in a proper buffer.


go to *Messages*


You can just click the mini buffer or do what borkdude said

Patrick Brown22:03:53

Duh, not a proud moment

 {:dependency-scheme "jar",
  :show-docs-arity-on-same-line? true,
  :text-document-sync-kind nil,
  :source-paths nil,
  :source-aliases nil,
  :cljfmt-config-path ".cljfmt.edn",
  :document-formatting? true,
  :document-range-formatting? true},
 :project-root-uri "file:///home/pat/m",
 :port "NREPL only available on :debug profile (`bb debug-cli`)",
 :project-settings {},
 :server-version "2023.02.27-13.12.12",
 :clj-kondo-version "2023.02.17",
 :log-path "/tmp/clojure-lsp.3157811663365747466.out",
 :classpath-settings nil}
 {:dependency-scheme "jar",
  :show-docs-arity-on-same-line? true,
  :text-document-sync-kind nil,
  :source-paths nil,
  :source-aliases nil,
  :cljfmt-config-path ".cljfmt.edn",
  :document-formatting? true,
  :document-range-formatting? true},
 :project-root-uri "file:///home/pat/m",
 :port "NREPL only available on :debug profile (`bb debug-cli`)",
 :project-settings {},
 :server-version "2023.02.27-13.12.12",
 :clj-kondo-version "2023.02.17",
 :log-path "/tmp/clojure-lsp.3157811663365747466.out",
 :classpath-settings nil}


Everything looks good, check if project-root-uri really matches your project root

Patrick Brown22:03:23

It does. I’m doing a proper full on reinstall of my emacs deps as borkdude outlined. It feels like I must have messed something up with my emacs config, but for the life of my I don’t remember touching it.


@U036UJBDM5G I don't want to sound patronizing, but do you save your emacs config in version control? I even save my entire elpa directory in version control since 2013 haha

Patrick Brown22:03:34

I have all my configs, but I git ignore my autodownloaded deps.


I've had too many weird issues before that and decided to do it the blunt way

Patrick Brown22:03:05

If that turns out to be my problem, I may jump on that ship.


I'm not using straight.el etc, it may have better version management

Patrick Brown22:03:06

It supposed to immutable like nix, but all I know is I just add :straight t to my use-package and it works.

👍 1

I've had issues with .elc files before, when I removed those, emacs re-compiled the .el files and suddenly a problem was fixed

Patrick Brown22:03:42

The same has happened with straight many times. This time I deleted andything with clojure in the name and it didn’t help, but it costs nothing to go further.


@UKFSJSM38 what was the minimal emacs project to install clojure-lsp / lsp-mode again? it helped me find the weird delay problem at the time


ah yes, @U036UJBDM5G you could try that file instead of init.el and see if you can get things working

Patrick Brown22:03:05

Well, no dice on the rebuilding emacs with fresh packages, and no dice on the minimal config.


is clojure-lsp on your path, can emacs find it?


else lsp-mode will download it anyway right

Patrick Brown22:03:50

I appreciate you both for coming out. HMU if you think of anything. I’m a frustrated dog, so maybe my dog and I should go outside for a walk with the beautiful weather we’re having. When I come back, I’m installing clojure-lsp and clj-kondo from source again, and launching with a custom command. That worked in the past. clojure lsp is there it just doesn’t seem to link with emacs, emacs knows it’s there, it knows my classpath. The problem lies somewhere in the middle.

👍 2

A simple project usually helps a lot debug such issues, I recommend testing with my project

Patrick Brown23:03:00

@U04V15CAJ @UKFSJSM38 Thanks for all the help. After no luck with building from source. I went nuclear rm -rfed the f out of everything I could find, then I reinstalled things just like the readme brought my custom config back in piece by piece. I wish I had something smart to say… I’m just happy I can use my tooling again. Side note, I’ve grown way to reliant on tooling to be comfortable. Keep up the good work. I appreciate the quality things you make.


Thanks! Glad it works now :)