Fork me on GitHub

hello! have been trying to make cider-pprint-eval-defun-at-point work in CLJS repl with shadow, which seems to be implemented on the shadow side for, maybe someone got it working? connecting to shadow's nrepl server, running shadow with latest nrepl, cider-nrepl, piggieback deps injected


@UDQ2UEPMY, just tried this in my shadow build and it seems to work. I'm on cider 1.1.0, nrepl 0.8.3, and cider-nrepl 0.26.0. I don't think piggieback is relevant for a shadow-cljs connection since it has its own middleware to make a cljs repl.


thank you! turned out pretty printing just broke on all my inputs because of #js tags and some other stuff, I wasn't smart enough to test it on pure data first 🥲


Hi all, wondering what would be the best way to ensure that I have (set! *print-namespace-maps* nil) automatically set when I connect an nrepl via cider. Would it be a cider or nrepl configuration point? Thanks!


Does anybody have any helpful info as to why emacs process hangs, eating 100% CPU and me not being able to interact with the terminal, when running cider and nrepl via cider-jack-in? Appears to happen everytime I encounter a ClassCastException? clojure-cli command:

/usr/local/bin/clojure  -Sdeps '{:deps {nrepl/nrepl {:mvn/version "0.9.0"} refactor-nrepl/refactor-nrepl {:mvn/version "3.2.0"} cider/cider-nrepl {:mvn/version "0.28.1"}} :aliases {:cider/nrepl {:main-opts ["-m" "nrepl.cmdline" "--middleware" "[refactor-nrepl.middleware/wrap-refactor,cider.nrepl/cider-middleware]"]}}}' -M:dev:cider/nrepl


can you post the full stacktrace?


This? Or debug info from emacs, I appear not to get the latter, since everything just freezes.

Execution error (ClassCastException) at migratus.database/connect* (database.clj:132).         
class com.zaxxer.hikari.HikariDataSource cannot be cast to class java.sql.Connection (com.zaxxer.hikari.HikariDataSource is in unnamed module of loader 'app'; java.sql.Connection is in module java.sql of loader 'platform')


that’s just normal application code it appears. You are trying to run migrations and its not happy


if you run clj -M:dev in a terminal what happens?


yeah, just a stupid code error, but that's all the info that pops up. will try your suggestion


here's the stacktrace causing emacs to become unresponsive, running clj -M:dev

"Execution error (NullPointerException) at migratus.database/connect* (database.clj:133).\nCannot invoke \"java.sql.Connection.setAutoCommit(boolean)\" because \"conn\" is null\n",
{:clojure.error/class java.lang.NullPointerException,
:clojure.error/line 133,
"Cannot invoke \"java.sql.Connection.setAutoCommit(boolean)\" because \"conn\" is null",
:clojure.error/symbol migratus.database/connect*,
:clojure.error/source "database.clj",
:clojure.error/phase :execution},
[{:type clojure.lang.ExceptionInfo,
	:message "Error on key :db/datasource when building system",
	{:reason :integrant.core/build-threw-exception,
	:system {},
	#object[clojure.lang.MultiFn 0x54d16074 "clojure.lang.MultiFn@54d16074"],
	:key :db/datasource,
	{:dbtype "postgresql",
	:connectionInitSql "COMMIT;",
	:username "db_user",
	:port 5432,
	:dbname "my_database",
	:host "",
	:maximumPoolSize 3}}},
	:at [integrant.core$build_exception invokeStatic "core.cljc" 285]}
	{:type java.lang.NullPointerException,
	"Cannot invoke \"java.sql.Connection.setAutoCommit(boolean)\" because \"conn\" is null",
[[migratus.database$connect_STAR_ invokeStatic "database.clj" 133]
 [migratus.database$connect_STAR_ invoke "database.clj" 117]
 [migratus.database.Database init "database.clj" 255]
 [migratus.core$init invokeStatic "core.clj" 170]
 [migratus.core$init doInvoke "core.clj" 167]
 [clojure.lang.RestFn invoke "" 410]
 [clojure.lang.MultiFn invoke "" 234]
 [integrant.core$try_build_action invokeStatic "core.cljc" 294]
 [integrant.core$try_build_action invoke "core.cljc" 293]
 [integrant.core$build_key invokeStatic "core.cljc" 302]
 [integrant.core$build_key invoke "core.cljc" 298]
 [clojure.core$partial$fn__5861 invoke "core.clj" 2643]
 [clojure.core.protocols$fn__8181 invokeStatic "protocols.clj" 168]
 [clojure.core.protocols$fn__8181 invoke "protocols.clj" 124]
 [clojure.core.protocols$seq_reduce invokeStatic "protocols.clj" 31]
 [clojure.core.protocols$fn__8168 invokeStatic "protocols.clj" 75]
 [clojure.core.protocols$fn__8168 invoke "protocols.clj" 75]
 [clojure.core$reduce invokeStatic "core.clj" 6830]
 [clojure.core$reduce invoke "core.clj" 6812]
 [integrant.core$build invokeStatic "core.cljc" 325]
 [integrant.core$build invoke "core.cljc" 305]
 [integrant.core$init invokeStatic "core.cljc" 431]
 [integrant.core$init invoke "core.cljc" 423]
 [integrant.core$init invokeStatic "core.cljc" 428]
 [integrant.core$init invoke "core.cljc" 423]
 [backend.system$run invokeStatic "system.clj" 31]
 [backend.system$run invoke "system.clj" 30]
 [backend.core$_main invokeStatic "core.clj" 9]
 [backend.core$_main doInvoke "core.clj" 7]
 [clojure.lang.RestFn invoke "" 397]
 [clojure.lang.AFn applyToHelper "" 152]
 [clojure.lang.RestFn applyTo "" 132]
 [clojure.lang.Var applyTo "" 705]
 [clojure.core$apply invokeStatic "core.clj" 667]
 [clojure.main$main_opt invokeStatic "main.clj" 514]
 [clojure.main$main_opt invoke "main.clj" 510]
 [clojure.main$main invokeStatic "main.clj" 664]
 [clojure.main$main doInvoke "main.clj" 616]
 [clojure.lang.RestFn applyTo "" 137]
 [clojure.lang.Var applyTo "" 705]
 [clojure.main main "" 40]],
"Cannot invoke \"java.sql.Connection.setAutoCommit(boolean)\" because \"conn\" is null"}}


i’m wondering why its trying to do stuff. Do you have any top level stuff in user.clj?


and might be helpful to copy that and run it in a terminal


No difference when running repl in terminal and using cider-connect


Things i do to diagnose: start removing the refactor stuff as sometimes that can get out of date. If still an error, try in a blank project to ensure that its not related to the particular project


Thanks, will try and remove refactor stuff, thing is, this has happened for a while now, even before I added refactor yesterday.


yeah. my general idea is to remove all tooling, ensure that it fundamentally works. Then slowly reintroduce a single tool at a time.

👍 1

bah, removing all the extra stuff did not bring emacs to silence. thanks, @dpsutton. Said differently: Problem solved.

🎉 1
Nick McAvoy21:01:03

But what was the problem?


I am too embarrassed to tell, but here it is: never ever blindly copy some random person's cider config and expect it to work. I should have known, but I was desperately trying to tidy up my emacs config, and forgot to clean up the cider specific one. Shit happens.


what was the offending bit? Knowing the issue can help others in the future. I doubt you’ll be the last person to have this and it could help diagnosing in the future


There’s no embarrassment about using a config and there being a foot-gun. It’d be nice to know the footgun for the future though


Good point.

(use-package cider
  :ensure t
  :defer t
  :init (add-hook 'cider-mode-hook #'clj-refactor-mode) 
  :diminish subword-mode ;; <-- THIS WAS THE CULPRIT
  (setq nrepl-log-messages t                  
        cider-repl-display-in-current-window t
        cider-repl-use-clojure-font-lock t    
        cider-prompt-save-file-on-load 'always-save
        cider-font-lock-dynamically '(macro core function var)
        nrepl-hide-special-buffers t            
        cider-overlays-use-font-lock t)         
  (cider-repl-toggle-pretty-printing) )
Ijust simply didn't have the package installed


i would never have thought to look there. So thanks for sharing. And that’s super subtle. Not stupid at all


No worries.


And thanks for pushing me in the right direction.

👍 1
Nick McAvoy22:01:37

I've written less than 1% of the shell or emacs config that I use, so I can definitely relate! Very understandable. Kudos for sticking with it and finding the issue!

👍 1