cider icon indicating copy to clipboard operation
cider copied to clipboard

Can't cider-jack-in to projects with private git dependencies

Open PavlosMelissinos opened this issue 1 year ago • 7 comments

Expected behavior

cider-jack-in works in projects with private git repos

Actual behavior

I'm getting some text in the nrepl-server buffer that asks for my passphrase but there's no interactive prompt, so I can't provide it to complete the process. Here's the exact message "prompt" as it appears in the nrepl buffer:

Cloning: [email protected]:org/private-repo-name.git

Enter passphrase for key '/home/pavlos/.ssh/id_ed25519': 

Steps to reproduce the problem

Create a deps.edn with the following contents

{:deps {foo/bar {:git/url "[email protected]:org/private-repo-name.git"
                 :sha     "sha"}}}

where org/private-repo-name is a private repo

Run M-x cider-jack-in

Environment & Version information

CIDER version information

;; CIDER 1.12.0 (Split), nREPL 1.0.0
;; Clojure 1.11.1, Java 21.0.1

Lein / Clojure CLI version

Clojure CLI version 1.11.1.1149

Emacs version

GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.37, cairo version 1.16.0)

Operating system

Fedora 39

JDK distribution

openjdk version "21.0.1" 2023-10-17
OpenJDK Runtime Environment (Red_Hat-21.0.1.0.12-4) (build 21.0.1+12)
OpenJDK 64-Bit Server VM (Red_Hat-21.0.1.0.12-4) (build 21.0.1+12, mixed mode, sharing)

PavlosMelissinos avatar Dec 31 '23 01:12 PavlosMelissinos

In case anyone else is facing this, here are some workarounds:

  1. Spawn a standalone cider/nrepl server and cider-connect to it, as described in the docs
  2. Download the dependencies with clojure -P and then rerun cider-jack-in

(Many thanks to @vemv and @dpsutton from Clojurians slack for the suggestions)

PavlosMelissinos avatar Dec 31 '23 01:12 PavlosMelissinos

Hi!

Thanks much for the report.

I'll try to repro it, anyway could you please provide the exact prompt text?

vemv avatar Dec 31 '23 13:12 vemv

Good point, it's:

Cloning: [email protected]:org/private-repo-name.git

Enter passphrase for key '/home/pavlos/.ssh/id_ed25519': 

Like I said it only appears in the ~REPL~ nrepl-server buffer (and it's not interactive) I've added it to the initial description too

PavlosMelissinos avatar Dec 31 '23 15:12 PavlosMelissinos

Are you able to git-clone the same repo using e.g. Magit?

If not, it could indicate a generalized issue in your Emacs setup, such that ssh-add isn't being correctly invoked.

Example:

[...] You can confirm this by running eval $(ssh-agent); ssh-add ~/.ssh/id_rsa in a terminal, and then in the same terminal emacs &.

That solution isn't exactly ergonomic, but it would be a start.

Please try that specific approach for CIDER and/or Magit, allowing us to discard hypotheses.

Thanks - V

vemv avatar Jan 01 '24 07:01 vemv

Are you able to git-clone the same repo using e.g. Magit?

Yes! If I delete the cache from .gitlibs and run magit-clone directly I get the correct prompt (same message but interactive)

PavlosMelissinos avatar Jan 01 '24 22:01 PavlosMelissinos

Thanks!

To be clear, is your expected workflow entering the passphrase each time? It would make sense, although perhaps in your terminal emulator you don't have to?

vemv avatar Jan 01 '24 22:01 vemv

is your expected workflow entering the passphrase each time

I believe that depends on how the ssh agent is set up. So it doesn't happen always (I think) but:

  • when ssh-agent needs a passphrase I expect emacs/CIDER to ask for the user input correctly (magit-clone does so, so I assume it's caused by something that happens somewhere between the git and cider abstraction levels)
  • when a passphrase isn't necessary, I expect CIDER to be able to clone the repo and then start the REPL (neither happens in my case, CIDER gets stuck "waiting" for user input that will never come).

PavlosMelissinos avatar Jan 01 '24 23:01 PavlosMelissinos