tools-deps 2023-06-29

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?

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

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

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

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

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

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