Fork me on GitHub

Hi folks. I have some :jvm-ops in my profile. However, I’d like to use lein update-in for replacing them when invoking a specific command. What’s the correct syntax for that? Normally, I’d use lein update-in :jvm-opts conj <stuff> . But I don’t want to conj, I’d like to completely replace the current jvm-opts value.


update-in : assoc :jvm-opts "[...]" should work


Many thanks!

🙌 1

Actually, seems that it’s not working :thinking_face: Context: I have this in my lein profile:

{:repl {:jvm-opts     ["-Dclojure.server.repl={:port,5555,:accept,clojure.core.server/repl}"]}}
This is the port I use for socket repl. Now, I’m trying to run another project in port 0 (that is, random):
lein update-in : assoc :jvm-options "-Dclojure.server.repl={:port,0,:accept,clojure.core.server/repl}" -- repl
However, I’m getting
Exception in thread "main" Address already in use
Which makes me think that it did not work :thinking_face:


The repl profile is probably being merged on after your update-in command


So may be difficult to accomplish what you want with this setup


You maybe could use :displace metadata on the repl profile :jvm-opts


Got it. Thanks for the explanation. I think I will change my approach then – I’ll remove jvm-opts from my profile and use it by demand.


So, I must be messing something really basic, because this isn’t working:

lein update-in :jvm-opts conj "-Dclojure.server.repl={:port,5555,:accept,clojure.core.server/repl}" -- repl
gets this error
array element type mismatch
with my lein profile having
:jvm-opts []
inside :repl


For completeness, in

lein update-in : assoc :jvm-options "-Dclojure.server.repl={:port,0,:accept,clojure.core.server/repl}" -- repl
you assoced a single string, whereas jvm-options is expected to be a vector


btw update-in is kind of a hack, there are things that certainly don't work with it. It's more idiomatic to use profiles


You can activate profiles as defined in the project itself (if it's under your control) or ~/.lein/profiles.clj


Fair point. Makes sense.