Fork me on GitHub
Noah Bogart15:08:46

this is foolish of me but i’ve forgotten and can’t seem to make it work: how do i disable the :refer :all lint for clojure.test and then stop marking deftest and is as unresolved symbols?

Noah Bogart15:08:07

if it matters, i’m using the #lsp clj-kondo integration instead of relying on clj-kondo directly

Noah Bogart15:08:05

clj-kondo --lint "$(clojure -Spath)" --dependencies --parallel --copy-configs doesn’t make them go away


@nbtheduke This should work:

(ns foo
  {:clj-kondo/config '{:linters {:refer-all {:exclude [clojure.test]}}}}
  (:require [clojure.test :refer :all]))

(deftest foobar
  (is (= 1 2)))


There should be no unresolved symbols at all, it works out of the box


At least with clj-kondo + flycheck, no idea about lsp

Noah Bogart15:08:07

i’m not sure what I’m doing wrong, then, thanks


Are you using any other namespaces with :refer :all?

Noah Bogart15:08:42

i’ll keep poking at it


yeah, that should "just work"


Can you post this code? I'll try it locally

Noah Bogart15:08:17

this is a completely fresh, untouched library template from #deps-new, created with clojure -Tnew lib :name io.github.noahtheduke/datalog

Noah Bogart15:08:01

i can open a new github repo with this but i’ve not actually written any code yet lol


can you tell me how to install that tool

Noah Bogart15:08:48

clojure -Ttools install com.github.seancorfield/deps-new '{:git/tag "v0.1.0" :git/sha "089d868"}' :as new


@nbtheduke From a clean slate:

[email protected] /tmp/datalog $ clj-kondo --lint "$(clojure -Spath)"  --dependencies --parallel --copy-configs
[email protected] /tmp/datalog $ clj-kondo --lint test
test/noahtheduke/datalog_test.clj:2:34: warning: use alias or :refer [deftest is testing]
test/noahtheduke/datalog_test.clj:3:41: warning: use alias or :refer


Going to try lsp now


Looks normal to me:


(well, I'm using the linting from clj-kondo itself, not lsp)

Noah Bogart15:08:45

Hmmmmm I don’t know what I broke but I must have broken something. Thanks for verifying.


Perhaps @ericdallo knows more


ah yes, I can reproduce when I'm using the lsp linting instead of directly clj-kondo

👍 2

Some users already complained about this, and I never manage to reproduce successfully, not sure if it's something with clj-kondo cache or a source-path wrongly configured 😕


is there a simple repro?


it started working for me when I: 1) created a .lsp folder in the root of the project 2) removed the /tmp/ folder from the workspace (apparently it added that instead of the proper root) 3) deleted .clj-kondo/.cache 4) restarted the workspace 5) imported it from the proper root


1. clojure-lsp always create a .lsp folder after a success analyze, no need to create it


well, there wasn't one here


maybe because there was one in a higher dir?


so the project was not analyzed properly by clojure-lsp, the logs or the log to client should say that


it depends on what was the project root


sent by lsp-mode (configured by user)


yes, anyway fixing that fixed the problem for me


could you confirm your project root is configured properly @nbtheduke?


if clojure-lsp doesn't scan the project properly, it will both log to clojure-lsp log and send a message to client which will print something like Classpath lookup failed....

Noah Bogart16:08:11

"workspaceFolders": [
            "uri": "file:///Users/noah/Personal/datalog/test/noahtheduke",
            "name": "/Users/noah/Personal/datalog/test"
            "uri": "file:///Users/noah/Personal/datalog/src/noahtheduke",
            "name": "/Users/noah/Personal/datalog/src"
            "uri": "file:///Users/noah/Personal/datalog",
            "name": "/Users/noah/Personal"
            "uri": "file:///Users/noah/.vim",
            "name": "/Users/noah"

Noah Bogart16:08:56

that’s what vim sent to clojure-lsp

Noah Bogart16:08:24

hmm, lsp log:

2021-08-23T16:03:49.865Z UnknownHost INFO [clojure-lsp.source-paths:134] - Automatically resolved source-paths from deps.edn: #{"src" "resources" "test"}
2021-08-23T16:03:50.339Z UnknownHost INFO [clojure-lsp.crawler:133] - Analyzing source paths for project root /Users/noah/Personal/datalog
2021-08-23T16:03:50.346Z UnknownHost INFO [clojure-lsp.crawler:77] - Paths analyzed, took 0.006113346 secs. Caching for next startups...
2021-08-23T16:03:50.346Z UnknownHost DEBUG [clojure-lsp.server:?] - :initialize 500ms
2021-08-23T16:03:50.347Z UnknownHost INFO [clojure-lsp.kondo:64] - Linting whole project files took 1ms
2021-08-23T16:03:50.356Z UnknownHost INFO [clojure-lsp.server:350] - Initialized!
2021-08-23T16:03:50.356Z UnknownHost DEBUG [clojure-lsp.server:?] - :initialized 0ms
2021-08-23T16:03:50.361Z UnknownHost DEBUG [clojure-lsp.server:?] - :didOpen 4ms
2021-08-23T16:03:52.362Z UnknownHost DEBUG [clojure-lsp.server:?] - :semanticTokensFull 1ms
2021-08-23T16:03:55.146Z UnknownHost ERROR [clojure-lsp.server:?] -  192
                          java.util.concurrent.ForkJoinPool.runWorker 1594
                               java.util.concurrent.ForkJoinPool.scan 1656
             java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec 1020
                             java.util.concurrent.ForkJoinTask.doExec  290
              java.util.concurrent.CompletableFuture$AsyncSupply.exec 1692
               java.util.concurrent.CompletableFuture$ 1700
                  clojure-lsp.server.LSPTextDocumentService/reify/get                 server.clj:  139
                                       clojure-lsp.handlers/did-close               handlers.clj:   69
                        clojure-lsp.feature.file-management/did-close        file_management.clj:  180
                                     clojure-lsp.shared/uri->filename                 shared.clj:  123
                                          clojure.string/starts-with?                 string.clj:  364

2021-08-23T16:03:55.148Z UnknownHost DEBUG [clojure-lsp.server:?] - :didClose 1ms
2021-08-23T16:03:55.216Z UnknownHost DEBUG [clojure-lsp.server:?] - :didOpen 2ms
2021-08-23T16:03:57.220Z UnknownHost DEBUG [clojure-lsp.server:?] - :semanticTokensFull 0ms


sounds like a bug on recent introduced didClose


even so, not related with your issue

👍 2
Noah Bogart16:08:24

is there another way to determine the project root for lsp?


yes, the serverInfo command should return a project-root-uri


Calva and emacs already have handful commands to get that using that custom method

Noah Bogart16:08:52

:project-root-uri "file:///Users/noah/Personal/datalog"


is that the correct project root ?

Noah Bogart16:08:22

that’s where the deps.edn is, yeah.


could you try removing both .lsp/sqlite.db and .clj-kondo/.cache?


it'd be even better if you try one after the other


try first clj-kodno/.cache

Noah Bogart16:08:57

oops, did both and it seems to have resolved itself


np, is it working properly now?


what I think it's the issue:


clojure-lsp call clj-kondo 3 (independent from errors) times: 1. during init, after get the project classpath, to get external analysis (jars), calling clj-kondo passing the whole classpath (excluding project source-paths) 2. during init, after 1., to analyze only project source-paths 3. after any file change, running for a single file, but not important for this isue What I suspect is that, 1. doesn't run properly, but 2. runs fine, persisting a .clj-kondo/cache with only cache for project, not containing external deps


well, if you have only 2, then the above issue shouldn't have happened, since clj-kondo already has a built-in cache for clojure.test


but if 1 lints clojure.test not correctly then there will be some invalid cache analysis fo clojure.test, which is more likely to cause the issue


yeah, I think it's related with old cache or something like that if you manage to repro again, let us know @nbtheduke

☝️ 2

it would have been interesting indeed to inspect the contents of .clj-kondo/.cache after this happened

☝️ 2
Noah Bogart17:08:14

I’ll keep an eye out and if I see it again, I’ll post it!


Thanks, it's something that happens from time to time, the first report I saw of this was on Calva back on Feb/2020! So it'd be really nice if we manage to fix it somehow