This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-01-30
Channels
- # announcements (20)
- # asami (26)
- # babashka (10)
- # babashka-sci-dev (18)
- # beginners (81)
- # biff (6)
- # calva (6)
- # cider (1)
- # clerk (1)
- # clj-kondo (34)
- # clojure (50)
- # clojure-belgium (1)
- # clojure-berlin (6)
- # clojure-europe (20)
- # clojure-nl (1)
- # clojure-norway (22)
- # clojure-uk (2)
- # clojurescript (1)
- # clr (4)
- # community-development (3)
- # data-science (8)
- # datomic (3)
- # gratitude (1)
- # honeysql (6)
- # instaparse (2)
- # jobs (1)
- # jobs-discuss (13)
- # kaocha (7)
- # london-clojurians (1)
- # lsp (6)
- # malli (8)
- # matcher-combinators (9)
- # missionary (3)
- # nbb (8)
- # off-topic (20)
- # pathom (16)
- # polylith (2)
- # practicalli (3)
- # rdf (1)
- # re-frame (7)
- # reagent (3)
- # releases (2)
- # reveal (6)
- # rewrite-clj (22)
- # shadow-cljs (64)
- # tools-build (7)
- # xtdb (13)
Howdy. I'm using "let-def" instead of "let" to debug some things. Using emacs/lsp/clj-kondo I get warnings (which I find visually hard to ignore) around my "let-def" ... I tried
$ cat ~/.clj-kondo/config.edn
{:lint-as {myspace/let-def clojure.core/let } }
but I still get warnings. Does lsp use a different config location??oh you have it in your home config? this is not the right location. It should be:
~/.config/clj-kondo/config.edn
Humm.... I wonder if I'm out of date.
$ /home/linuxbrew/.linuxbrew/Cellar/clj-kondo/2022.11.02/bin/clj-kondo --lint migrate/migrate_bt_code.clj
migrate/migrate_bt_code.clj:45:13: error: Unresolved symbol: cols
migrate/migrate_bt_code.clj:46:9: error: Unresolved symbol: nxt
migrate/migrate_bt_code.clj:47:9: error: Unresolved symbol: authorrity-id-bch
migrate/migrate_bt_code.clj:48:9: error: Unresolved symbol: authority-description-bch
migrate/migrate_bt_code.clj:49:9: error: Unresolved symbol: authority-id
...
those are the let-def bindingscan you make a fully standalone git repo with a repro? then I'll have a look in an hour or so
https://github.com/bherrmann7/let-def-issue fyi, command line clj-kondo only reports 1 issue - yet emacs now shows 2... joy. but anyway, the single issue is in the repo.
and then:
$ clj-kondo --lint m/my_boat.clj
linting took 26ms, errors: 0, warnings: 0
if you're using clojure-lsp, you might have to restart your session (once you put the config in the right place, I've seen two issues during this conversation!): lsp-workspace-restart
Humm.....
$ clojure-lsp --version
clojure-lsp 2022.05.03-12.35.40
clj-kondo 2022.04.26-SNAPSHOT
upgrading wouldn't hurt, but after that it should work. let me know if you run into any other stuff
~/let-def-issue$ clojure-lsp --version
clojure-lsp 2023.01.26-11.08.16
clj-kondo 2023.01.20
~/let-def-issue$ emacs m/my_boat.clj
# emacs shows 2 errors in file
~/let-def-issue$ clj-kondo --lint m/my_boat.clj
m/my_boat.clj:10:11: error: Unresolved symbol: puma
linting took 10ms, errors: 1, warnings: 0
~/let-def-issue$ rm -rf .clj-kondo/
~/let-def-issue$ clj-kondo --lint m/my_boat.clj
linting took 10ms, errors: 0, warnings: 0
~/let-def-issue$
seems like emacs/clojure-lsp is not using ~/.clj-kondo/config.edn
Sorry, I somehow missed that I had the config.edn file in the wrong directory. FYI: It seems clj-kondo reads from it though.
$ strace clj-kondo --lint m/my_boat.clj 2>&1 |grep --color config.edn
stat("/home/bob.herrmann/.clj-kondo/config.edn", {st_mode=S_IFREG|0664, st_size=133, ...}) = 0
open("/home/bob.herrmann/.clj-kondo/config.edn", O_RDONLY|O_LARGEFILE) = 4
lstat("/home/bob.herrmann/.clj-kondo/config.edn", {st_mode=S_IFREG|0664, st_size=133, ...}) = 0
but then I if I move the config (as you suggest)
$ strace clj-kondo --lint m/my_boat.clj 2>&1 |grep --color config.edn
stat("/home/bob.herrmann/.config/clj-kondo/config.edn", {st_mode=S_IFREG|0664, st_size=133, ...}) = 0
open("/home/bob.herrmann/.config/clj-kondo/config.edn", O_RDONLY|O_LARGEFILE) = 4
It uses that also.
And! emacs/clojure-lsp seemed to like the latter one! (like you said.) Woo Hoo!!
THANKS 👍 🔥 👍 🔥@U0502D2GL It reads that file because it's the first .clj-kondo/config.edn
it comes across in a parent directory. If you would have that config in $project/.clj-kondo/config
it wouldn't have searched higher up.
Great, thanks. It is working great. And I'm very very happy. Seems irrational to be so excited about such a small thing, but man it kicks butt.
After, what, 2 years of using clj-kondo, this is my first non-understood (potentially) false positive. Cheers for such a great, unobtrusive tool!!! With that said, here's what's puzzling me:
Sure, thanks a lot!!
(defn foo
([^clojure.lang.Symbol var-sym]
var-sym)
([^String a-ns
^String a-name
& {:keys [debug?]}] ; remove both this & keys ...
(str a-ns a-name debug?))) ; and `debug?` ... and error goes away
(foo 'inc)
Might have appeared around the time we switched to Clojure 1.11.
Yes, but I use it in many areas 🙂 Thanks a lot Michiel!
You can put this in your config to repair the type inference:
{:linters {:type-mismatch
{:namespaces
{dude
{foo
{:arities {1 {:args [:symbol]}
:varargs {:args [:string :string {:op :rest :spec :any}]}}}}}}}}
Yes, this does it - thanks a lot for the workaround. I'll keep an eye on release notes in the future to know when to remove the workaround. 🙂