Fork me on GitHub
#cider
<
2022-01-25
>
fjolne17:01:00

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 https://github.com/thheller/shadow-cljs/commit/285829fcc9113ad34d5b0d5e99f4e6c78874e2a4, maybe someone got it working? connecting to shadow's nrepl server, running shadow with latest nrepl, cider-nrepl, piggieback deps injected

1
zalky20:01:10

@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.

fjolne00:01:46

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 🥲

zalky20:01:38

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!

dawdler20:01:37

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

dpsutton20:01:24

can you post the full stacktrace?

dawdler20:01:44

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')

dpsutton20:01:39

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

dpsutton20:01:11

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

dawdler21:01:53

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

dawdler21:01:00

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

{:clojure.main/message
"Execution error (NullPointerException) at migratus.database/connect* (database.clj:133).\nCannot invoke \"java.sql.Connection.setAutoCommit(boolean)\" because \"conn\" is null\n",
:clojure.main/triage
{:clojure.error/class java.lang.NullPointerException,
:clojure.error/line 133,
:clojure.error/cause
"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},
:clojure.main/trace
{:via
[{:type clojure.lang.ExceptionInfo,
	:message "Error on key :db/datasource when building system",
	:data
	{:reason :integrant.core/build-threw-exception,
	:system {},
	:function
	#object[clojure.lang.MultiFn 0x54d16074 "clojure.lang.MultiFn@54d16074"],
	:key :db/datasource,
	:value
	{:db-spec
	{:dbtype "postgresql",
	:password
	"pazzword",
	:connectionInitSql "COMMIT;",
	:username "db_user",
	:port 5432,
	:dbname "my_database",
	:host "192.168.0.1",
	:maximumPoolSize 3}}},
	:at [integrant.core$build_exception invokeStatic "core.cljc" 285]}
	{:type java.lang.NullPointerException,
	:message
	"Cannot invoke \"java.sql.Connection.setAutoCommit(boolean)\" because \"conn\" is null",
	:at
	[migratus.database$connect_STAR_
	 invokeStatic
	 "database.clj"
	 133]}],
:trace
[[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 "RestFn.java" 410]
 [backend.db.datasource$eval26692$fn__26694
  invoke
  "datasource.clj"
  22]
 [clojure.lang.MultiFn invoke "MultiFn.java" 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$fn__8136$G__8131__8145
  invoke
  "protocols.clj"
  19]
 [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.protocols$fn__8110$G__8105__8123
  invoke
  "protocols.clj"
  13]
 [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 "RestFn.java" 397]
 [clojure.lang.AFn applyToHelper "AFn.java" 152]
 [clojure.lang.RestFn applyTo "RestFn.java" 132]
 [clojure.lang.Var applyTo "Var.java" 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 "RestFn.java" 137]
 [clojure.lang.Var applyTo "Var.java" 705]
 [clojure.main main "main.java" 40]],
:cause
"Cannot invoke \"java.sql.Connection.setAutoCommit(boolean)\" because \"conn\" is null"}}

dpsutton21:01:58

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

dpsutton20:01:38

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

dawdler20:01:07

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

dpsutton20:01:10

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

dawdler21:01:17

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

dpsutton21:01:46

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

👍 1
dawdler21:01:07

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?

dawdler21:01:01

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.

dpsutton21:01:09

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

dpsutton21:01:33

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

dawdler22:01:29

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
  :config
  (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

dpsutton22:01:19

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

dawdler22:01:53

No worries.

dawdler22:01:23

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