Fork me on GitHub
#leiningen
<
2018-09-21
>
Jakub Holý (HolyJak)10:09:56

Hello folks! Could somebody kindly advise me how to debug a lein plugin? I have added lein cooper to my project but it fails with an excepion. Is setting LEIN_JVM_OPTS to -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y the way to go? Thanks!

Jakub Holý (HolyJak)10:09:09

Also, what is a good way to use my clone of a plugin (preferably without needing to install it to my local mvn repo, use it directly from its git clone directory)? Thanks!

mikerod15:09:20

@holyjak so you can always do DEBUG=true lein <whatever task>

mikerod15:09:54

lein will use the DEBUG flag to enable debug level logging. if the plugin is well-written, it’ll use the logging utils that respect that

mikerod15:09:05

but even if not, you’ll still get more info on the internal steps lein is doing

mikerod15:09:49

as far as using your own clone of a repo, why not install the snapshot and reference the snapshot version you installed?

mikerod15:09:07

Not sure of a better way. I don’t know that lein checkouts feature works for plugins (could be proven wrong there)

mikerod15:09:24

a lein install of a snapshot of a cloned git repo you have should be harmless though

mikerod15:09:33

snapshot versions are overridden on each install

mikerod15:09:59

you can even change the version to like plugin-name-MINE-SNAPSHOT if you don’t want to collide with the “real one”

👍 4
Jakub Holý (HolyJak)16:09:02

thx but DEBUG=true is not enough, I need a true debugger

mikerod16:09:48

well there are ways to do that too

mikerod16:09:59

what I prefer to do

mikerod16:09:04

clone the plugin repo

mikerod16:09:20

start a lein repl (or however, you like to make repls) in that repo

mikerod16:09:50

then:

(require '[leiningen.core.project :as p])

(def project (p/read "path/to/your-own/project.clj"))

❤️ 4
mikerod16:09:12

then you can call your plugin’s task, by finding it’s definition under it’s leiningen.<plugin-ns>/task-name

mikerod16:09:22

at that point, you have a live repl to troubleshoot

mikerod16:09:36

you can redefine plugin fn’s with println etc