Does/can lein repl write ./.nrepl-port file?
This seems like it would be easy to find info on but I'm struggling.
It's not creating that file for me by default.
https://codeberg.org/leiningen/leiningen/src/branch/main/src/leiningen/repl.clj#L22
I think it normally does yes
It does't seem to here
wonder what https://codeberg.org/leiningen/leiningen/src/branch/main/src/leiningen/repl.clj#L252 is about
What lein version are you running?
lein --version
Do you get any nREPL output in your logs? Something like:
nREPL server started on port 34603 on host 127.0.0.1 -
REPL-y 0.5.1, nREPL 1.0.0
Clojure 1.11.1
OpenJDK 64-Bit Server VM 17.0.8+7-jvmci-23.0-b15 Leiningen 2.10.0 on Java 17.0.8.1 OpenJDK 64-Bit Server VM
on my linux box and
Leiningen 2.10.0 on Java 20.0.1 OpenJDK 64-Bit Server VM
on my maclein repl and lein repl :headless do not write a ./.nrepl-port file
which logs do you mean?
the commands do print that to /dev/tty
nREPL server started on port 38097 on host 127.0.0.1 - I think it might only write that file in a project.
/tmp
❯ mkdir foo
/tmp
❯ cd foo
/tmp/foo
❯ lein repl
nREPL server started on port 58193 on host 127.0.0.1 -
REPL-y 0.5.1, nREPL 1.0.0
Clojure 1.11.1
OpenJDK 64-Bit Server VM 18.0.2.1+1
Docs: (doc function-name-here)
(find-doc "part-of-name-here")
Source: (source function-name-here)
Javadoc: (javadoc java-object-or-class-here)
Exit: Control+D or (exit) or (quit)
Results: Stored in vars *1, *2, *3, an exception in *e
user=>
zsh: suspended lein repl
/tmp/foo
❯ ls -a
. ..
/tmp/foo
❯ fg
[1] + continued lein repl
Welcome back!
Bye for now!
/tmp/foo
❯ cd ..
/tmp
❯ rmdir foo
/tmp
❯ lein new foo
Generating a project called foo based on the 'default' template.
The default template is intended for library projects, not applications.
To see other templates (app, plugin, etc), try `lein help new`.
/tmp
❯ cd foo
/tmp/foo
❯ ls
CHANGELOG.md README.md project.clj src
LICENSE doc resources test
/tmp/foo
❯ lein repl
nREPL server started on port 58535 on host 127.0.0.1 -
REPL-y 0.5.1, nREPL 1.0.0
Clojure 1.11.1
OpenJDK 64-Bit Server VM 18.0.2.1+1
Docs: (doc function-name-here)
(find-doc "part-of-name-here")
Source: (source function-name-here)
Javadoc: (javadoc java-object-or-class-here)
Exit: Control+D or (exit) or (quit)
Results: Stored in vars *1, *2, *3, an exception in *e
foo.core=>
zsh: suspended lein repl
/tmp/foo
❯ ls -a
. .nrepl-port project.clj
.. CHANGELOG.md resources
.gitignore LICENSE src
.hgignore README.md target
.lein-repl-history doc test
/tmp/foo I can do what I need now...
Ah, well, that might or might not be what one wants. 😃 But as long as it is deterministic, I guess it’s fine.
I'm writing a shell function called nrepl for me personally that will start a lein repl server in a background process in any directory, and then write .nrepl-port and .nrepl-pid files.
If they already exist it will just report the port and pid.
So I can just mv ~/.lein/repl-port ./.nrepl-port if needed after starting the lein repl server.
Using lein repl for now because my current projects all use lein
I don't know leiningen very well, but wouldn't it be abnormal to run lein repl in a dir without a project.clj?
I can see it being useful. :)
fwiw, I'm trying to get my REPL/nREPL fu solidified and only use REPL servers from various clients from now on. It's not super easy to learn all the right things to do on this but it's important that I figure it all out. I did watch @seancorfield’s talk on REPL DD https://www.youtube.com/watch?v=gIoadGfm5T8 but that doesn't instantly make me a expert by any stretch. Also... advice welcome.
Shouldn’t be abnormal? Isn’t that what a lot of Clojure at a glance guides tell you to do?
Oh yeah, right, for a wee experiment at the terminal, of course.
Running lein repl outside of a project is fine. If it werent then the task would signal an error (like e.g. running lein uberjar in an empty folder)
In fact Leiningen looks for a :no-project-needed metadata in tasks. If that is set to true, then the task will run even in the absence of a project file. Otherwise the user will see an error like
Couldn't find project.clj, which is needed for [task]
> I don't know leiningen very well, but wouldn't it be abnormal to run lein repl in a dir without a project.clj?
My brain was obviously not working well yesterday! facepalm