This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-03-22
Channels
- # announcements (16)
- # babashka (7)
- # babashka-sci-dev (14)
- # beginners (34)
- # calva (80)
- # clj-kondo (23)
- # cljdoc (17)
- # cljs-dev (1)
- # cljsrn (10)
- # clojure (51)
- # clojure-berlin (3)
- # clojure-europe (14)
- # clojure-italy (10)
- # clojure-nl (2)
- # clojure-norway (211)
- # clojure-uk (5)
- # clojurescript (4)
- # cursive (22)
- # datalevin (12)
- # datomic (2)
- # defnpodcast (1)
- # duct (5)
- # emacs (4)
- # events (2)
- # fulcro (3)
- # graalvm (1)
- # interop (3)
- # introduce-yourself (4)
- # java (1)
- # jobs (7)
- # kaocha (38)
- # leiningen (3)
- # lsp (11)
- # malli (4)
- # membrane (5)
- # music (1)
- # off-topic (28)
- # pathom (13)
- # pedestal (3)
- # polylith (4)
- # portal (10)
- # practicalli (1)
- # re-frame (33)
- # reitit (2)
- # remote-jobs (1)
- # sci (6)
- # shadow-cljs (49)
- # sql (4)
- # xtdb (3)
I've been trying to get Calva to work, but I can't connect to a REPL other than the getting started one. Even the Clojurescript Quickstart REPLs don't work. I've tried this on a number of different projects and I'm not sure what I'm doing wrong.
For one of the projects, I have as a deps.edn
{:paths ["src/main" "resources"]
:deps {org.clojure/clojure {:mvn/version "1.10.1"}
binaryage/oops {:mvn/version "0.7.0"}
bk/ring-gzip {:mvn/version "0.3.0"}
com.fulcrologic/fulcro {:mvn/version "3.2.12"}
com.fulcrologic/fulcro-garden-css {:mvn/version "3.0.7"}
com.taoensso/timbre {:mvn/version "4.10.0"}
com.wsscode/pathom {:mvn/version "2.2.31"}
funcool/cuerdas {:mvn/version "2020.03.26-3"}
hiccup {:mvn/version "1.0.5"}
juxt/crux-core {:mvn/version "20.08-1.10.1-beta"}
mount {:mvn/version "0.1.16"}
org.immutant/web {:mvn/version "2.1.10"}
ring/ring-core {:mvn/version "1.8.1"}
ring/ring-defaults {:mvn/version "0.3.2"}
tick {:mvn/version "0.4.26-alpha"}}
:aliases {:dev {:extra-paths ["src/dev" "src/workspaces"]
:extra-deps {org.clojure/clojurescript {:mvn/version "1.10.764"}
org.clojure/tools.namespace {:mvn/version "1.0.0"}
binaryage/devtools {:mvn/version "1.0.2"}
nubank/workspaces {:mvn/version "1.0.15"}
thheller/shadow-cljs {:mvn/version "2.8.109"}}}}}
Then for shadow-cljs.edn
{:nrepl {:port 9000}
:deps {:aliases [:dev]}
:dev-http {8000 "classpath:public"}
:builds {:main {:target :browser
:output-dir "resources/public/js/main"
:asset-path "/js/main"
:modules {:main {:init-fn prompt.client/init
:entries [prompt.client]}}
:devtools {:after-load prompt.client/refresh
:preloads [com.fulcrologic.fulcro.inspect.preload
prompt.development-preload]}}
:cards {:target nubank.workspaces.shadow-cljs.target
:ns-regexp "-(test|cards)$"
:output-dir "resources/public/js/workspaces"
:asset-path "/js/workspaces"
:preloads [com.fulcrologic.fulcro.inspect.preload]}}}
I start shadow-cljs in the terminal using npx shadow-cljs
. Then I run "Start or connect to a Clojure REPL" > "Connect to a running REPL in your project" > "deps.edn + shadow-cljs" > "localhost:9000" > ":main". I get the error
Failed starting cljs repl for build: :main. Is the build running and connected?
See the Output channel "Calva Connection Log" for any hints on what went wrong.
The output says
Socket closed
Socket closed
Execution error (FileNotFoundException) at user/eval5504 (REPL:1).
Could not locate shadow/cljs/devtools/api__init.class, shadow/cljs/devtools/api.clj or shadow/cljs/devtools/api.cljc on classpath.
Socket closed
Socket closed
Hi! Let’s the convo in one thread here. I’m not really familiar with the deps + shadow setup, but I think there has been some confusion around this and there is come improvement that could be added to Calva / the docs regarding this. You might find some helpful info here: https://github.com/BetterThanTomorrow/calva/issues/1591 and @U0ETXRFEW may be able to help more when he’s around.
From that issue: > I think it is due to that shadow-cljs dependencies are assumed to be present. You may be missing a necessary dependency (shadow.cljs.devtools ?), but I couldn’t say at the moment what exactly you need to do.
Thanks for posting the deps.edn
and shadow-cljs.edn
, @UGBKV7HHP. Calva tricks you a bit here. Since you are starting the project using npx shadow-cljs
you should connect to it using the shadow-cljs
project type. shadow-cljs.edn
has :deps {:aliases [:dev]}
which will make shadow take care of starting the project using clojure
.
Your command line for starting the project is not ensuring Calva's dependencies are met, though. Consider using Calva to start the project (a.k.a. Jack-in) or use Calva's command Copy Jack-in command-line to clipboard to get a command line you can use that makes Calva happy.
Ok I was able to get that project to work using plain "shadow-cljs" rather than "deps.edn + shadow-cljs" thank you
I have another project I'm trying to get working that doesn't use shadow-cljs. I tried "Start and Project REPL and Connect (aka Jack-in)" > "deps.edn" > "alias :dev". I tried Ctrl+Alt+C+Enter
on my user.clj. It doesn't seem to do anything. When I try to Alt+Enter
a form, the REPL says
; Syntax error compiling at (src/dev/user.clj:38:3).
; Unable to resolve symbol: start in this context
Put another way. If you run the command Load current file and dependencies from the command palette. Does something happen then?
When I choose that command from the command palette, I get the error:
Command 'Calva: Load Current File and Dependencies' resulted in an error (n.filter is not a function)
No, that was something different: https://github.com/BetterThanTomorrow/calva/issues/1567
I think all the symbols in my file are defined. Here's the user.clj:
(ns user
(:require
[clojure.java.browse :refer [browse-url]]
[com.walmartlabs.lacinia.pedestal2 :as lp]
[io.pedestal.http :as http]
[quiz.core :as quiz]))
(def schema (quiz/load-schema))
(defonce server nil)
(defn start-server
[_]
(let [server (-> schema
(lp/default-service {:graphiql true})
http/create-server
http/start)]
server))
(defn stop-server
[server]
(http/stop server)
nil)
(defn start
[]
(alter-var-root #'server start-server)
:started)
(defn stop
[]
(alter-var-root #'server stop-server)
:stopped)
(comment
"Execution error (ExceptionInfo) at com.walmartlabs.lacinia.schema/verify-fields-and-args (schema.clj:1524)."
"Field `Query/quiz' references unknown type `Quiz'."
(start)
(stop))
If something breaks before start
is defined, then it won't get defined. Maybe (quiz/load-schema)
results in an error?. Can you try it with clj
on the command line and see what happens? Calva can sometimes hide some error messages (we should fix that):
I double checked and one of my dependenices was broken. Once I fixed it, that error message went away thanks
How do you send a form within a comment? I'm using Alt+Enter
but I think that's sending the entire comment
It should work with Alt+Enter
. Also the error you got when start
wasn't defined, seems to indicate it worked then....
Ok when I Alt+Enter
on (start)
the REPL says:
; Syntax error compiling at (src/dev/user.clj:38:3).
; Unable to resolve symbol: start in this context
When I load the file, the REPL says:
; Evaluating file: user.clj
; Execution error (ExceptionInfo) at com.walmartlabs.lacinia.schema/verify-fields-and-args (schema.clj:1524).
; Field `Query/quiz' references unknown type `Quiz'.
; Evaluation of file user.clj failed: class clojure.lang.Compiler$CompilerException
Actually when I try to change the text of that comment and load the file again, it still shows the same error. Not sure if it's not loading the changes to my file or if that's a genuine error message
It's a little confusing sorry because it might be a real error and it might be reading out my comment
The messages in your comment there are just strings. You can alt enter on them and see them evaluate to themselves.
But when you load the file, the Clojure reader will not evaluate things in the comment
form. It is a macro defined like so:
(defmacro comment
"Ignores body, yields nil"
{:added "1.0"}
[& body])
Which means the Clojure Reader will read the forms there, but not evaluate them.Please consider posting a review https://marketplace.visualstudio.com/items?itemName=betterthantomorrow.calva&ssr=false#review-details ❤️
Hi, I am using Calva on the deps.edn
+ shadow-cljs
project.
For several days / weeks I have a problem with code navigation, linting, etc. when REPL is running.
I have created a minimal project / repo with this problem. I’m not sure if I’m doing something wrong or it’s a bug.
Thank you for any help.
https://github.com/stepankoci/vscode-calva (project contains readme with my setup and steps to problem reproduction)
Thank you!
I sent a PR. 😃 Let me know if it works. It's a bit tricky for me to test it right now.
Awesome, It’s working!
I’m expecting cider/cider-nrepl version should be in sync with version provided by copy jack-in command
?
Thank you very much!
> I’m expecting cider/cider-nrepl version should be in sync with version provided by copy jack-in command
?
Yes.
In Calva Calva 2.0.256 when I jack-in with deps.edn and do not select any alias, it tries to run clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version,"0.9.0"},cider/cider-nrepl {:mvn/version,"0.27.4"}}} '-M -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]"
which fails with
> Missing required argument for "-M ALIASES"
Any tips? Should I make a dummy, empty alias and use that one?
Hmmm, this might be related to https://github.com/BetterThanTomorrow/calva/issues/1611
I do get the list where I can select an alias, it is just that I do not want any of them :)
The command you pasted looks a bit funny just before -M
. There is a space before the '
instead of after it...
When I jack in it looks like
clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version,"0.9.0"},cider/cider-nrepl {:mvn/version,"0.27.4"}}}' -M -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]"
And no complaints.If I run your command line though, it complaints
WARNING: Implicit use of clojure.main with options is deprecated, use -M
And then it starts the REPL anyway.version info of things would be great, including clojure and jdk
Yes, it could be possible that that’s behavior from an older version of clojure
, but I’m not sure. -M
does not require the use of aliases.
You were right! I updated from clojure 1.10.1.619 to 1.10.3.1087 and now it works just fine
Dear Calva-friends: Here's next version of Calva https://19922-125431277-gh.circle-artifacts.com/0/tmp/artifacts/calva-2.0.257-dev-00abd8b2.vsix The Ux change here is more monorepo convenience when jacking in or connecting to a project. If there are more than one Clojure projects, Calva presents a menu. You can fuzzy search it to quickly find your project if the menu is long. I've been smiling using it at Pitch where we have a lot of projects in the repo and I often need to start three of them in parallell. I can now easily switch which project I am connected to. However, as simple as the change is on the Ux side, it is a major refactor in the code. It was all too stateful and I couldn't build more on top of it. The result is a rebuild of important Calva things and there is now much less statefulness + this feature. Sweet, huh? The catch? Haha, it is that now I hope you help me test it some. I've gone through all use cases I can think of, but there are sure more of them. Be creative please! Thanks to @corasaurus-hex, @domagala.lukas and @brandon.ringe for help with reviewing, suggestions, ideas, and cheering-ons! ❤️
Wow that search seems very fast. I tried this out on a polylith work project with several deps.edn files.
Is there a command I need to run to switch between running repls? I opened two repls, and all evaluations get sent to the second one. I’m guessing I need to switch connections somehow?
@U08TWB99B Calva can only be connected to one project at a time, So ”switching repls” means disconnecting from one and connecting to another. But Calva does the disconnect automatically when you connect to another repl, so .... well, try this: Start two repls from projects in the same repo/workspace (outside of Calva, so not jack-in). Then use Calva to connect to one of them. Then connect to the other.
Ok, thanks for clarifying. I’ll give it a try to connect to external repls. But, in the meantime, it’s awesome that I can use Calva in a monorepo now! I’ve been opening individual sub-directories in VSCode until now.
To your observation about the speed of the search, @brandon.ringe. It is a glob over all the files in the workspace. On my machine (a Mac M1 Max) it takes about 50-100 ms in the rather huge Pitch monorepo. I'm curious about the performance on less stellar machines. Calva logs the time the glob takes, so anyone reading this is encouraged to report the times printed in the console.
To avoid searching through large sub directories for naught, the search excludes some known non-project directories, like .git
, node_modules
, etcetera. This exclusion is configurable via the setting, calva.projectRootsSearchExclude
. Docs here: https://github.com/BetterThanTomorrow/calva/blob/dev/docs/site/connect.md#monorepos--multiple-clojure-projects-in-one-workspace
To see the impact the exclusion has, remove all entries in that setting and bring up the project root menu.
Hello folks! Any update about this issue? https://github.com/BetterThanTomorrow/calva/issues/1189
See this thread: https://clojurians.slack.com/archives/CBE668G4R/p1647974038051949. Just trying to keep the convo in one place. 😄
I don't think so, but I'm wondering if you can see anything in the vscode inspector console now? I recently added an assert to that function
ooo, I raised the original issue - I'll have a check next time it happens! My colleague had the same thing happen today so it could be something at a project level
well, the assert should result in a different error, that's all. I'd just like to confirm and see if the message is different
it's a side-effect of working towards changing some typescript options (turning on strictNullChecks)