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

describe remote scenariuos #3505

Closed
wants to merge 17 commits into from
Closed

Conversation

behrica
Copy link
Contributor

@behrica behrica commented Oct 8, 2023

Give more details and hopeful clarity to the use of Cider in remote / container scenarios.

I left it on purpose very general for now.

describe remote scenarious
@behrica
Copy link
Contributor Author

behrica commented Oct 9, 2023

In order to get more concrete in my use case, I would come up with some ssh and shell magic.
But i don't know if the Cider docu is the right place for that.
For example:

In my remote devcontainer scenario I use a shell comand such as this to start a nrepl in the remote container and forward the port to local:

ssh -t -L 12345:localhost:12345 MY_REMOTE_SERVER \
    devcontainer exec  --workspace-folder /FOLDER_WITH_CODE/ON/REMOTE-SERVER \
    "clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version \"0.8.3\"} cider/cider-nrepl {:mvn/version \"0.25.5\"}}}' -m nrepl.cmdline -p 12345 -b 0.0.0.0 --middleware '[\"cider.nrepl/cider-middleware\"]' "

This requires as well a devcontainer.json snippet which exposes the port:

"appPort": [
		"12345:12345", // for cider
	],

Now I can connect a local Cider to port 12345 and edit the files over TRAMP on MY_REMOTE_SERVER,( not in container, but they are mounted by devcontainer so it's the same)

I think this is a very comfortable way to use a remote host+container together with a local graphical Emacs
But should this get into Cider docu ?

@vemv
Copy link
Member

vemv commented Oct 9, 2023

It sounds like a reasonable and small snippet to include.

(I assume that there's no 'native' option? I see that there's https://github.com/devcontainers/cli)

@behrica
Copy link
Contributor Author

behrica commented Oct 9, 2023

It sounds like a reasonable and small snippet to include.
My concern is there are lots of options, regarding which concrete "container management tool somebody is using", among

  • docker cli
  • podman cli
  • devcontainer cli
  • devpod cli
  • gitpod cli

The later 3 are using docker behind the scenes
and there are other devcontainer-cli alternatives.

But I can change the text to point out, that devcontainer-cli is one potential way to manage containers on a remote / localhost host

@vemv
Copy link
Member

vemv commented Oct 9, 2023

If the ssh approach is a generic one, it SGTM to put it first, and mention other possibilities below.

@behrica behrica marked this pull request as ready for review October 9, 2023 22:06
addressed review comments
Copy link
Member

@vemv vemv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After applying the suggestions please give it one additional proofread

Thanks much!

doc/modules/ROOT/pages/basics/up_and_running.adoc Outdated Show resolved Hide resolved
doc/modules/ROOT/pages/basics/up_and_running.adoc Outdated Show resolved Hide resolved
doc/modules/ROOT/pages/basics/up_and_running.adoc Outdated Show resolved Hide resolved
doc/modules/ROOT/pages/basics/up_and_running.adoc Outdated Show resolved Hide resolved
doc/modules/ROOT/pages/basics/up_and_running.adoc Outdated Show resolved Hide resolved
doc/modules/ROOT/pages/basics/up_and_running.adoc Outdated Show resolved Hide resolved
doc/modules/ROOT/pages/basics/up_and_running.adoc Outdated Show resolved Hide resolved
doc/modules/ROOT/pages/basics/up_and_running.adoc Outdated Show resolved Hide resolved
doc/modules/ROOT/pages/basics/up_and_running.adoc Outdated Show resolved Hide resolved
doc/modules/ROOT/pages/basics/up_and_running.adoc Outdated Show resolved Hide resolved
behrica and others added 12 commits October 10, 2023 21:55
Co-authored-by: vemv <vemv@users.noreply.github.com>
Co-authored-by: vemv <vemv@users.noreply.github.com>
Co-authored-by: vemv <vemv@users.noreply.github.com>
Co-authored-by: vemv <vemv@users.noreply.github.com>
Co-authored-by: vemv <vemv@users.noreply.github.com>
Co-authored-by: vemv <vemv@users.noreply.github.com>
Co-authored-by: vemv <vemv@users.noreply.github.com>
Co-authored-by: vemv <vemv@users.noreply.github.com>
Co-authored-by: vemv <vemv@users.noreply.github.com>
Co-authored-by: vemv <vemv@users.noreply.github.com>
Co-authored-by: vemv <vemv@users.noreply.github.com>
proofreading done
Copy link
Member

@vemv vemv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there

Using containers means that the JVM in which the nREPL server process is running runs inside a container (Docker or otherwise).
The files which we edit might / might not be edited using TRAMP. They could as well be mounted inside the container, so appear as local.

So CIDER can hardly detect if it's dealing with remote files, so it is better to not rely on `cider-jack-in` and its remote support described above, but to
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're gonna say that the above section is possibly incorrect, better to improve it upfront - mind to give it a go?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to say that CIDERs approach to try to infer the "host to run the jack-in command" when doing cider-jack-in from the file location / path of the edited file / folder cannot work in complex remote scenarios like "docker on remote host"
So the sentence You can safely run cider-jack-in- while working with remote files over TRAMP. from the docu is not correct in some (most ?) remote + docker scenarios.

It is not even required that the source code is at all on the remote machine. I could start a remote nREPL, tunnel the port locally, and have all my files locally. (and be aware that "(load-file ..)" will not work, But all cider-eval-.. commands do work

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked as well the open issues for this and found:
#2703 (comment)

I share your comment that cider-jack-in cannot work reliable ever for all remote situations and should therefore be discouraged for any remote scenario in favor of "cider-connect"

It does work for the "simplest" remote scenario, namely having files on a given ssh accessible server and wanting to start the nREPL process on that machine as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my concrete szenario, CIDER would need to be able to infer this

 ssh -t -L 12345:localhost:12345  dsvm devcontainer exec  --workspace-folder /media/xfs/repos/foodfraudproject/   "clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version \"0.8.3\"} cider/cider-nrepl {:mvn/version \"0.25.5\"}}}' -A:dev -m nrepl.cmdline -p 12345 -b 0.0.0.0 --middleware '[\"cider.nrepl/cider-middleware\"]' "

How could that work for the first part:

ssh -t -L 12345:localhost:12345 -L 7777:localhost:7777 dsvm devcontainer exec  --workspace-folder /media/xfs/repos/foodfraudproject/

by just "knowing" the file name of the file I have open ???

Should I do a PR accordingly to change the text of:

You can run `cider-jack-in-\*` while working with remote files over TRAMP. CIDER
)
?
-> I would propose to not use jack-in in any but the simplest remote scenario...

doc/modules/ROOT/pages/basics/up_and_running.adoc Outdated Show resolved Hide resolved
doc/modules/ROOT/pages/basics/up_and_running.adoc Outdated Show resolved Hide resolved
@vemv vemv marked this pull request as draft October 11, 2023 20:01
@vemv vemv closed this in b64213b Oct 12, 2023
@vemv
Copy link
Member

vemv commented Oct 12, 2023

I applied my last round of feedback directly, preserving attribution.

The results are here:

https://docs.cider.mx/cider/basics/up_and_running.html#working-with-containers-docker-or-others

Feel free to propose a new iteration anytime.

Cheers - V

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

Successfully merging this pull request may close these issues.

None yet

3 participants