Command line arguments to repl/rebel-remote don't work
toburger opened this issue · comments
The same command line args as applied to repl/remote do not work with repl/rebel-remote.
--host and --port do not have any effect.
After investigating a bit more I think I've found the "real" cause of the problem:
The remote NREPL gets registered with the host localhost (see the printed out nrepl://localhost:44947):
When i execute a netcat command I can't reach the service:
So I think I have to startthe nrepl-Server with the actual host name. The repl/...
commands do have a parameter to specify the host name?
Ah yes, I remember the --bind
is a server option is required to set the hostname that the nrepl server starts on. If --bind
is not set, the default locahost IP address is used
❯ clojure -M:repl/rebel --bind 192.168.0.212 --port 44445
WARNING: abs already refers to: #'clojure.core/abs in namespace: clojure.test.check.generators, being replaced by: #'clojure.test.check.generators/abs
nREPL server started on port 44445 on host 192.168.0.212 - nrepl://192.168.0.212:44445
[Rebel readline] Type :repl/help for online help info
user=>
When connecting via the --connect
option, the --host
option is the client argument that specifies the address set by --bind
on the server
Its quite easy to get --host
and --bind
confused.
The nrepl docs provide some other options, including defining a configuration file.
Ah, that's exactly what happened! I've tried it with --host and nothing happened so I thought there is no option for that! 😅 Thanks for the hint!
Now the repl/remote
works like a charm. But the repl/rebel-remote
doesn't seem to use the --host argument.
Sorry, I had to hide the host for security reasons but I can assure that the they go to the same host.
Update: sorry, I forgot that --connect
was already included in the alias... try using nrepl as a client alone, without rebel readline
https://nrepl.org/nrepl/usage/clients.html#using-the-built-in-client
I believe the --connect
option is also required as well as the --host
and --port
options
clojure -M:repl/rebel-remote --connect --host hostname --port 8083
I dont have a remote setup at the moment to test.
If the above doesnt work, then try using nrepl directly as a remote REPL client
https://nrepl.org/nrepl/usage/clients.html#using-the-built-in-client
I have only managed to get a remote connection by first establishing an SSH forwarding connection. This only seems to work with nrepl connect command locally, using the :repl/rebel-remote
rebel readline alias does not seem to know about the remote repl state :(
Remote server
Start the REPL process on the remote machine, specifying the port
clojure -M:repl/basic --port 1234
SSH tunnel
Create an ssh local forward tunnel to the remote machine
ssh -L :1234:192.168.0.212:1234 practicalli@192.168.0.238 -N -v
This will prompt for the user password, e.g. practicalli is the name of the user account on the remote machine.
192.168.0.212 is the IP address of the local machine and 192.168.0.238 is the IP address of the remote machine (replace with your own IP addresses)
Local connection
On the local machine (in a separate terminal prompt), connect to the local port and and nrepl commands will be sent via SSH to the REPL process running on the remote server.
clojure -M:repl/basic --connect --host localhost --port 1234
Testing
At the REPL prompt on the remote server, define a var, e.g.
(def remote-value 42)
At the REPL prompt on the local server, evaluate the var name
remote-value
This should display the value 42 in the local repl prompt.
The process is simpler if using Emacs
cider-connect-clj
to connect to the remote repl :)
If using Emacs Cider as the local REPL connection, define a local SSH connection in the .ssh/config
file.
Host gkar-repl
HostName 192.168.0.238
# IdentityFile /home/practicalli/.local/joint-clojure-machine.pem
User practicalli
PasswordAuthentication yes
LocalForward 1234 localhost:1234
Port 22
Uncomment the
IdentityFile
if there are pem certificates available. Otherwise Emacs Cider will prompt for the user account password on the remote machine.
In Emacs, run the cider-connect-clj
command and select the Host definition from the list of connections, e.g. gkar-repl or enter the IP address of the remote server
Enter the port, e.g 1234
Emacs cider should connect to the remote repl state.
Thanks for the thorough testing!
I've managed to connect via SSH tunnel and Cider and it works!
But in summary we can definitely say that repl/rebel-remote
ignores --host and --port parameters.
Which is fine for me if I know the limitations but on the other hand the command is misleading as it implies that it is possible to connect to a remote REPL.
Marked the alias as DEPRECATED and will move to the deps-deprecated.edn file by the next release