furkan3ayraktar / clojure-polylith-realworld-example-app

Clojure, Polylith and Ring codebase containing real world examples (CRUD, auth, advanced patterns, etc) that adheres to the RealWorld spec and API.
MIT License
448 stars 79 forks source link

Problem running the project with Emacs/Cider #32

Closed BuddhiLW closed 11 months ago

BuddhiLW commented 1 year ago

I'm using cider, M-x cider-jack-in-clj,

Full report at:
/tmp/clojure-14664372717496286616.edn
 ("exited abnormally with code 1")
[nREPL] Starting server via /bin/clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version "1.0.0"} cider/cider-nrepl {:mvn/version "0.30.0"} refactor-nrepl/refactor-nrepl {:mvn/version "3.6.0"}} :aliases {:cider/nrepl {:main-opts ["-m" "nrepl.cmdline" "--middleware" "[refactor-nrepl.middleware/wrap-refactor,cider.nrepl/cider-middleware]"]}}}' -M:cider/nrepl
error in process sentinel: nrepl-server-sentinel: Could not start nREPL server: Execution error (FileNotFoundException) at java.io.FileInputStream/open0 (FileInputStream.java:-2).
-Sdeps (No such file or directory)

And the full report says:

{:clojure.main/message
 "Execution error (FileNotFoundException) at java.io.FileInputStream/open0 (FileInputStream.java:-2).\n-Sdeps (No such file or directory)\n",
 :clojure.main/triage
 {:clojure.error/class java.io.FileNotFoundException,
  :clojure.error/line -2,
  :clojure.error/cause "-Sdeps (No such file or directory)",
  :clojure.error/symbol java.io.FileInputStream/open0,
  :clojure.error/source "FileInputStream.java",
  :clojure.error/phase :execution},
 :clojure.main/trace
 {:via
  [{:type java.io.FileNotFoundException,
    :message "-Sdeps (No such file or directory)",
    :at [java.io.FileInputStream open0 "FileInputStream.java" -2]}],
  :trace
  [[java.io.FileInputStream open0 "FileInputStream.java" -2]
   [java.io.FileInputStream open "FileInputStream.java" 216]
   [java.io.FileInputStream <init> "FileInputStream.java" 157]
   [java.io.FileInputStream <init> "FileInputStream.java" 111]
   [clojure.lang.Compiler loadFile "Compiler.java" 7588]
   [clojure.main$load_script invokeStatic "main.clj" 475]
   [clojure.main$script_opt invokeStatic "main.clj" 535]
   [clojure.main$script_opt invoke "main.clj" 530]
   [clojure.main$main invokeStatic "main.clj" 664]
   [clojure.main$main doInvoke "main.clj" 616]
   [clojure.lang.RestFn applyTo "RestFn.java" 137]
   [clojure.lang.Var applyTo "Var.java" 705]
   [clojure.main main "main.java" 40]],
  :cause "-Sdeps (No such file or directory)"}}
furkan3ayraktar commented 1 year ago

I have no experience with Emacs/Cider, so I don't know what the issue is here. The stack trace is not very helpful either. One thing that comes to mind is if you included the correct aliases when starting your REPL. :dev and :test aliases should be included while starting the REPL for the project to work. Have you figured out any solutions yet?

BuddhiLW commented 1 year ago

I haven't. I was reading about polylith, and wanted to inspect the project, locally. Upon being stuck, I just documented the error, here, and moved on.

The stack trace is not very helpful either. 

I agree.

One thing that comes to mind is if you included the correct aliases when starting your REPL. :dev and :test aliases should be included while starting the REPL for the project to work.

I don't have this option, upon cider start and until I get the error

furkan3ayraktar commented 1 year ago

It could be a good idea to ask this question in Clojurians Slack. There may be some people using Emac/Cider together with Polylith.

vemv commented 1 year ago

(CIDER maintainer here)

I was able to run this project in CIDER without a problem.

Does the /bin/clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version "1.0.0"} cider/cider-nrepl {:mvn/version "0.30.0"} refactor-nrepl/refactor-nrepl {:mvn/version "3.6.0"}} :aliases {:cider/nrepl {:main-opts ["-m" "nrepl.cmdline" "--middleware" "[refactor-nrepl.middleware/wrap-refactor,cider.nrepl/cider-middleware]"]}}}' -M:cider/nrepl command pass on a vanilla shell?

I don't have this option, upon cider start and until I get the error

Yes, you do, it's the cider-clojure-cli-aliases option. See https://docs.cider.mx/cider/basics/up_and_running.html or simply query the cider-clojure-cli-aliases docs within Emacs

cider/cider-nrepl {:mvn/version "0.30.0"} indicates you're a touch behind. I'd recommend using CIDER at Git master or its latest snapshot (20231008.2124 as of today).

If it persists after trying all those, feel free to create a detailed issue in CIDER.

Cheers - V

seancorfield commented 1 year ago

I suspect your clojure command is either very old or is not the official CLI.

What does clojure -version display?

BuddhiLW commented 11 months ago

You are right.

I recently reformatted my PC and just fresh-installed Clojure and Cider.

The project runs as it should.

Thanks people!

BuddhiLW commented 11 months ago

Just to make an addendum, I use doom emacs, and all my packages are installed through doom extensions. And, I regularly update it.

The current repl spawn message is the following:

nREPL server started on port 42277 on host localhost - nrepl://localhost:42277
;; Connected to nREPL server - nrepl://localhost:42277
;; CIDER 1.7.0-snapshot (package: 1.7.0-snapshot), nREPL 1.0.0
;; Clojure 1.11.1, Java 17.0.9-ea
;;     Docs: (doc function-name)
;;           (find-doc part-of-name)
;;   Source: (source function-name)
;;  Javadoc: (javadoc java-object-or-class)
;;     Exit: <C-c C-q>
;;  Results: Stored in vars *1, *2, *3, an exception in *e;
;;  Startup: /usr/local/bin/clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version "1.0.0"} cider/cider-nrepl {:mvn/version "0.30.0"} refactor-nrepl/refactor-nrepl {:mvn/version "3.6.0"}} :aliases {:cider/nrepl {:main-opts ["-m" "nrepl.cmdline" "--middleware" "[refactor-nrepl.middleware/wrap-refactor,cider.nrepl/cider-middleware]"]}}}' -M:cider/nrepl
user> 
vemv commented 11 months ago

That's the standard CIDER repl init message. Probably can be customized away.

That CIDER is quite behind, but they're on it

BuddhiLW commented 11 months ago

I can enforce a package to be fetched from github, for example. I will do that with Cider, for now. Thanks for the heads up.


A question, I'm trying to use .dir-locales.el in order to modify cider-clojure-cli-aliases. But, I'm not sure how I would do it.

;; cider-clojure-cli-aliases
((cider-clojure-cli-aliases . ":dev"))

As, the emacs doc:

cider-clojure-cli-aliases is a variable defined in ‘cider.el’.

Its value is nil

A list of aliases to include when using the clojure cli.
Alias names should be of the form ":foo:bar".
Leading "-A" "-M" "-T" or "-X" are stripped from aliases
then concatenated into the "-M[your-aliases]:cider/nrepl" form.

  This variable is safe as a file local variable if its value
  satisfies the predicate ‘stringp’.
  This variable was introduced, or its default value was changed, in
  version 1.1 of the cider package.
  You can customize this variable.

Currently, I'm unable to inject the :dev alias

vemv commented 11 months ago

It's named .dir-locals.el (probably you didn't make that typo, but just in case)

If it's not getting picked up that's a generic Emacs problem. I'd try luck over Clojurians #emacs or #doom-emacs

BuddhiLW commented 11 months ago

Thanks for the correction. I committed the typo only here, indeed.

Well, I went raw for the M-x customize... which is not ideal. But, I was able to run everything.

That's more than enough for now! :)

pic-full-231106-1622-00