tools-deps

isak 2023-06-29T22:52:28.764219Z

If I have this alias in my deps edn: :setmain {:ns-default foo.foo}, when I run clj -A:setmain, why does it start a repl in the user namespace instead of foo.foo?

2023-06-29T22:59:56.886629Z

:ns-default tells -X and -T to lookup unqualified symbols passed as arguments in the given namespace

isak 2023-06-29T23:02:09.957819Z

I see, thanks

isak 2023-06-29T23:06:34.726389Z

Do you know if there a way to set the default namespace when you are starting a REPL?

2023-06-29T23:06:50.587799Z

there is none

isak 2023-06-29T23:07:03.311769Z

ah, ok

2023-06-29T23:09:47.663829Z

you can pass expressions to be pre-evaluted

% clj -M -e '(ns foo)' -r
foo=>
which I believe in tools.deps would be maybe a main args, no idea how any of that would be quoted/escaped

🙏 1
isak 2023-06-29T23:24:32.729219Z

Nice, that approach works. I'll try to see if there is a way to put it in an alias.

Alex Miller (Clojure team) 2023-06-30T00:16:01.373459Z

You can put that in :main-opts

👍 1
seancorfield 2023-06-30T00:38:53.783099Z

If it's an existing ns you want to load and switch to at startup, make sure you require it and then in-ns it!

👍 1
practicalli-johnny 2023-06-30T07:34:02.082569Z

Rather than try to set the namespace when starting the repl, a common practice is to use a custom user namespace to load and run code https://practical.li/clojure/clojure-cli/repl-startup/

🙏 1