Search code examples
clojureclojurescriptcidernreplshadow-cljs

Although CIDER works without projects and the Clojure project is successfully built, why I can't bring both things together?


I have a Clojure/ClojureScript project that I am able to build locally. The project is built with the following command:


Pedros-MacBook-Air:balance pedro$ shadow-cljs watch app

shadow-cljs - config: /Users/pedro/projects/balance/shadow-cljs.edn
NPM dependency "highlight.js" has installed version "^9.16.2"
"11.1.0" was required by jar:file:/Users/pedro/.m2/repository/superstructor/re-highlight/1.1.0/re-highlight-1.1.0.jar!/deps.cljs
shadow-cljs - HTTP server available at http://localhost:3005
shadow-cljs - server version: 2.15.3 running at http://localhost:9630
shadow-cljs - nREPL server started on port 8230
shadow-cljs - watching build :app
[:app] Configuring build.
[:app] Compiling ...
[:app] Build completed. (1155 files, 3 compiled, 4 warnings, 10.88s)

Ok. It works!

Also, I am able to use CIDER without a project. After having to answer the question below with y:

Are you sure you want to run `cider-jack-in' without a Clojure project? (y or n) y

I am able to run CIDER and I have REPL powers. Ok.

So, shadow-cljs and CIDER both wok, but separately. Now, I want to have both running together!

However, in the above-mentioned project successfully built, I can't use CIDER jack-in nor cider-connect.

My first attempt was simply moving with Emacs to the project directory and doing cider-jack-in which returns:

enter image description here

The mini-buffer does not allow me to type the shadow-cljs watch app command. I cannot even introduce whitespaces.

If I just insert the first desired word, shadow-cljs, Emacs returns that

user-error: The npx shadow-cljs executable isn’t on your ‘exec-path’

I must highlight that the same error message is retrieved no matter what the specific cider-jack-in used. Both cider-jack-in and cider-jack-in-cljs retrieve the same error message.

I do not how exactly to solve it. Why I can't even type things with freedom?

My second attempt was trying cider connect. For the info on host and port, I used the "build data" provided earlier:

shadow-cljs - HTTP server available at http://localhost:3005
shadow-cljs - server version: 2.15.3 running at http://localhost:9630
shadow-cljs - nREPL server started on port 8230

First, the mini-buffer asked for Host: which I replied with:

http://localhost

And then for Port:, which I replied with:

8320

I got:

nrepl-connect: [nREPL] Direct connection to http://localhost:8230 failed; try setting ‘nrepl-use-ssh-fallback-for-remote-hosts’ to t

After that, I tried an eval of the s-expression below via eval-expression (bounded to M :):

(setq nrepl-use-ssh-fallback-for-remote-hosts t) 

But, it was not enough. Emacs returns:

nrepl--ssh-tunnel-connect: [nREPL] SSH port forwarding failed.  Check the ’*nrepl-tunnel projects/balance:localhost*<2>’ buffer

If I switch buffer to *nrepl-tunnel projects/balance:localhost*<2> this is what I have:

OpenSSH_8.6p1, LibreSSL 3.3.6
debug1: Reading configuration data /Users/pedro/.ssh/config
debug1: /Users/pedro/.ssh/config line 1: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 21: include /etc/ssh/ssh_config.d/* matched no files
debug1: /etc/ssh/ssh_config line 54: Applying options for *
debug1: /etc/ssh/ssh_config line 58: Applying options for *
debug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling
debug1: Connecting to http port 22.
ssh: Could not resolve hostname http: nodename nor servname provided, or not known

Process nrepl-tunnel exited abnormally with code 255

Obs.: I am using macOS 12.5 on a MacBook Air M1. Is this a possible solution?

How can I solve this?

Thanks


Solution

  • You're trying to run a ClojureScript project as a Clojure project. You should use cider-jack-in-cljs instead. When prompted select shadow-cljs as command to be used, shadow for ClojureScript REPL type and app for shadow-cljs build.