This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-09-26
Channels
- # announcements (2)
- # asami (2)
- # aws (34)
- # babashka (6)
- # beginners (9)
- # calva (76)
- # chlorine-clover (10)
- # circleci (5)
- # clj-kondo (2)
- # clojure (40)
- # clojure-australia (3)
- # clojure-europe (15)
- # clojurescript (39)
- # conjure (1)
- # core-async (4)
- # cursive (4)
- # datahike (1)
- # datomic (69)
- # figwheel-main (1)
- # graalvm (16)
- # honeysql (9)
- # hyperfiddle (2)
- # jobs-discuss (2)
- # lsp (36)
- # luminus (1)
- # malli (11)
- # off-topic (13)
- # pathom (1)
- # portal (1)
- # portkey (3)
- # reitit (25)
- # reveal (1)
- # rewrite-clj (5)
- # spacemacs (2)
- # sql (4)
- # vrac (90)
I have a package xx.yy.zz/ containing clj files. Now I want to rename the package to xx.yy.aa. However, after I “rename” with VSCode, the files in the xx.yy.zz, for example, xx.yy.zz.some_ns is still xx.yy.zz.some_ns instead of xx.yzz.aa.some_ns.
I just rename things manually. Unless there is a case where #lsp can help. It can with some things, I haven’t figured out what works and not so I often try with that first. 😃
LSP can help but we don't have this feature yet: https://github.com/clojure-lsp/clojure-lsp/issues/552
> You can rename namespaces via the ns form though Could you be more explicit on this?
you can hover over the foo.bar
here:
(ns foo.bar
...
..)
and call rename, it will rename all references + file nameNow that I have clojure-lsp and clj-kondo starting up successfully (thanks @ericdallo!) I’m cleaning up the warnings that arise. Most make perfect sense, but I seem to have a heisenwarning? I have a “placeholder” test file containing:
(ns race-and-improve.session-test
(:require [clojure.test :refer [deftest is]]))
(deftest simple-test
(is (= (+ 1 2) 3)))
When I start VSCode, this file is coloured orange to indicate that it contains warnings, and sure enough when I hover the mouse over it, the tooltip says “1 problem in this file”. But when I open the file, the warning disappears and the file is no longer coloured orange.
What might be causing this?When you say latest, you mean released, or waiting to be released? I’m running 2021.09.13-22.25.35 which I believe is the most up to date release?
it was fixed on master but not on latest release: https://github.com/clojure-lsp/clojure-lsp/issues/554 But I know you are probably using the master clojure-lsp
Ah! Snap. Thanks!
I haven’t switched to master yet - will do.
I’m curious, how would one use clojure-lsp’s master branch, instead of a release? Do you mean building clojure-lsp from the master branch yourself and pointing Calva to it?
Exactly. There are instructions on how to do so in the section “Using a Custom Clojure-lsp Native Binary” here: https://calva.io/clojure-lsp/
Thank you @UGC0NEP4Y, that’s very kind of you to say!
Thanks @U5KAD4W2E. I was just curious if there was some other method being used here that I was unaware of. I wrote those instructions in the docs for using a native binary 😄 - glad to know they are being used.
Also, I believe I came across your book once in a book store, and flipped through and was happy to see Clojure mentioned. Awesome coincidence to later chat with you here. 😃 (I just looked it up because of the above comment and remembered the cover.)
@ericdallo I’m running clojure-lsp 2021.09.30-15.28.01 but I’m still getting the same heisenwarning. Is it possible that I’m seeing a different problem from the one you fixed?
The warning I’m getting (now I’ve worked out how to see it - without making it disappear before I can!) is:
{
"resource": "/Users/paulbutcher/Projects/raceandimprove/race-and-improve/test/clj/race_and_improve/session_test.clj",
"owner": "_generated_diagnostic_collection_name_#0",
"code": "redefined-var",
"severity": 4,
"message": "redefined var #'race-and-improve.session-test/simple-test",
"source": "clj-kondo",
"startLineNumber": 4,
"startColumn": 1,
"endLineNumber": 4,
"endColumn": 1,
"tags": [
1
]
}
It’s the code I pasted above - a “placeholder” test file:
(ns race-and-improve.session-test
(:require [clojure.test :refer [deftest is]]))
(deftest simple-test
(is (= (+ 1 2) 3)))
The weird thing (to my mind) is that I see the warning when I open the project, but it disappears the instant I open the file.
The problem seems to be related to the “empty project.clj” problem that we hit earlier. Delete the project.clj file, and the problem doesn’t happen.
I have no idea why kondo is saying that var was already referred, I'll debug a little more
Thanks. I suspect that it’s the project.clj and deps.edn “fighting” somehow (because delete project.clj and it doesn’t happen).
Thanks. Although… The only reason I have the project.clj is to tell Heroku that I’m using Clojure. I’ve just done some digging, and there are other options I could use: https://devcenter.heroku.com/articles/buildpacks#setting-a-buildpack-on-an-application Perhaps the easiest approach would be to do something like that and just delete project.clj.
My suggestion about that is if even you need that project.clj, keep it "valid", like something like:
(defproject dummy "0.0.1")
To avoid bizarres issuesAs it happens, that is what I have in my “real” project (but I still have the heisenwarning)
Oh! Now I’m confused
This is what I have in my “real” project.clj:
; Unused - only here because the Heroku Clojure buildpack insists upon project.clj being present
(defproject org.example/sample "1.0.0"
:source-paths ["src/cljs" "src/cljc" "src/clj"])
And I have the heisenwarning
Hum, I confirmed that doesn't work indeed, but it does work if I change it to :
; Unused - only here because the Heroku Clojure buildpack insists upon project.clj being present
(defproject org.example/sample "1.0.0"
:source-paths ["src/cljs" "src/cljc" "src/clj"]
:test-paths ["test/clj"])
Thats … odd!
Apologies for having such a weird project config (blush!)
I think I’m going to experiment with an alternative way to get Heroku to use the Clojure buildpack and avoid this multiple fighting project definitions problem entirely.
(the empty project.clj also confuses Calva, so it would be good to lose it if I can)
This is turning into a yak-shave - Heroku’s Clojure buildpack refuses to run if it can’t find a project.clj 😞
-----> App not compatible with buildpack:
Could not find a 'project.clj' file! Please ensure it exists and is checked into Git.
I feel a pull request against the buildpack coming on..
yeah, I'm debugging clojure-lsp to see if I can fix that invalid warning, but even so, it makes sense a PR to heroku
Unsurprisingly, I guess, I’ve been beaten to it: https://github.com/raymcdermott/heroku-deps-build-pack
it seems that when you don't tell lein what are the test source-paths ,it uses the default test
so it tells to kondo to analyze these folders:
from project.clj
#{"src/cljs" "src/cljc" "src/clj" "test" "src/test/clojure"
from deps.edn
#{"test/clj" "src/clj"}
and this for some reason would scan the test/clj
2 times or somethingConfirmed the issue!
@U04V15CAJ TLDR: if you pass a folder and a file inside that same folder, kondo scan 2 times the same file emitting warnings like var already referred
. Ex:
Repro: https://github.com/paulbutcher/heisenwarning
$ clj-kondo --lint test test/clj/race_and_improve/session_test.clj
test/clj/race_and_improve/session_test.clj:4:1: warning: redefined var #'race-and-improve.session-test/simple-test
linting took 116ms, errors: 0, warnings: 1
it seems to me that kondo could be smart enough to know that ns was already analyzed
WDYT?