Fork me on GitHub
#leiningen
<
2022-03-24
>
apt14:03:48

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.

vemv15:03:55

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

apt17:03:55

Many thanks!

🙌 1
apt22:03:38

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" java.net.BindException: Address already in use
Which makes me think that it did not work :thinking_face:

mikerod00:03:36

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

mikerod00:03:18

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

mikerod00:03:40

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

apt03:03:46

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.

apt03:03:38

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

vemv05:03:57

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

vemv05:03:34

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

vemv05:03:02

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

apt19:03:06

Fair point. Makes sense.