Fork me on GitHub
#tools-deps
<
2023-06-29
>
isak22:06:28

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?

hiredman22:06:56

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

isak23:06:09

I see, thanks

isak23:06:34

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

hiredman23:06:50

there is none

hiredman23:06:47

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

🙏 2
isak23:06:32

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

Alex Miller (Clojure team)00:06:01

You can put that in :main-opts

👍 2
seancorfield00:06:53

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!

👍 2
practicalli-johnny07:06:02

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/

🙏 2