leiningen

apt 2022-03-24T14:59:48.701459Z

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.

vemv 2022-03-24T15:04:55.120959Z

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

apt 2022-03-24T17:12:55.648039Z

Many thanks!

🙌 1
apt 2022-03-24T22:11:38.934859Z

Actually, seems that it’s not working 🤔 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 🤔

2022-03-25T00:44:36.040859Z

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

2022-03-25T00:45:18.670949Z

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

2022-03-25T00:45:40.222619Z

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

apt 2022-03-25T03:09:46.265359Z

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.

apt 2022-03-25T03:45:38.925479Z

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

vemv 2022-03-25T05:03:57.809139Z

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

vemv 2022-03-25T05:04:34.536769Z

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

vemv 2022-03-25T05:05:02.606539Z

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

apt 2022-03-25T19:10:06.909129Z

Fair point. Makes sense.