leiningen

N.B. The maintainers are on #leiningen on Libera chat IRC. Go there for direct support/bug reports.
Marco Nicolodi 2020-05-04T13:48:20.086700Z

Hi folks. Is it possible to update two values that are not in the same tree branch of a defproject using lein update-in? Im creating codox related settings at pipeline time to generate docs. I need to update both the :codox and the :profiles :dev :dependencies values. I tried to use multiple update-in (as seen in the code below) but I couldnt make it work.

lein update-in :codox assoc :themes "[\"rdash\"]" :metadata "{:doc/format :markdown}" \
      -- update-in :profiles:dev:dependencies conj "[codox-theme-rdash \"0.1.2\"]" \
      -- update-in :plugins conj "[lein-codox \"0.10.7\"]" \
      -- codox

2020-05-04T13:53:54.087300Z

@marcocontatopro update-in is a task

2020-05-04T13:54:09.087900Z

To chain tasks you use do

2020-05-04T13:54:12.088100Z

Does that work?

2020-05-04T13:54:29.088500Z

Now that I say it. Thinking it doesnt

Marco Nicolodi 2020-05-04T13:55:09.089200Z

lol so simple! gonna try. it would be awesome. thank you friend!

2020-05-04T13:55:32.089900Z

Looks like you were doing it right. Sure it doesn’t work? Ha

Marco Nicolodi 2020-05-04T14:03:25.090700Z

im not using the single : as the defproject root, maybe its related to that. Im going to try multiple calls with do.

2020-05-04T14:13:30.091200Z

I don’t think do was a good suggestion

2020-05-04T14:13:35.091500Z

It doesn’t “chain”

Chase 2020-05-04T15:40:00.093600Z

So I have cider/cider-nrepl in my Lein profiles.clj just so I can quickly get a nrepl going with lein repl in random projects that I am exploring. In my official projects though I usually throw it in my project.clj because I think things like shadow-cljs will inject required middleware once it sees that dependency.

Chase 2020-05-04T15:40:13.094Z

Can these two things conflict or will the project.clj take precedence?

2020-05-04T16:11:59.094200Z

@chase-lambert think you end up with both

2020-05-04T16:12:02.094400Z

but only one wins

2020-05-04T16:12:10.094600Z

I believe the last one declared wins - going through :dependencies or :plugins order (they are sequentials (eg. vectors))

2020-05-04T16:29:19.095200Z

wouldn't they see cider/cider-nrepl once it's injected by profiles.clj? that should haappen before their code runs

Chase 2020-05-04T16:30:28.095400Z

Good question. I am not sure. Let me go test that real quick.

Chase 2020-05-04T16:32:11.095600Z

Oh wait, I might have been super dumb with this question as it pertains to shadow-cljs because calling shadow-cljs watch app has nothing to do with lein.

Chase 2020-05-04T16:34:00.095800Z

As in, I am not even using lein in that project. shadow-cljs calls the nrepl itself but that might not be necessarily the case always so I was still curious

Marco Nicolodi 2020-05-04T18:33:04.098600Z

using pprint for debugging both of these generate valid projects:

lein update-in :codox assoc :themes "[\"rdash\"]" :metadata "{:doc/format :markdown}" -- \
      update-in :profiles:dev:dependencies conj "[codox-theme-rdash \"0.1.2\"]" -- \
      codox
and
lein update-in :codox assoc :themes "[\"rdash\"]" :metadata "{:doc/format :markdown}" -- \
      update-in : assoc :profiles "{:dev {:dependencies  [[codox-theme-rdash \"0.1.2\"]]}}" -- \
      codox
I think the problem is that im adding a new dependency, and therefore I would need to build the classpath again. Does it make sense @mikerod ?

2020-05-05T13:44:24.099800Z

@marcocontatopro sorry, didn’t get to look at this. not familiar with the plugin and it sounds like the solution was related to how it works

2020-05-05T13:44:47.100Z

if you put it in :dev it may not have been merged in in time for when you were calling the task

2020-05-05T13:45:13.100200Z

:dev profile is a default that is merged in in most tasks, bbut that’s not always true and also depends on what you are doing if profiles are merged implicitly ahead of time or not

Marco Nicolodi 2020-05-05T17:22:01.100400Z

noiice

Marco Nicolodi 2020-05-05T17:22:18.100600Z

thanks for clarifying

Marco Nicolodi 2020-05-05T17:23:01.100800Z

you certainly helped pointing that my script should work and linking that github PR 🙂

2020-05-05T17:28:15.101Z

nice, yeah pprint can be helpful in many cases

Marco Nicolodi 2020-05-04T19:03:27.098800Z

actually i dont think it makes sense, since codox does build the classpath

Marco Nicolodi 2020-05-04T19:03:38.099Z

but its still failing with Could not find Codox theme: :rdash

Marco Nicolodi 2020-05-04T19:04:49.099200Z

"{:clojure.main/message \"Syntax error (IllegalArgumentException) compiling at (/private/var/folders/vd/nd1wrjqx4p5bxvsx38gr9n440000gn/T/form-init1582674147706229508.clj:1:125).\ Could not find Codox theme: :rdash\ \", :clojure.main/triage {:clojure.error/phase :compile-syntax-check, :clojure.error/line 1, :clojure.error/column 125, :clojure.error/source \"form-init1582674147706229508.clj\", :clojure.error/path \"/private/var/folders/vd/nd1wrjqx4p5bxvsx38gr9n440000gn/T/form-init1582674147706229508.clj\", :clojure.error/class java.lang.IllegalArgumentException, :clojure.error/cause \"Could not find Codox theme: :rdash\"}, :clojure.main/trace {:via [{:type clojure.lang.Compiler$CompilerException, :message \"Syntax error compiling at (/private/var/folders/vd/nd1wrjqx4p5bxvsx38gr9n440000gn/T/form-init1582674147706229508.clj:1:125).\", :data {:clojure.error/phase :compile-syntax-check, :clojure.error/line 1, :clojure.error/column 125, :clojure.error/source \"/private/var/folders/vd/nd1wrjqx4p5bxvsx38gr9n440000gn/T/form-init1582674147706229508.clj\"}, :at [clojure.lang.Compiler load \"Compiler.java\" 7648]} {:type java.lang.IllegalArgumentException, :message \"Could not find Codox theme: :rdash\", :at [codox.writer.html$apply_one_theme invokeStatic \"html.clj\" 499]}], :trace [[codox.writer.html$apply_one_theme invokeStatic \"html.clj\" 499] [codox.writer.html$apply_one_theme invoke \"html.clj\" 496] [clojure.lang.PersistentVector reduce \"PersistentVector.java\" 343] [clojure.core$reduce invokeStatic \"core.clj\" 6827] [clojure.core$reduce invoke \"core.clj\" 6810] [codox.writer.html$apply_theme_transforms invokeStatic \"html.clj\" 502] [codox.writer.html$apply_theme_transforms invoke \"html.clj\" 501] [codox.writer.html$write_docs invokeStatic \"html.clj\" 507] [codox.writer.html$write_docs invoke \"html.clj\" 504] [clojure.lang.Var invoke \"Var.java\" 384] [codox.main$generate_docs invokeStatic \"main.clj\" 125] [codox.main$generate_docs invoke \"main.clj\" 116] [user$eval11272 invokeStatic \"form-init1582674147706229508.clj\" 1] [user$eval11272 invoke \"form-init1582674147706229508.clj\" 1] [clojure.lang.Compiler eval \"Compiler.java\" 7177] [clojure.lang.Compiler eval \"Compiler.java\" 7166] [clojure.lang.Compiler eval \"Compiler.java\" 7167] [clojure.lang.Compiler load \"Compiler.java\" 7636] [clojure.lang.Compiler loadFile \"Compiler.java\" 7574] [clojure.main$load_script invokeStatic \"main.clj\" 475] [clojure.main$init_opt invokeStatic \"main.clj\" 477] [clojure.main$init_opt invoke \"main.clj\" 477] [clojure.main$initialize invokeStatic \"main.clj\" 508] [clojure.main$null_opt invokeStatic \"main.clj\" 542] [clojure.main$null_opt invoke \"main.clj\" 539] [clojure.main$main invokeStatic \"main.clj\" 664] [clojure.main$main doInvoke \"main.clj\" 616] [clojure.lang.RestFn applyTo \"RestFn.java\" 137] [clojure.lang.Var applyTo \"Var.java\" 705] [clojure.main main \"main.java\" 40]], :cause \"Could not find Codox theme: :rdash\", :phase :compile-syntax-check}} "

Marco Nicolodi 2020-05-04T19:15:11.099400Z

adding to :dependencies instead of :profiles:dev:dependencies seem to work. Good enough. But I didnt got what happened.