Fork me on GitHub
#lsp
<
2022-12-11
>
Martynas Maciulevičius13:12:33

I used - in my library name and when I try to jump to the source in that dependency LSP expects that I'll use _ in the filename. What can I do about it? Does it mean that I can't use - in repository names? Sometimes it jumps to some files, but other times it expects _ in the same project. Weird. For instance I have analyzer.clj and core.clj. I can jump to analyzer.clj but not core.clj source file. If I use CIDER to jump into the source then it works.

ericdallo13:12:06

I'm not aware of a bug like that, and the project-root name should not affect anything, is it possible to create a simple repro where I can try?

Martynas Maciulevičius13:12:09

It's also possible that it's a bug of my nvim. I'll try to make a repro.

👍 1
Martynas Maciulevičius13:12:41

Try this project: https://github.com/Invertisment/reprochildproj I added a readme It's very weird but the bug is different this time. This time it doesn't load one of two namespaces.

Martynas Maciulevičius13:12:28

Also please disregard the test-bb task, it creates a JVM process and it's not correct.

ericdallo13:12:11

From the readme, is that related to repl?

ericdallo13:12:38

LSP has nothing related with REPL, it uses static analysis

Martynas Maciulevičius13:12:40

I don't think so, but I always start a REPL.

Martynas Maciulevičius13:12:58

Yes, I think REPL isn't related.

ericdallo13:12:11

so, what's the exact lsp issue? the readme mentions loading in repl

ericdallo13:12:58

anyway, I get the issue form readme on emacs + cider:

Could not find namespace: com.github.invertisment.repro-parentproj.core

Martynas Maciulevičius13:12:01

I confused everything. I can't jump into the analyzer.clj using LSP. And REPL can't load it too.

ericdallo13:12:03

the repl is another thing, probably related with the deps not being available in bb.edn, only on deps.edn

Martynas Maciulevičius13:12:04

But I can jump into core.cljc

ericdallo13:12:39

I can repro the find-definition issue for analyzer, let me take a closer look

Martynas Maciulevičius13:12:41

I used bb.edn only to launch the repl task. So the process should exist but it should not do anything

ericdallo13:12:22

the repl issue is that: your com.github.invertisment/repro-parentproj dep comes from deps.edn, when you start a bb repl, it won't check your deps.edn, but your bb.edn

ericdallo13:12:29

and there is no com.github.invertisment/repro-parentproj dep there, so bb won't know about that

ericdallo13:12:09

if you start a clojure repl, it should work though

ericdallo13:12:15

the issue on the find definition of analyzer is that the code is invalid:

(ns com.github.invertisment.repro-parentproj.analyzer)

(defn hello []
  (println "hey") ;; missing a ) here

Martynas Maciulevičius13:12:00

I'll try to fix it and try again. I was typing too fast then.

Martynas Maciulevičius13:12:03

This time it works. Not sure what's the issue with my other project then.

ericdallo14:12:52

yeah, I'd say 50% of fixing a issue is finding a way to repro 😅 , sometimes it's hard, but without reproing is not easy to understand how to fix it or if it's indeed a issue

Martynas Maciulevičius14:12:30

In my other repository the issue is that with LSP I have several namespaces in one directory and when I jump into core.cljc then the file is blank. And then when I jump into function's source then it also can't find it. But REPL finds it because it loads it and runs it. But this happens only for one file in the same folder.

ericdallo14:12:15

maybe some file with same name or something in the classpath?

Martynas Maciulevičius14:12:48

(ns neil-proj.gitlab-dep
  (:require [io.gitlab.invertisment.____________.analyzer :as q]
            [io.gitlab.invertisment.____________.core :as qq] ;; blank file when navigated via LSP
            [io.gitlab.invertisment.____________.path :as qqq]
            [clojure.tools.build.api :as tools-build])) ;; this one is to test that some other source project works

(defn a []
  (qq/analyze-paths nil nil) ;; this code works via REPL but I can't LSP-jump there
  #_(tools-build/jar))
Maybe there is a core.cljc somewhere else, but it's full path though

Martynas Maciulevičius14:12:54

But when I jump into analyzer then in the bottom of the screen I see this path:

~/.gitlibs/libs/io.gitlab.invertisment/xxx-xxx/dd6aa966d5b8965400a7490c5c52c6d64d8fb232/src/io/gitlab/invertisment/xxx_xxx/analyzer.cljc
And the core has this path:
~/.gitlibs/libs/io.gitlab.invertisment/xxx-xxx/689d541bdbc59cc6c05c8cb7f099e2a53630cf58/src/clojure/io/gitlab/invertisment/xxx_xxx/core.cljc
So for some reason the commit hash is different (initially I thought that difference between xxx_xxx and xxx-xxx is the bug but hash choice for a file probably is the actual bug)

ericdallo14:12:04

are both namespaces (not the filename) equal?

Martynas Maciulevičius14:12:32

All three namespaces are different, they contain code

ericdallo14:12:00

I mean, the namespace name (ns foo.bar)

Martynas Maciulevičius14:12:47

> ls | xargs -L 1 head -n 1

(ns io.gitlab.invertisment.------------.analyzer
(ns io.gitlab.invertisment.------------.core
(ns io.gitlab.invertisment.------------.path

Martynas Maciulevičius15:12:25

Actually I can share the namespace names, there is nothing there:

(ns neil-proj.gitlab-dep
  (:require [io.gitlab.invertisment.query-scopes.analyzer :as q]
            [io.gitlab.invertisment.query-scopes.core :as qq] ;; blank file when navigated via LSP
            [io.gitlab.invertisment.query-scopes.path :as qqq]
            [clojure.tools.build.api :as tools-build]))

(defn a []
  (qq/analyze-paths nil nil) ;; this code works via REPL
  #_(tools-build/jar))
And the files:
[martin@qwe query_scopes HEAD]$ ls | xargs -L 1 head -n 1
(ns io.gitlab.invertisment.query-scopes.analyzer
(ns io.gitlab.invertisment.query-scopes.core
(ns io.gitlab.invertisment.query-scopes.path
[martin@qwe query_scopes HEAD]$ ls
analyzer.cljc  core.cljc  path.cljc
[martin@qwe query_scopes HEAD]$

Martynas Maciulevičius15:12:18

I deleted project's .clj-kondo directory and it jumps now.

Martynas Maciulevičius15:12:31

Unfortunately I deleted it and I can't send it to you 😕

Martynas Maciulevičius15:12:00

I think it should be something with previous commits of the project. Maybe I tried to load it while the project wasn't fully working yet. I was testing things out and moving files around.

ericdallo15:12:26

that sounds like git branch switchs and file watch was not properly working. LSP file watch is a feature that the editor keeps listening for the project files, and when they change outside the editor the editor tells the lsp server that those files were created/changed/deleted, so the server can update analysis of the project correctly. This is mostly a feature to avoid the need of restarting your editor or lsp server to re-analyze the project, only for consistency.

Martynas Maciulevičius15:12:32

But I have been restarting my editor (and with it LSP) and REPL multiple times :thinking_face: And it persisted until I deleted that directory.

ericdallo15:12:03

Hum, weird, we don't have cache issues for a long time after we fixed some known bugs, again, if you can find a way to repro LMK, but usually is hard to repro cache issues 😔

Martynas Maciulevičius15:12:33

I think for now I won't be doing a repro 😄 There is one and it could be played around to remove and add remote project's sources. And that may be enough.

Martynas Maciulevičius15:12:49

But I don't want to look for it more for now

👍 1
robertfw19:12:33

I just updated my install of clojure-lsp via the install script, and have run into an error after the update. I thought I'd check here if I was missing something obvious before filing an issue, I had a look but didn't see anything related.

robertfw@orion:~$ clojure-lsp --version
clojure-lsp 2022.05.03-12.35.40
clj-kondo 2022.04.26-SNAPSHOT

robertfw@orion:~$ sudo bash < <(curl -s )
Downloading  to /tmp/tmp.IfoNRy4tk4
Moving /usr/local/bin/clojure-lsp to /usr/local/bin/clojure-lsp.old
Successfully installed clojure-lsp in /usr/local/bin

robertfw@orion:~$ clojure-lsp --version
clojure-lsp: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by clojure-lsp)
clojure-lsp: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by clojure-lsp)

robertfw19:12:47

I tried the nightly release using the pinned comment, same issue

borkdude19:12:48

@UG00LE5TN Try the static release @UKFSJSM38 I've had the same issue with clj-kondo. The issue was that the build environment used a too new version of glibc. I downgraded the build image again and this "fixed it"

borkdude20:12:07

Also I install the static binary in the clj-kondo install script by default now

borkdude20:12:46

@UG00LE5TN You can install the static image with --static

robertfw20:12:00

thanks @U04V15CAJ! @UKFSJSM38 let me know if you'd like to open an issue to track this

ericdallo20:12:11

please do

👍 1
ericdallo20:12:59

@U04V15CAJ Do you have the commit so I can do the same to clojure-lsp?

borkdude20:12:03

what's funny is that this started happening when building on github actions too. I've had the similar issue on circleci

borkdude20:12:33

@UKFSJSM38 I guess your issue is that you're using ubuntu-latest

borkdude20:12:45

which you should not do, use a fixed version of ubuntu and not the newest

borkdude20:12:30

I made --static the default now in the install script too for linux amd64

borkdude20:12:39

Just see latest commits in the clj-kondo repo

ericdallo20:12:30

The script should be fixed @UG00LE5TN LMK otherwise

borkdude20:12:12

@UKFSJSM38 I think you forgot that you also have linux aarch64 which doesn't have a static binary

ericdallo20:12:41

oh yeah, forgot about that

borkdude20:12:46

also you should probably update the brew formula to use the static binary on amd64 (only that again)

ericdallo20:12:23

will do thanks

borkdude20:12:00

I just did another release for this in the end since some github actions also downloaded the amd64 dynamic binary and started failing

ericdallo20:12:50

Yeah, I think I'll do a new one just to avoid that kind of problem

borkdude20:12:36

you might want to double-check what ldd --version returns in the 20.04 runners

borkdude20:12:40

if it says 2.31 it's good

borkdude20:12:14

@UG00LE5TN What does ldd --version return on your system?

robertfw20:12:41

@U04V15CAJ

robertfw@orion:~$ ldd --version
ldd (Ubuntu GLIBC 2.31-0ubuntu9.9) 2.31
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.

👍 1