Fork me on GitHub
#lsp
<
2022-04-27
>
snoe22:04:24

@jacob.maine i tried running the profiler stuff in cli/dev from a repl to a debug-cli build and I couldn't require clojure-lsp.debug So i started splatting "dev" in various src-dirs in cli/build.clj until it worked. Not sure if I was building wrong or something was missing in there.

jacob.maine22:04:34

you mean clojure-lsp.debug?

👍 1
jacob.maine22:04:46

hmm… there isn’t anything special about how you should build. just make should work

jacob.maine22:04:56

fwiw, it works ok for me in emacs

snoe22:04:26

i wonder if cider / jack-in / user profile is doing something with dev. I just check again, and Could not locate ... clojure_lsp/debug.clj ... on classpath. unless i muck with that build file.

snoe22:04:45

I wonder if its because im connecting from a project that isnt clojure-lsp.

jacob.maine22:04:11

hmm… that seems likely. i’m not sure i’ve ever tried to require clojure-lsp namespaces from other projects

jacob.maine22:04:41

here’s a question… what the heck is an uberjar? i know it contains your code and clojure.core. but how does it handle code on other classpaths? are they bundled into it too?

snoe22:04:04

yeah it contains everything. strings clojure-lsp|grep "clojure_lsp/debug" shows it's not in the graal artifact unlike other namespaces.

jacob.maine22:04:34

oh, you’re using the native version? that’s even more mysterious to me than the uberjar version

jacob.maine22:04:04

fwiw, strings clojure-lsp|grep "clojure_lsp/debug" also suggests it’s not in the debug uberjar version

snoe22:04:46

Oh, and i see what we're doing differently too, if you launch lsp, you should be able (require 'clojure-lsp.debug) without evaling the namespace. (and fireplace chokes on eval if a file doesn't exist so i cant manually eval)

jacob.maine22:04:21

yeah, if i run (require 'clojure-lsp.debug) i also get an exception (unless i’ve previously evaled the namespace)

jacob.maine22:04:54

Could not locate clojure_lsp/debug__init.class, clojure_lsp/debug.clj or clojure_lsp/debug.cljc on classpath.

👆 1
snoe22:04:53

Hrm maybe @UKFSJSM38 can help include that src dir properly?

jacob.maine22:04:31

I was just going to ask… can you figure out which inclusion of the src dir fixed things?

jacob.maine22:04:33

I’m a little confused though… I thought the graal build was only for prod, not dev?

jacob.maine22:04:17

i’m just worried that including that src dir in the wrong place will force those libraries to get compiled into the prod executable, which i don’t think we want

snoe22:04:28

lol, I don't know either, I was just doing what worked as far as builds. My preference for dev was to use lein run originally. I added to both places in uber-aot but im not going to have time for awhile to track down if both or either are needed.

snoe22:04:11

I agree for release it shouldnt be there, i thought the extra-aliases :debug for debug-cli would only do it for dev builds.

jacob.maine22:04:39

i’m afraid i can’t help either, mostly because i’m pretty useless when it comes to understanding builds

jacob.maine23:04:37

although, this looks like it might be a straightforward change…

jacob.maine23:04:53

does this look roughly like what you did?

jacob.maine23:04:56

diff --git a/cli/build.clj b/cli/build.clj
index d1300505..ab7f9fff 100644
--- a/cli/build.clj
+++ b/cli/build.clj
@@ -48,11 +48,12 @@
   (clean opts)
   (javac opts)
   (println "Building uberjar...")
-  (let [basis (b/create-basis (update basis :aliases concat (:extra-aliases opts)))]
-    (b/copy-dir {:src-dirs ["src" "resources"]
+  (let [basis (b/create-basis (update basis :aliases concat (:extra-aliases opts)))
+        src-dirs (into ["src" "resources"] (:extra-dirs opts))]
+    (b/copy-dir {:src-dirs src-dirs
                  :target-dir class-dir})
     (b/compile-clj {:basis basis
-                    :src-dirs ["src" "resources"]
+                    :src-dirs src-dirs
                     :java-opts ["-Xmx2g" "-server"]
                     :class-dir class-dir})
     (b/uber {:class-dir class-dir
@@ -74,7 +75,8 @@
   (uber-aot (merge opts {:extra-aliases [:native]})))

 (defn debug-cli [opts]
-  (uber-aot (merge opts {:extra-aliases [:debug]}))
+  (uber-aot (merge opts {:extra-aliases [:debug]
+                         :extra-dirs ["dev"]}))
   (bin {:jvm-opts ["-Djdk.attach.allowAttachSelf=true"]}))

 (defn prod-cli [opts]

jacob.maine23:04:41

fwiw, that lets me run (require 'clojure-lsp.debug)

snoe23:04:03

yeah, thats way more robust than what i had. ;)

snoe23:04:47

thanks boss!

😉 1
ericdallo23:04:00

Sorry for the delay, the src folders are probably missing because of missing dev/test/debug aliases

ericdallo23:04:54

Yeah, the proposed fix should be enough :)

👍 1
ericdallo23:04:27

I didn't notice dev was outside src

ericdallo23:04:48

Merged, I like how we have total control on build.clj even tho it's a little bit more complex, lein magics used to annoy me 😅

jacob.maine00:04:53

those Cognitect folk seem to know what they’re doing :)

rich 1
jacob.maine22:04:36

that is, if i connect to the lsp server and eval clojure-lsp.debug, it works

jacob.maine22:04:09

the “dev” path is supposed to come from the :debug alias, which is used for make