Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command line arguments to repl/rebel-remote don't work #82

Closed
toburger opened this issue Jan 16, 2024 · 9 comments
Closed

Command line arguments to repl/rebel-remote don't work #82

toburger opened this issue Jan 16, 2024 · 9 comments

Comments

@toburger
Copy link

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.

@practicalli-johnny
Copy link
Contributor

Maybe I am missing something but I havent been able to replicate the issue you have been experiencing

image

Are the more details you can supply, e.g. the command used, any network infrastructure being navigated or a project that recreates the issue.

Thanks.

@toburger
Copy link
Author

toburger commented Feb 12, 2024

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):

image

When i execute a netcat command I can't reach the service:

image

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?

@practicalli-johnny
Copy link
Contributor

practicalli-johnny commented Feb 12, 2024

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.

@toburger
Copy link
Author

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.

image

Sorry, I had to hide the host for security reasons but I can assure that the they go to the same host.

@practicalli-johnny
Copy link
Contributor

practicalli-johnny commented Feb 13, 2024

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

@practicalli-johnny
Copy link
Contributor

practicalli-johnny commented Feb 13, 2024

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 :(

The Cider docs recommend using a TLS approach

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 :)

@practicalli-johnny
Copy link
Contributor

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.

@toburger
Copy link
Author

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.

image

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.

@practicalli-johnny
Copy link
Contributor

Marked the alias as DEPRECATED and will move to the deps-deprecated.edn file by the next release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants