Fork me on GitHub
#calva
<
2022-11-17
>
Daniel Craig17:11:24

Is anyone using Calva inside Github Codespaces? I want to jack-in to my project but I'm finding that when I do Calva: start a project REPL (AKA jack-in) -> shadow-cljs -> :app -> :app that evaluating forms always returns nil. Here is the link to the project: https://github.com/danielmartincraig/danielmartincraig.net

stantheman23:11:51

Trying to add the Portal extension to vscode Calva. Running on WSL2 with Sean Corfield's setup https://github.com/seancorfield/vscode-calva-setup. Most things working but I cant get Portal to start clj says; clj꞉rich4clojure.hard.problem-091꞉> ; Execution error (ConnectException) at http://sun.nio.ch.Net/pollConnect (Net.java:-2). ; Connection refused terminal says; java -jar '/home/kali/.vscode-server/extensions/betterthantomorrow.calva-2.0.319/deps.clj.jar' -Sdeps '{:deps {nrepl/nrepl {:mvn/version,"1.0.0"},cider/cider-nrepl {:mvn/version,"0.28.5"}}}' -M:repl/conjure:clj-kondo:graph:nREPL nREPL server started on port 33811 on host localhost - <nrepl://localhost:33811> nREPL 1.0.0 Clojure 1.11.1 OpenJDK 64-Bit Server VM 17.0.5+8-Debian-2 ; looked at Portal guides, deps.edn and calva docs \O-_/ no idea what to check next???

seancorfield23:11:20

My workflow: • start REPL manually in WSL2 • connect Calva to it • send the command to start Portal for VS Code It looks like you're jacking-in via Calva (the deps.clj.jar command) -- is Portal a dependency in your :dev/conjure alias? Or in your project's main :deps? (otherwise you will not have the server-side Portal code) How are you trying to start Portal once your REPL is connected?

stantheman11:11:23

Thx Sean, yes I normally am jacking-in calva which works although I always have fun deciding where the relevant deps.edn should be atm it is same file in /.clojure and /.clojure/src/projname/. I try to start portal with ctrl+alt+space P which gave the above connection error. deps.edn file , very gross enclosed its gross as I have trying to learn via lots of rich4clojure problems! Jacking-in / deps gives following in terminal: java -jar '/home/kali/.vscode-server/extensions/betterthantomorrow.calva-2.0.319/deps.clj.jar' -Sdeps '{:deps {nrepl/nrepl {:mvn/version,"1.0.0"},cider/cider-nrepl {:mvn/version,"0.28.5"}}}' -M:repl/conjure:clj-kondo:graph:nREPL:portal WARNING: Specified aliases are undeclared and are not being used: [:portal] Downloading: clj-kondo/clj-kondo/maven-metadata.xml from clojars nREPL server started on port 35497 on host localhost - <nrepl://localhost:35497> nREPL 1.0.0 Clojure 1.11.1 OpenJDK 64-Bit Server VM 17.0.5+8-Debian-2 Interrupt: Control+C Exit: Control+D or (exit) or (quit) user=>

;; USER level deps.edn -these deps.edn at ~/.clojure will apply to all my projects
;; The deps.edn file describes the information needed to build a classpath.
;; When using the `clojure` or `clj` script, there are several deps.edn files
;; that are combined: - install-level - user level (this file) - project level (current directory when invoked)
;; For all attributes other than :paths, these config files are merged left to right.
;; Only the last :paths is kept and others are dropped.
{;; Paths
  ;;   Directories in the current project to include in the classpath
  ;; :paths ["src"]
  ;; External dependencies
	;; Aliases  resolve-deps aliases (-R) affect dependency resolution, options:
	;;     :extra-deps - specifies extra deps to add to :deps
	;;     :override-deps - specifies a coordinate to use instead of that in :deps
	;;     :default-deps - specifies a coordinate to use for a lib if one isn't found
	;;   make-classpath aliases (-C) affect the classpath generation, options:
	;;     :extra-paths - vector of additional paths to add to the classpath
	;;     :classpath-overrides - map of lib to path that overrides the result of resolving deps
 :deps {org.clojure/clojure {:mvn/version "1.11.1"},
        org.clojure/core.match {:mvn/version "1.0.0"},
        org.clojure/data.csv {:mvn/version "1.0.1"},
        net.cgrand/xforms {:mvn/version "0.19.4"},
        criterium/criterium {:mvn/version "0.4.6"},
        cheshire/cheshire {:mvn/version "5.11.0"},
        org.clojure/spec.alpha {:mvn/version "0.3.218"},
        org.clojure/core.specs.alpha {:mvn/version "0.2.62"},
        org.clojure/math.numeric-tower {:mvn/version "0.0.5"},
        org.clojure/math.combinatorics {:mvn/version "0.1.6"},
        org.clojure/data.priority-map {:mvn/version "0.0.5"},
        com.hyperfiddle/rcf {:mvn/version "20220926-202227"},
        rhizome/rhizome {:mvn/version "0.2.9"},
        djblue/portal {:mvn/version "0.33.0"},
        ;;  aysylu/loom {:mvn/version "1.0.2"},
        zprint/zprint {:mvn/version "1.2.4"}
        ;; dorothy/dorothy {:mvn/version "0.0.7"}
}  ;; Aliases
 :aliases
 {;; Conjure nvim for clojure
  :repl/conjure
  {:extra-deps {nrepl/nrepl       {:mvn/version "1.0.0"}
                djblue/portal     {:mvn/version "0.33.0"}
                refactor-nrepl/refactor-nrepl {:mvn/version "3.5.2"}
                cider/cider-nrepl {:mvn/version "0.28.5"}}
   :main-opts  ["-m", "nrepl.cmdline",
                "-e", "(use,'clojure.repl)(use,'clojure.java.javadoc)",
                "--middleware", "[cider.nrepl/cider-middleware,portal.nrepl/wrap-portal]",
                "--interactive"]},
  :clj-kondo
  {:replace-deps {clj-kondo/clj-kondo {:mvn/version "RELEASE"}}
   :main-opts ["-m", "clj-kondo.main"]},
  :graph
  {:graph {:replace-deps {org.clojure/tools.deps.graph {:mvn/version "1.1.68"}}
          ;; :main-opts ["-m" "clojure.tools.deps.graph"] ;; deprecated
           :ns-default clojure.tools.deps.graph}},
  :nREPL
  {:extra-deps {cider/cider-nrepl {:mvn/version "0.28.5"}
                djblue/portal     {:mvn/version "0.33.0"}
                nrepl/nrepl {:mvn/version "1.0.0"}
                refactor-nrepl/refactor-nrepl {:mvn/version "3.5.2"}}
   :main-opts ["-m" "nrepl.cmdline",
               "-e", "(use,'clojure.repl)(use,'clojure.java.javadoc)",
               "--middleware", "[cider.nrepl/cider-middleware,portal.nrepl/wrap-portal]",
               "--interactive"]},
  :test
  {:extra-paths ["test"]
   :extra-deps {io.github.cognitect-labs/test-runner
                {:git/tag "v0.5.1" :git/sha "dfb30dd"}}
   :main-opts ["-m", "cognitect.test-runner"]
   :exec-fn cognitect.test-runner.api/test}

  ;; :zprint {:extra-deps {org.clojure/clojure {:mvn/version "1.11.1"}
  ;;                       zprint/zprint {:mvn/version "1.2.3"}}
  ;;          :main-opts ["-m", "zprint.main"]}
  }
;   :deps {:extra-deps {org.clojure/tools.deps.alpha {:mvn/version "0.14.1178"}}}
  ;;   :test {:extra-paths ["test"]}
 }
  ;; Provider attributes
  ;; :mvn/repos {
  ;;   "central" {:url ""}
  ;;   "clojars" {:url ""}}

stantheman11:11:12

The full exception & stacktrace on ctrl alt space P is clj꞉user꞉> ; Use alt+enter to evaluate ; Jack-in done. clj꞉user꞉> clj꞉rich4clojure.hard.problem-091꞉> ; Execution error (ConnectException) at (Net.java:-2). ; Connection refused clj꞉rich4clojure.hard.problem-091꞉> clojure.lang.Compiler$InvokeExpr/eval (Compiler.java:3719) clojure.lang.Compiler$DefExpr/eval (Compiler.java:457) clojure.lang.Compiler/eval (Compiler.java:7199) clojure.core/eval (core.clj:3215) clojure.core/eval (core.clj:3211) nrepl.middleware.interruptible-eval/evaluate (interruptible_eval.clj:87) clojure.core/apply (core.clj:667) clojure.core/with-bindings* (core.clj:1990) nrepl.middleware.interruptible-eval/evaluate (interruptible_eval.clj:87) clojure.main/repl (main.clj:437) clojure.main/repl (main.clj:458) clojure.main/repl (main.clj:368) nrepl.middleware.interruptible-eval/evaluate (interruptible_eval.clj:84) nrepl.middleware.interruptible-eval/evaluate (interruptible_eval.clj:56) nrepl.middleware.interruptible-eval/interruptible-eval (interruptible_eval.clj:152) nrepl.middleware.session/session-exec (session.clj:218) nrepl.middleware.session/session-exec (session.clj:217) java.lang.Thread/run (Thread.java:833)

seancorfield17:11:27

WARNING: Specified aliases are undeclared and are not being used: [:portal]
That says :portal is not a known alias and that's why Portal is not starting up and you can't connect.

seancorfield17:11:05

~/.clojure/src/projname/ seems like a very strange place to have project files?

seancorfield17:11:27

Oh, I see you have djblue/portal specific in multiple aliases...

seancorfield17:11:18

Once your REPL is started, can you manually type in (require '[portal.api :as p]) and if that works, (p/open {:port 7654}) and see if you get a browser open (assuming you have a browser installed on Debian)?

stantheman17:11:28

Thanks I'm sanitising java / clojure etc in the WSL2 completely, to be able to run up a repl from linux and then run vscode and connect separately. Had some early success after adding Debians unstable to my apt and loading Temurix jvm. This allows portal to start in the manually Tap> values mode. I'm working on getting the portal.wrap middleware working next. When I 'Connect to a repl outside your project' it seems to work but gives a strange error that cider is missing and Calva cant issue a Info to the remote repl. But the Portal is opening and I can Tap> to it!

seancorfield17:11:54

OK, sounds like you're making progress 🙂

stantheman17:11:05

Yes thanks, I was reading the nRepl docs which led me to try adding cider middleware in the nRepl Server configuration files but this is hitting a clj -Sdeps '{:deps {nrepl/nrepl {:mvn/version "1.0.0"}}}' -M: -m nrepl.cmdline Execution error (FileNotFoundException) at nrepl.cmdline/require-and-resolve (cmdline.clj:220). Could not locate cider/nrepl__init.class, cider/nrepl.clj or cider/nrepl.cljc on classpath.

seancorfield17:11:53

You need cider-nrepl instead of just nrepl

stantheman17:11:25

I think I've made some circular complications and am missing a clean directory layout. clj -Sdescribe {:version "1.11.1.1200" :config-files ["/usr/local/lib/clojure/deps.edn" "/home/kali/.clojure/deps.edn" "deps.edn" ] :config-user "/home/kali/.clojure/deps.edn" :config-project "deps.edn" :install-dir "/usr/local/lib/clojure" :config-dir "/home/kali/.clojure" :cache-dir ".cpcache" :force false :repro false :main-aliases "" :repl-aliases ""}

stantheman17:11:59

Hmm now it does find refactor clj -Sdeps '{:deps {cider/cider-nrepl {:mvn/version "0.28.5"}}}' -M: -m nrepl.cmdline Execution error (FileNotFoundException) at nrepl.cmdline/require-and-resolve (cmdline.clj:201). Could not locate refactor_nrepl/middleware__init.class, refactor_nrepl/middleware.clj or refactor_nrepl/middleware.cljc on classpath. Please check that namespaces with dashes use underscores in the Clojure file name.

seancorfield18:11:46

refactor-nrepl is not part of CIDER -- how are you specifying the middleware to load?

stantheman18:11:45

Yes just trying commenting out refactor in the deps.edn files but I am also checking something the nRepl docs led me to try which was a nRepl config (global / user) so I may have to clear those as well - doh!

stantheman18:11:21

The nrepl config was in with a refactor wrap .nrepl/nrepl.edn. Grand deleted refactor in there as well. Now I can start nrepl from kali-linux clj -Sdeps '{:deps {cider/cider-nrepl {:mvn/version "0.28.5"}}}' -M: -m nrepl.cmdline and code launches vscode then I connected with 'Connect to repl not in proj' / deps/ ... And Ctrl Alt space P launches Portal yah! I can Tap> stuff to Portal toexamine tah-dah. I think Ill leave the idea of the portal-wrap till another time. Ill concentrate on backup / git'ing this config so far.... Thanks v much for the splendid help have a good week-end Sean

seancorfield18:11:47

Cool! Enjoy Portal 🙂

stantheman18:11:25

Yeah thx busy on spreadsheets now for she who must be obeyed to compare groceries 😅