Fork me on GitHub

Is it possible to specify init-opt within deps.edn file?


should I be surprised that clojure forms in main opts are not output as quoted args?


I.E. :main-opts ["-e" (list 1 2 3)]


the list expression gets broken up into separate args


I guess escaping gets complicated


or there is a depth of features here I don't understand


I think the thing you might be missing is :main-opts is meant to be a list of strings passed as command line arguments, not a list of arbitrary datastructures


Also remember that , is whitespace so you can often get around shell-level tokenization by using , in strings instead of spaces. But, yeah, :main-opts are strings @bhauman.


thanks guys


another question, is this not a feature that we might want?


to take advantage of the fact that we are in a clojure form to begin with and script our way to euphoria?


But :main-opts are what is passed as a sequence of strings to the -main function via clojure.main -- it's all strings. You can easily pass an EDN string if you want a data structure.


There's no difference between command-line invocation and :main-opts.


and it is passed by a script, not by Clojure code.


the script doesn't parse the deps.edn


The :main-opts are cached to a text file and then piped into the (string) options passed to clojure.main. Just like the :jvm-opts.


I get this but I'm sure clojure code prepares the opts


before caching


It's just strings in the cached file. And it's just strings that are passed to clojure.main.


I must be missing something, are you saying that the feature isn't possible?


or that it messes up the semantics?


Take a look at the clojure shell script. Here's an example of what gets cached:

(! 763)-> ls -l .cpcache/*.main
-rw-r--r--  1 sean  staff  90 Mar 26 15:38 .cpcache/1770942858.main
-rw-r--r--  1 sean  staff  17 Apr 14 00:52 .cpcache/2142975460.main
-rw-r--r--  1 sean  staff  17 Apr 14 18:18 .cpcache/4269137912.main
-rw-r--r--  1 sean  staff  22 May  2 14:38 .cpcache/84686696.main
(! 764)-> cat .cpcache/84686696.main 
-m rebel-readline.main
(! 765)-> cat .cpcache/1770942858.main 
-e (require,'[,:refer,[start-server]]),(start-server,:port,5555)
(! 766)-> 


yes but we call the tools.aplha to resolve the tags


which is parsing main opts and therefore could quote clojure forms before caching them?


I just made a fairly big update to … would appreciate any folks here who could kick the tires a bit before I post to the mailing list


This includes adding some test runner boilerplate from clj-new. -- not sure what you mean there @hagmonk?


Should that link to Cognitect's test-runner repo perhaps?


Oh I pinched that from a clj-new generated app - specifically the separate test and runner aliases


I didn’t see the same style being used on the test-runner repo, but maybe I missed it


Ah, I see. Linking to my dot-clojure repo probably makes more sense then for that (at least by way of explanation).


Cool! I will make that change


I’m exploring the idea of adding more aliases to provide parity with project.clj, in those cases where someone has a tools.deps based tool we can use


CLJS and uberjars for instance


so now I'm looking at your deps.edn file and getting lots of ideas :) but I need to work on my real projects today at some point, LOL

Alex Miller (Clojure team)20:06:15

@bhauman I didn’t understand your earlier comments re quoting. if it’s something I should pay attention to, please try again :)


happy to 🙂

Alex Miller (Clojure team)20:06:53

the ground truth is that the jvm takes a classpath, a main class and string args to the main class. so we want to expose that, first.

Alex Miller (Clojure team)20:06:08

other things on top of that may also be useful



Alex Miller (Clojure team)20:06:36

but I didn’t understand what problem you were trying to solve or thing you were trying to make better or avoid


it just seems there is an opportunity when providing clojure forms (not strings) inline in :main-opts to output a single string arg that will make it through to the jvm process as a single arg

Alex Miller (Clojure team)20:06:58

the ultimate call needs individual string args though - how do you decide how to parse and tokenize?


:main-opts ["-e" {:build 1}] => clojure -e "{:build 1}"


is what I'm imagining

Alex Miller (Clojure team)20:06:39

you seem to be suggesting a read/print cycle but using different kinds of printing

Alex Miller (Clojure team)20:06:34

“-e” would be read as a string and pr’ed as “-e” (perhaps escaped in the invocation as clojure -e '"-e"`


it seems that string typs can go though untouched and that forms would be dispatched as such


other than string forms 🙂


its a common need, and it seems like a shame to be in a clojure form and then have to translate and escape a clojrue form correctly

Alex Miller (Clojure team)20:06:31

there are a couple layers of transformation here and I intend to sit down and sort through them methodically. I’m well aware it’s broken in various ways at the moment.

Alex Miller (Clojure team)20:06:57

I’m a little concerned about implying evaluation in the deps.edn file

Alex Miller (Clojure team)20:06:27

the args there are read (as edn) and never evaluated and I don’t want to imply that (or do it)

Alex Miller (Clojure team)20:06:48

it’s important to me that it remains plain edn data




not what I'm thinking or wanting to imply at all

Alex Miller (Clojure team)20:06:22

I didn’t think so, but it’s easy to get that impression from that example

Alex Miller (Clojure team)20:06:55

I’m not a fan of “special” arg handling


where I really want it is for cljs.main and figwheel.main to supply inline config

Alex Miller (Clojure team)20:06:25

yeah, that’s really same need as say, server repl

Alex Miller (Clojure team)20:06:49

passing arbitrary edn as an arg


:main-opts ["-m" "cljs.main" "-co" {:output-to "out/main.js"} ]

Alex Miller (Clojure team)20:06:19

in a way that is not a nightmare, and that works :)


what works?

Alex Miller (Clojure team)20:06:47

I’m just saying that a requirement is that the end result works


gotcha 🙂


it is interesting though that I'd expected this to work


I intuited that it might me a likely feature

Alex Miller (Clojure team)20:06:59

there might be a higher level solution to this problem too - I know Rich has mentioned various ideas that are in this ballpark but a somewhat different take on it

Alex Miller (Clojure team)20:06:47

for example, you could expose functions directly and hide the main goo entirely


that is interesting

Alex Miller (Clojure team)20:06:28

it’s come up in several contexts and I know he’s noodling about it

Alex Miller (Clojure team)20:06:52

but sometimes he noodles for many years before it lands somewhere :)

Alex Miller (Clojure team)20:06:23

so I make no suggestion that a deux ex machina will save us all here

Alex Miller (Clojure team)20:06:07

clojure.main itself is both very flexible and frustratingly limited

Alex Miller (Clojure team)20:06:38

like I think it sucks that rebel-readline couldn’t just be hooked directly


I had some thoughts about that


I could potentially graalvm it, and provide a rlwrap equivalent

Alex Miller (Clojure team)20:06:44

well, I need to roll back to other work, but I would like to hear them somewhere :)


thanks Alex! later