Add main opts to -Sdescribe output


Enhancement Description

Add main opts to -Sdescribe output. This could simply be a new :main-opts key along with a string value representing the content of the main opts cache file, if one exists, or an empty string otherwise.


Downstream execution environments can make use of the main opt information when using clojure for dependency download, classpath construction, and main opt selection via aliases. Another way to look at this is that, in the same way that -Spath provides useful information when composing clojure with other executable environments that can consume classpaths, access to the main opts is also similarly useful when composing. This need probably isn't sufficiently strong to warrant polluting the options list with a new -Smain-opts flag; putting this into -Sdescribe output is likely sufficient.

A secondary rationale might be that this could be useful to humans for debugging purposes.

Implementation Considerations

This could be as simple as a single new line in the script, perhaps placed after the line that emits :main-aliases in the -Sdescribe output.

This would work for most normal use cases, but could perhaps be dependent upon what happens with TDEPS-56, where there might end up being some platform-specific changes made to properly handle the case when a main opt has a space embedded in it. (Perhaps in light of this, clojure could take the stance that :main-opts isn't guaranteed to be final; this is consistent with things still being in alpha, and perhaps also consistent with -Sdescribe not really being formal API.)




Mike Fikes
April 9, 2018, 7:40 AM



the attached patch causes clojure -Sdescribe -A:foo to emit

on both macOS and Ubuntu 16.04. And clojure -Sdescribe emits

The patch redirects error to /dev/null to handle the second case above where the main cache file doesn't exist.

Alex Miller
April 9, 2018, 9:23 AM

There are actually two sources of main options to consider: 1) the .main file which holds the outcome of main opts aliases and 2) any additional options specified on the command line. Seems like either these should be combined into a single unified main options set or should be included as separate keys. My first instinct would be the former, but would need to think about that a bit more.

The suggested approach also does not "clojure-ify" the data and just treats the whole thing as a string. We already have issues around escaping and I'd like to solve this in the most correct way possible, probably in light of other changes necessary around quoting in the .main file.

Alex Miller
September 29, 2020, 3:34 AM

Probably not going to do this - would like to phase out -Sdescribe.

Having some way for scripts to parse or access the main options though is something we're thinking about and might cover the same needs.

Won't Fix


Alex Miller


Mike Fikes