Fork me on GitHub
#cider
<
2020-10-22
>
practicalli-john01:10:46

Getting a weird error when running cider-jack-in-clj with a Clojure CLI deps.edn project and using an alias with the -M flag rather than the deprecated -A flag (I've tried a few aliases with the same error). I have tried this with several versions of Clojure CLI tools installed, from 1.10.1.697 onwards. Using the -A flag does not give this error...

error in process sentinel: Could not start nREPL server: Execution error (FileNotFoundException) at java.io.FileInputStream/open0 (FileInputStream.java:-2).
-Sdeps (No such file or directory)
CIDER 1.0.0snapshot (package: <tel:202009301242|20200930.1242>) Update: In the #tools-deps channel I am asking if the -M flag has issues when the -Sdeps option is also supplied (as I cant seem to turn -Sdeps injection for cider-jack-in-clj off completely with variables in .dir-locals.el)

practicalli-john10:10:00

Root cause: When using a .dir-locals.el file to set (cider-clojure-cli-global-options . "-M:env/test") the -M flag and aliase is placed before -Sdeps when it should be placed after clojure [clj-opt*] -M[:aliases] [init-opt*] [main-opt] [arg*] -Sdeps is an clj-opt (as shown when running clojure -h in a terminal) A working command line with the -M flag and an :env/test alias should look as follows:

/usr/local/bin/clojure -Sdeps '{:deps {nrepl {:mvn/version "0.8.2"} refactor-nrepl {:mvn/version "2.5.0"} cider/cider-nrepl {:mvn/version "0.25.3"}}}' -M:env/test -m nrepl.cmdline --middleware '["refactor-nrepl.middleware/wrap-refactor", "cider.nrepl/cider-middleware"]'
The same positional rule applies for -A flag, however, the -A flag seems more flexible about following the rules. As a temporary work-around I can use the universal argument (C-u in Emacs / SPC-u in Spacemacs) before calling cider-jack-in and manually edit the command line, putting the alias in the right position. I still havent found a way to disable the -Sdeps from being injected. I can configure for an empty deps list, but have not found a way to prevent the -Sdeps option from being added, except by removing all arguments including the -M alias and -m main-namespace I'e raised an issue and see if I can figure out a PR, although I got a little lost looking at the jack-in code last time. https://github.com/clojure-emacs/cider/issues/2916

iarenaza21:10:11

@jr0cket @U06KGTXL5 I suggested a potential fix in the Github issue.

👍 6
cider 3
practicalli-john11:10:00

Pull request to fix the Clojure CLI projects ordering of parameters https://github.com/clojure-emacs/cider/pull/2917

theophilusx01:10:04

I am seeing the same error as @jr0cket, but using cider 20201020..1058 package

practicalli-john10:10:00
replied to a thread:Getting a weird error when running `cider-jack-in-clj` with a Clojure CLI `deps.edn` project and using an alias with the `-M` flag rather than the deprecated `-A` flag (I've tried a few aliases with the same error). I have tried this with several versions of Clojure CLI tools installed, from 1.10.1.697 onwards. Using the `-A` flag does not give this error... error in process sentinel: Could not start nREPL server: Execution error (FileNotFoundException) at java.io.FileInputStream/open0 (FileInputStream.java:-2). -Sdeps (No such file or directory) CIDER 1.0.0snapshot (package: <tel:202009301242|20200930.1242>) Update: In the #tools-deps channel I am asking if the `-M` flag has issues when the `-Sdeps` option is also supplied (as I cant seem to turn `-Sdeps` injection for `cider-jack-in-clj` off completely with variables in .dir-locals.el)

Root cause: When using a .dir-locals.el file to set (cider-clojure-cli-global-options . "-M:env/test") the -M flag and aliase is placed before -Sdeps when it should be placed after clojure [clj-opt*] -M[:aliases] [init-opt*] [main-opt] [arg*] -Sdeps is an clj-opt (as shown when running clojure -h in a terminal) A working command line with the -M flag and an :env/test alias should look as follows:

/usr/local/bin/clojure -Sdeps '{:deps {nrepl {:mvn/version "0.8.2"} refactor-nrepl {:mvn/version "2.5.0"} cider/cider-nrepl {:mvn/version "0.25.3"}}}' -M:env/test -m nrepl.cmdline --middleware '["refactor-nrepl.middleware/wrap-refactor", "cider.nrepl/cider-middleware"]'
The same positional rule applies for -A flag, however, the -A flag seems more flexible about following the rules. As a temporary work-around I can use the universal argument (C-u in Emacs / SPC-u in Spacemacs) before calling cider-jack-in and manually edit the command line, putting the alias in the right position. I still havent found a way to disable the -Sdeps from being injected. I can configure for an empty deps list, but have not found a way to prevent the -Sdeps option from being added, except by removing all arguments including the -M alias and -m main-namespace I'e raised an issue and see if I can figure out a PR, although I got a little lost looking at the jack-in code last time. https://github.com/clojure-emacs/cider/issues/2916

Steiner12:10:09

hey. how can I use cider to debug my code, I watch the doc, but found nothing I understand.

Steiner12:10:17

can you tell me how to operate??

Steiner12:10:47

sorry, I don't use spacemacs, but original one

practicalli-john12:10:31

only difference is C-M-x instead of , d b to start

Steiner12:10:44

eh, which one should I use??

Steiner12:10:24

eh, what operation should I do first??

practicalli-john12:10:36

C-u C-M-x with the cursor on a function will instrument that function. This adds breakpoints to that function. Then evaluate a call to that function using the usual key bindings or command A menu should appear above the instrumented function. Use n (next) to step through the evaluation of each expression or form in the function, using any arguments passed to that function.

Steiner15:10:33

I have to say, C-M-x in may key-bind is cider-eval

practicalli-john16:10:17

C-u C-M-x it seems. I dont use the cider keybindings, but the keybinding is described in the docs

Steiner12:10:26

another question, how to set proxy in cider, cider-jack-in failed because former proxy port is forbidden by me, and now I use a new port for proxy

Steiner15:10:09

eh, I am trying to debug in cider now, and I copy this code from doc:

(loop [i 0]
                  #break
                  (when (< i 10)
                    (println i)
                    (recur (inc i))))
but it throws me an error that
1. Caused by java.lang.RuntimeException
   Unmatched delimiter: )
what's happening??

Steiner15:10:45

ps: I am sure `

{:user {:plugins [[cider/cider-nrepl "0.9.0"]]}}
has been writen in my .lein/profile.clj

dpsutton15:10:57

that version was released in 2015.

Steiner15:10:52

what should I do

dpsutton15:10:14

i can't believe it even works. remove that from lein profiles. if you use cider-jack-in CIDER now makes sure the correct dependencies are added

Steiner15:10:46

you mean write [cider/cider-nrepl "0.9.0"] in to my project.clj??

dpsutton15:10:23

no. don't add anything. if you use cider-jack-in it will add it automatically. also, that version is from 2015 so you certainly shouldn't use that version in any case

Steiner16:10:29

but however, cider-toggle-trace-var only works when [cider/cier-nrepl] writen in .lein/profile.clj

dpsutton16:10:04

CIDER needs cider-nrepl on the classpath. if you remove that from your lein profiles, but you use cider-jack-in CIDER will add the correct version for you on startup

dpsutton16:10:05

/Users/dan/bin/lein update-in :dependencies conj \[nrepl\ \"0.8.2\"\] -- update-in :plugins conj \[cider/cider-nrepl\ \"0.25.3\"\] -- repl :headless :host localhost

dpsutton16:10:32

is an example of the way that CIDER starts up a lein project. as you can see, it includes the correct recent version of cider-nrepl for all features of CIDER to work correctly

dpsutton16:10:49

if you are starting your project in another manner then you are responsible for ensuring the dependencies are on the classpath. I'd recommend a profile and then lein with-profile +name-of-the-profile that includes the dep [cider/cider-nrepl "0.25.3"] or the most recent version of cider-nrepl

Steiner16:10:33

user-error: 'cider-toggle-trace-var' requires the nREPL op "toggle-trace-var" (provided by cider-nrepl)

Steiner16:10:49

I remove content of .lein/profile.clj

dpsutton16:10:44

how did you start your repl?

Steiner16:10:53

cider-jack-in

dpsutton16:10:58

at the top of the repl buffer do you see something like: ;; Startup: with a big command after it? can you post that?

dpsutton16:10:23

and what is the output of lein --version ?

Steiner16:10:55

2.8.1 maybe it's too low

dpsutton16:10:18

yeah. lein upgrade 2.9.4 should update it

Steiner16:10:09

hold on please, I install it from apt, now I want to build it from source, just for fun, can I do it??

dpsutton16:10:24

i guess? uninstall from apt and then do what you want

Steiner16:10:37

wow, I solve that after upgrade leiningen, thank you

👍 3
dpsutton16:10:10

and in general, never put stuff in lein/profiles. Use a profile in the project or let CIDER manage it for you

Steiner16:10:42

one more question ![image](https://docs.cider.mx/cider/_images/cider_debugger.gif) how can I do like this?? I copy it in my emacs, but find it not stop

Steiner17:10:01

and this is Startup message

;; Connected to nREPL server - 
;; CIDER 1.0.0-snapshot, nREPL 0.8.2
;; Clojure 1.8.0, Java 11.0.8
;;     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;
;; ======================================================================
;; If you're new to CIDER it is highly recommended to go through its
;; user manual first. Type <M-x cider-view-manual> to view it.
;; In case you're seeing any warnings you should consult the manual's
;; "Troubleshooting" section.