This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-10-30
Channels
- # aleph (4)
- # announcements (5)
- # architecture (1)
- # aws (5)
- # babashka (12)
- # beginners (143)
- # chlorine-clover (4)
- # cider (16)
- # clj-kondo (44)
- # cljfx (26)
- # cljsrn (2)
- # clojure (34)
- # clojure-europe (28)
- # clojure-gamedev (1)
- # clojure-nl (3)
- # clojure-provo (2)
- # clojure-spec (6)
- # clojure-uk (17)
- # clojurescript (99)
- # code-reviews (6)
- # core-async (15)
- # cryogen (9)
- # cursive (14)
- # data-science (1)
- # datomic (16)
- # duct (1)
- # events (4)
- # exercism (1)
- # figwheel-main (3)
- # fulcro (3)
- # hugsql (7)
- # leiningen (4)
- # malli (15)
- # off-topic (13)
- # pathom (8)
- # re-frame (7)
- # reitit (35)
- # remote-jobs (1)
- # sci (10)
- # shadow-cljs (32)
- # sql (5)
- # tools-deps (102)
- # tree-sitter (3)
- # uncomplicate (7)
- # vim (40)
- # xtdb (8)
clojure -A:foo and clojure -M:foo without main-opts do the same thing: invoke a REPL with alias foo merged in -- right? Should -M:foo give a warning when you forget to supply main-opts in deps.edn maybe?
-A
is for REPL invocation, according to the docs.
I suspect that's a bit of a grey area given that :main-opts ["-r"]
works to run a REPL, yes?
well, I invoked an alias with -M while I forgot to provide :main-opts in deps.edn, so it invoked a REPL for me
Yeah, I would sort of expect -M
to at least give a warning if no :main-opts
are provided. @alexmiller?
(! 651)-> fgrep :repl deps.edn
:repl {:main-opts ["-r"]}
(! 652)-> clj -M:repl
Clojure 1.10.1
user=> ^D
(! 653)-> clj -A:repl
WARNING: Use of :main-opts with -A is deprecated. Use -M instead.
Clojure 1.10.1
user=> ^D
(so, yeah, you can specify -r
explicitly as a :main-opts
item)
And the corollary:
(! 656)-> fgrep :dummy deps.edn
:dummy {}
(! 657)-> clj -M:dummy
Clojure 1.10.1
user=> ^D
(! 658)-> clj -A:dummy
Clojure 1.10.1
user=> ^D
you can supply main-opts on the command line, so -M does necessarily have to have :main-opts
clj -M:my-alias-with-just-deps -m my.ns
Yes, but that's not the case we're discussing here.
well, what is?
See the two console examples I pasted. No command-line main-opts there.
-M invokes clojure.main. clojure.main does not require opts.
Fair enough. The "implicit" -r
option š
Why draw the distinction in the docs then that -A
is for REPL execution?
really, it can be used to supply aliases for anything but it's only useful with REPL (because -M can be used for main and -X can be used for functions)
(and for allowing legacy stuff to continue working)
I guess this will become less confusing once -A
stops executing :main-opts
I'm curious how you plan to distinguish between -A
for a REPL and -M
executing clojure.main
which might pick up other main opts?
what do I need to distinguish?
I mean: how is -A
going to start a REPL without running clojure.main
?
it already does this
it invokes clojure.main
that's an implementation detail
clj
without -M or -X will start a repl, you let me figure out how to do that :)
So, in the absence of :main-opts
in an alias, both -A
and -M
will work identically, always? i.e., they will both run clojure.main
and they will both start a REPL?
I would maybe prefer -M to trigger a warning when there is no :main-opts []
when you want to explicitly pass 0 arguments to main (i.e. invoke a REPL)
@borkdude I don't think that is going in the right direction...
It seems that the only way to avoid continued confusion is to have clojure.main
without arguments not start a REPL -- and require -r
for that? š
I don't follow
So, in the absence of :main-opts
in an alias, both -A
and -M
will work identically, always? i.e., they will both run clojure.main
and they will both start a REPL?
I guess you could always have a new entry point for a REPL and have -A
invoke that...?
I don't understand what problem is bothering you
(or rather "have the absence of -M
and -X
invoke that")
the absence of -M or -X means: invoke a repl
in other words, the default behavior of clj
is: invoke a repl
(! 659)-> clj -A:dummy -r
WARNING: When invoking clojure.main, use -M
Clojure 1.10.1
user=> ^D
ok, you're outside the bounds of documented behavior
that's legacy support
-r
is a documented main-opt that causes clojure.main
to start a REPL, isn't it?
yes, but when we stop accepting main opts outside of -M, that's no longer a thing
there may be some other set of accepted arguments in the repl case that have nothing to do with clojure.main
OK, so there will need to be a change in the behavior of clojure.main
at some point to "fix" this?
clojure.main
's help says
-r, --repl Run a repl
"clj starting a repl" is distinct from clojure.main
yes, the mechanism clj currently uses to start a repl is clojure.main
but that's an implementation detail
So there will be a non-`clojure.main` entry point that clj
can use to start a REPL?
(otherwise this confusion is going to continue)
what I'm saying is - I am promising clj
will start a repl. the end.
and I'm promising that clj -M
will run clojure.main
and that clj -X
will invoke a function with a map
but you're not promising that clojure.main
will not support -r
at some future point :rolling_on_the_floor_laughing:
there are no plans to make clojure.main do anything different than what it does now
in the before times, clj
always ran clojure.main. that is no longer the model
the new model is: ā¢ by default, run a repl ā¢ with -M, run clojure.main ā¢ with -X, execute a function with a map
and "run a repl" does not say anything about clojure.main
if you want to explicitly run clojure.main to run a repl, then clj -M
or clj -M -r
will do that
The confusion arises because the docs talk about "using -A
(for REPL invocation)" when it still runs :main-opts
!
well, we're in a bridge period between the two models
The sooner -A
stops running :main-opts
the better...
(mind you, even in that future world, I think @borkdudeās confusion will still be present, yes?)
if the confusion is that you can use clojure.main to run a repl, then yes
but it's easy to reason about if we are properly conveying that -M == run clojure.main
Argh, I'm being bitten by caching here š
(! 665)-> clj -Sforce -A
Missing required argument for "-A ALIASES"
(! 666)-> clj -Sforce -A -r
Missing required argument for "-A ALIASES"
^ That makes more sense.
-M
and -X
can be invoked without an alias, -A
cannot.
what does that have to do with caching? -A always requires an alias
Because this happened before I added -Sforce
:
(! 662)-> clj -A
Clojure 1.10.1
user=>
(! 663)-> clj -A -r
WARNING: When invoking clojure.main, use -M
Clojure 1.10.1
user=> ^D
(note the command history numbers there!)
oh, well that's just a bug then
Here's the repro for that bug:
(! 674)-> clj -Sforce -A
Missing required argument for "-A ALIASES"
(! 675)-> clj -A
Clojure 1.10.1
user=>
So the point earlier was: invoking -M with an alias that doesn't have :main-opts
assumes that :main-opts
is implicitly []
. My question was: should this be less implicit, to avoid people ending up in a REPL when invoking -M with an alias that wasn't intended for -M at all
no, because :main-opts is not required
@borkdude in the following :test
has no :main-opts
-- which of these would you expect to get warnings on and why?
(! 676)-> clj -Sforce -M:test -r
Clojure 1.10.1
user=> ^D
(! 677)-> clj -Sforce -A:test -r
WARNING: When invoking clojure.main, use -M
Clojure 1.10.1
user=> ^D
(! 678)-> clj -Sforce -M:test
Clojure 1.10.1
user=> ^D
(! 679)-> clj -Sforce -A:test
Clojure 1.10.1
user=> ^D
we could do something like - if you supplied -M but did not supply either :main-opts or main-opts on the command line, then either warn or error at that point
but honestly that's difficult to check right now due to where that knowledge of different parts of that is
So -M
wouldn't silently start a REPL unless you said -M -r
? I think that would be reasonable.
(if it could be checked)
and then -M means run clojure.main except for this one case where it fails
(I'd be against an error there but I think a warning to remind folks might be worthwhile)
main opts can be supplied on the command line, so not providing arguments means the same as :main-opts []
, but you can also do that with -A
which is the preferred way of invoking a REPL maybe
@seancorfield 1.10.1.735 if you want to check the -A thing
But I suspect there's no point trying to second-guess what folks will find confusing until after we have a CLI version where -A
no longer uses :main-opts
@alexmiller Thanks for the swift fix!
(! 680)-> clj -Sforce -A
-A requires an alias
(! 681)-> clj -A
-A requires an alias
confirmed fixed!I did not take the time to try on Windows, but it might already catch this case due to the different parsing. I'll check that before we get to a stable release