Fork me on GitHub
#lsp
<
2023-10-31
>
emccue01:10:44

Opening thread here on implicit suggestion from @UEENNMX0T

👍 1
emccue01:10:06

I figure those who know are in both places though

phill10:10:03

The immediate dependencies of (dependencies referred to in project.clj with {:type :pom}), i.e., the immediate dependencies of "bundles", should count as direct dependencies for this purpose

ericdallo10:10:00

That would require access kondo analysis during a hook right @U04V15CAJ ?that's something we from nubank are missing as well since we tried to created custom linters that check analysis

borkdude10:10:14

check my comments in clj-kondo about this topic

borkdude10:10:37

I don't think this issue is related to hooks at all, you could just walk the final analysis but the real problem is to find out what namespace belongs to which dependency

ericdallo11:10:28

ah didn't see it was a message forwarded, makes sense, sounds like a interesting custom linter for lsp

ericdallo11:10:41

my problem was something else, when you want to reg-finding! in a hook, have access to analysis to know more about the code, but it's another discussion :)

ericdallo11:10:01

@U3JH98J4R feel free to create a clojure-lsp feature request as github issue

borkdude11:10:56

@UKFSJSM38 there is a function called ns-analysis in the API, there's also api/resolve

ericdallo11:10:19

oh, we missed that, will take a look

ericdallo11:10:13

clojure-lsp Released clojure-lsp 2023.10.30-16.25.41 with fixes and performance improvements! • General ◦ Bump clj-kondo to 2023.10.21-20231022.204832-4. ◦ Fix move-to-let/expand-let bug for multi-arity functions https://github.com/clojure-lsp/clojure-lsp/issues/1283 ◦ Fix :dependency-scheme setting for .java files from jars https://github.com/clojure-lsp/clojure-lsp/issues/1653 ◦ Bump graalvm to 21. ◦ Improve overall performance using GraalVM 21 PGO (Profile-Guided Optimizations). ◦ Extract the responsibility for merging clj-depend config https://github.com/clojure-lsp/clojure-lsp/issues/1265 ◦ Support passing configurations to clj-depend via CLI https://github.com/clojure-lsp/clojure-lsp/issues/1694 ◦ Bump clj-depend to 0.9.2 ◦ Performance: remove keyword-usages elements from external analysis as they are not used for any feature and for big projects may affect memory. https://github.com/clojure-lsp/clojure-lsp/issues/1700 • Editor • New paredit refactorings: ▪︎ forward-slurp ▪︎ forward-barf ▪︎ backward-slurp ▪︎ backward-barf ▪︎ raise ▪︎ kill ◦ Improve rename to avoid internal errors and show proper error messages. https://github.com/clojure-lsp/clojure-lsp/issues/1691 ◦ Exclude unused-public-vars when inside a comment block. ◦ Add :analysis-summary field to serverInfo command to get information about project for performance analysis. ◦ Add :analysis settings, with options to disable specific analysis for better performance on huge projects. https://github.com/clojure-lsp/clojure-lsp/issues/1700 Main highlights: • Performance: Less analysis saved in memory and cache affecting big projects • Performance: new oracle graalvm 21 with pgo instrument which considerable improve overall performance (LMK if any weird crashes with the binary) • Feature: The new paredit refactorings are part of clojure-lsp-intellij work, but it's intended to be used on multiple editors without custom paredit plugins Thank you clojurists-together and all for the support! Happy code!

🎉 13
clojure-lsp 3
❤️ 1
Noah Bogart12:10:09

Are the paredit refactorings exposed as code actions?

ericdallo12:10:14

For now no as I thought would be too much to expose those, it's possible, but I think most if not all the time, you already want a keybinding or call that directly, not via code actions right?

👍 1
ericdallo12:10:06

for example, on emacs lsp-mode there is a lsp-clojure-forward-barf command which calls that command directly

Noah Bogart12:10:38

Oh i see, i was conflating code actions and the extra commands. That’s great. I’ll make sure to add these new commands to coc-clojure

ericdallo12:10:03

cool, thanks!

Carsten Behring13:10:30

I am using clojure-lsp inside Docker and have a problme with teh classpath scan. I see an error of

023-10-31T13:50:15.994Z  INFO [clojure-lsp.classpath:103] - Finding classpath via `clojure -A:test:dev -Spath`
2023-10-31T13:50:15.996Z  ERROR [clojure-lsp.classpath:130] - Error while looking up classpath info in /workspaces/try-py. Error: Cannot run program "clojure" (in directory "/workspaces/try-py"): error=2, No such file or directory
I am very sure that Clojure is in my $PATH. How can I further debug this ?

Carsten Behring14:10:17

I might want to add that clojure is in an unusual place, but I have now setup everything so that is is found. For interactive and non-interactive shells.

Carsten Behring15:10:59

Could we maybe add a debug logging of the env here: (or at least the 'PATH' in env ?) https://github.com/clojure-lsp/clojure-lsp/blob/8efc7ebfdd319fbef86a75fc2c8f965d725fa712/lib/src/clojure_lsp/classpath.clj#L108 This would help to check for errors. I suspect that in some form the PATH in my console and the "PATH" used in he clojure.java.shell/sh are not the same for some reason.

Carsten Behring15:10:42

I got it working by symlinking clojure additionaly into /usr/local/bin Its original place is /home/vscode/.asdf/shims/clojure ( /home/vscode/.asdf/shims is in PATH of user vscode when logged in)

ericdallo15:10:42

adding that debug log was added to my backlog this week, I'll work on that since we've been having issues on intellij because of weird PATHs as well

ericdallo15:10:41

but you are correct, the PATH in java.shell is weird sometimes, and doesn't match anything like the PATH of current SHELL... @U04V15CAJ did you face anything similar when implementing babashka.process?

ericdallo16:10:38

@U7CAHM72M just pushed a debug log for that, you can use a nightly build on #clojure-lsp-builds it should be available in some mins

Carsten Behring16:10:59

Interesting ... ERROR [clojure-lsp.classpath:133] - Error while looking up classpath info in /workspaces/try-py. Error: Cannot run program "clojure" (in directory "/workspaces/try-py"): error=2, No such file or directory 2023-10-31T16:32:49.235Z DEBUG [clojure-lsp.classpath:134] - Env used for classpath lookup: SHELL: null PATH: null

ericdallo16:10:50

let me double check I didn't do a mistake

ericdallo16:10:14

my bad, made another commit fixing it

Carsten Behring17:10:20

here we go: SHELL: /bin/bash PATH: /bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin

Carsten Behring17:10:34

a very minimal PATH

Carsten Behring17:10:13

In my shell I have PATH="/usr/local/python/current/bin:/usr/local/py-utils/bin:/usr/local/share/nvm/current/bin:/usr/local/sdkman/bin:/usr/local/sdkman/candidates/java/current/bin:/usr/local/sdkman/candidates/gradle/current/bin:/usr/local/sdkman/candidates/maven/current/bin:/usr/local/sdkman/candidates/ant/current/bin:/usr/lib/jvm/msopenjdk-current/bin:/home/vscode/.asdf/bin:/usr/local/python/current/bin:/usr/local/py-utils/bin:/usr/local/share/nvm/current/bin:/usr/local/sdkman/bin:/usr/local/sdkman/candidates/java/current/bin:/usr/local/sdkman/candidates/gradle/current/bin:/usr/local/sdkman/candidates/maven/current/bin:/usr/local/sdkman/candidates/ant/current/bin:/usr/lib/jvm/msopenjdk-current/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/vscode/.asdf/shims:/home/vscode/.local/bin"

ericdallo17:10:14

yep, that's what I found so far with intellij users as well, kind of blocked from there

ericdallo17:10:39

is like System/getenv from the process is not checking the shell for some reason

ericdallo17:10:41

I wish there was something we could do from clojure side to fix that, but I can't see it

Carsten Behring20:10:27

Am I right that it is NOT the nREPL process which calls System/getenv but clojure-lsp?

ericdallo20:10:56

yes, there's nothing related with repl

Carsten Behring20:10:15

and what starts clojure-lsp ? Emacs ?

ericdallo20:10:29

editors spawn the server process

Carsten Behring20:10:03

how does it even do that in my case (in Docker )...? Via ssh clojure-lsp ? My emacs is local, but clojure-lsp runs in Docker...

ericdallo20:10:38

yeah, maybe that's the problem, it will use the PATH from your docker

ericdallo20:10:21

you can spawn clojure-lsp outside editor, since it has custom lint features, like clojure-lsp diagnostics

ericdallo20:10:33

but you may face the same issue when it needs the classpath

Carsten Behring20:10:52

For me it does work with specifying the full clojure command in lsp settings I, just wanted to avoid that.

ericdallo20:10:11

yeah, I agree it's not ideal but for that to work the clojure-lsp process that your docker container spawns should have the same PATH env from your host

Carsten Behring20:10:45

hmm. No the same then host, the docker user has it correct... I was looking in lsp-mode.el for the code which starts clojure-lsp , but I have no clue if I am on the righ track.

Carsten Behring20:10:01

I am not even sure, if it is indeed lsp-mode.el which starts lsp-clojure process.. it looks like it though.

ericdallo20:10:57

if you use on emacs, it is

ericdallo20:10:28

make-process is the one that spawns the process

ericdallo20:10:42

could you try from your docker container run clojure-lsp diagnostics and check if you face the same issue? (you need to be on your project root to run that)

Carsten Behring21:10:46

Thats why I think "emacs" starts clojure-lsp in a cerati whay, which sets the PATH to this very limited dirs. Inside my Docker teh PATH for user vscode is very different.

Carsten Behring21:10:16

I found the reason for the path. When in a TRAMP buffer, the

(exex-path)
returns
(/bin /usr/bin /sbin /usr/sbin /usr/local/bin /usr/local/sbin /workspaces/try-py/)(/bin /usr/bin /sbin /usr/sbin /usr/local/bin /usr/local/sbin /workspaces/try-py/)
which seems to be the PATH when processes are started, at least by default

ericdallo12:11:57

yeah, makes sense

Carsten Behring08:11:55

Emacs seem to still follow a more "classic" approach to Linux file system organisations, which only has foreseen executables in certain places.

Carsten Behring10:11:45

@UKFSJSM38 I think there is something which could be done to find clojure-lsp via Emacs / TRAMP. Som code like this:

(custom-set-variables
 '(tramp-remote-path (quote (tramp-own-remote-path)) nil (tramp)))

(defun print-find-clojure-lsp ()
  (interactive)
  (message "exec-path: %s" (exec-path))
  (message "find-python: %s" (executable-find "clojure-lsp")))
does work. So there is a way from emacs to find clojure-lsp excutable taking the PATH from remote host into consideration.

Carsten Behring10:11:22

I am still not sure, if we talk about a bug here or missing / unclear documentation in case of "clojure-lsp on TRAMP". It seems at least that we have "unexpect / hard to debug" behaviour when "out-of-the-box" setup of clojure-lsp on TRAMP does not find clojure-lsp or even clojure executables, while the current user has them on the "path". The fact that TRAMP does not use the PATH variables "by-default" (but it uses some kind of "default" value for PATH, which in my view does not make a lot of sense) when launching commands was at least for me unexpected. I suggest at least to add here something in his direction. "When using clojure-lsp on a TRAMP connection, Emacs/clojure-lsp will try to launch clojure-lsp and clojure commands on the remote host. In case of those being in unusual folders (not `/usr/bin' , /usr/local/bin' ) this might fail, as TRAMP by default does not use / propagate the PATH variable of a remote user to launch executable, but its own default. This can be solved by hardcoding the full path to the clojure/clojure-lsp executable in the settings or by changing the TRAMP configuration of Emacs https://clojure-lsp.io/troubleshooting/

ericdallo13:11:23

Will do, thanks @U7CAHM72M, BTW https://github.com/clojure-lsp/clojure-lsp-intellij/blob/f8bb033aa8dc04de5d4524a7b3b176c2f821d9a3/src/main/clojure/com/github/clojure_lsp/intellij/server.clj#L52-L54 as well kind of related to this problem, but it seems to be a problem on the way launchers launch intellij not injecting any variable, I don't recommend it doing in other editors.

ericdallo13:11:09

One thing you can improve @U7CAHM72M is instead of changing classpath-cmd with the exact path, change the :env arg to add PATH to that, BTW I https://github.com/clojure-lsp/clojure-lsp/blob/b184ca6c9d12e28011ece4719ed2749defa5a766/lib/src/clojure_lsp/classpath.clj#L185-L195 to make it more clear how it works

Stig Brautaset20:10:54

I tried to bump my clojure-lsp flake today, but it failed with this error:

> unpacking source archive /nix/store/cmsh1mkx8x193dagjay32gffxp1qbhi4-d10vaqcl5bkwjv1aqsah0wlxi8n00wqk-source
       > source root is d10vaqcl5bkwjv1aqsah0wlxi8n00wqk-source
       > patching sources
       > Execution error (ExceptionInfo) at cljnix.utils/throw+ (utils.clj:22).
       > "Can't expand full sha" {:lib io.github.clojure/tools.build, :node {:git/url "", :tag "v0.9.6", :sha "8e78bcc"}}
(full error in 🧵)

ericdallo20:10:54

I bumped tools.build but for some reason the PR was not automatically opened bumping the deps.lock

👍 1
ericdallo12:11:28

sorry, that one sec took some hours, it should be fixed now

Stig Brautaset12:11:50

All good! Testing now...

Stig Brautaset12:11:23

It looks to pass 🙂

🎉 1