Good Morning Clojurians, When I try to follow: https://book.fulcrologic.com/#_build_it, and and execute:
[I] /home/sporty/clojure/fulcro/app1~> npx shadow-cljs server
shadow-cljs - config: /home/sporty/clojure/fulcro/app1/shadow-cljs.edn
shadow-cljs - starting via "clojure"
shadow-cljs - HTTP server available at <http://localhost:8000>
shadow-cljs - server version: 2.11.8 running at <http://localhost:9630>
shadow-cljs - nREPL server started on port 9000
I am trying to connect to it with https://liquidz.github.io/vim-iced/#clojurescript_shadow_cljs, the vim-iced, requires execution of
$ iced repl {YOUR-BUILD-ID}
command. What is the {YOUR-BUILD-ID}?@timofey.sitnikov according to https://book.fulcrologic.com/#_shadow_cljs_build_tool_configuration
It should be :main
i think. Its the key that you have used in the :builds
key in shadow-cljs.edn
I did bunch of research on this and decided to make notes for myself:
I tried this:
[I] /home/sporty/clojure/fulcro/app1~> iced repl :main
OK: CLJS option is enabled.
OK: Clojure CLI project is detected
Execution error (FileNotFoundException) at java.io.FileInputStream/open0 (FileInputStream.java:-2).
:main (No such file or directory)
Full report at:
/tmp/clojure-12744298337363785468.edn
Content of the /tmp/clojure-12744298337363785468.edn report:
{:clojure.main/message
"Execution error (FileNotFoundException) at java.io.FileInputStream/open0 (FileInputStream.java:-2).\n:main (No such file or directory)\n",
:clojure.main/triage
{:clojure.error/class java.io.FileNotFoundException,
:clojure.error/line -2,
:clojure.error/cause ":main (No such file or directory)",
:clojure.error/symbol java.io.FileInputStream/open0,
:clojure.error/source "FileInputStream.java",
:clojure.error/phase :execution},
:clojure.main/trace
{:via
[{:type java.io.FileNotFoundException,
:message ":main (No such file or directory)",
:at [java.io.FileInputStream open0 "FileInputStream.java" -2]}],
:trace
[[java.io.FileInputStream open0 "FileInputStream.java" -2]
[java.io.FileInputStream open "FileInputStream.java" 219]
[java.io.FileInputStream <init> "FileInputStream.java" 157]
[java.io.FileInputStream <init> "FileInputStream.java" 112]
[clojure.lang.Compiler loadFile "Compiler.java" 7571]
[clojure.main$load_script invokeStatic "main.clj" 475]
[clojure.main$script_opt invokeStatic "main.clj" 535]
[clojure.main$script_opt invoke "main.clj" 530]
[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 ":main (No such file or directory)"}}
Among others, I also tried:
$ iced repl main
Right so this took a bit of figuring out as Im not very familiar with the cljs ecosystem 😕
- Use iced repl
instead of passing the build id to start the repl
- Open the browser on localhost:8000 or the port you configured in shadow-cljs.edn
- Then inside vim, go to your cljs file and run the vim command: :IcedConnect
it should prompt for the repl type, choose shadow-cljs
- Then run the vim command :IcedStartCljsRepl shadow-cljs main
to start the repl
Im quite sure there's a better way/im missing something 😕
Maybe @liquidz.uo knows better?
Tried it, but it looks like the iced repl
does launch a REPL but it does not launch the server on the localhost:8000. I will try to require
the source into the namesapce, enter namespace and launch the server manually?
@timofey.sitnikov It should be main
as a {YOUR-BUILD-ID}
> OK: Clojure CLI project is detected
It seems deps.edn
is detected (higher priority than shadow-cljs.edn), so you should also use --force-shadow-cljs
option.
OK, so I run the command:
[I] /home/sporty/clojure/fulcro/app1~> iced repl --force-shadow-cljs main
OK: CLJS option is enabled.
OK: shadow-cljs project is detected
OK: For shadow-cljs project, start watching instead of starting REPL.
shadow-cljs - config: /home/sporty/clojure/fulcro/app1/shadow-cljs.edn
shadow-cljs - connected to server
shadow-cljs - watching build :main
[:main] Configuring build.
[:main] Compiling ...
[:main] Build completed. (251 files, 1 compiled, 1 warnings, 3.10s)
Everything still works in browsers, but when I am back in vim and i type:
:IcedConnect
, I get this:
iced-nrepl is not enabled. Please launch repl with `iced repl` command.
Interesting, when I execute :IcedConnect
second time, I get Already Connected
. The I can execute: IcedEval (+1 2)
and I get 3
, but when I
execute :IcedEval (js/alret "Hi")
I get No such namespace: js
Do you have .nrepl.edn
or $HOME/.nrepl/nrepl.edn
?
iced
is created automatically if these are absent, but if they are present, the contents have not been confirmed so far.
So could you add middleware setting as follows?
https://liquidz.github.io/vim-iced/vim-iced.html#vim-iced-manual-shadow-cljs
Maybe you are in CLJ session instead of CLJS session becase of the middleware missing error.
Wow, I was not even close. I did not have the .nrepl.edn, even worse, I did not have the middleware dependencies that supposed to be in the shadow-cljs.edn
. When I do place them in the shadow-cljs.edn
, I get :
=============================================================================
WARNING: The configured :dependencies in shadow-cljs.edn were ignored!
When using :deps they must be configured in deps.edn
==============================================================================
So somehow I have to place it into deps.edn.OK, that solved it! deps.edn
needs the nrepl dependencieds, like this:
:aliases {:dev {:extra-paths ["src/dev"]
:extra-deps {org.clojure/clojurescript {:mvn/version "1.10.742"}
thheller/shadow-cljs {:mvn/version "2.11.8"}
binaryage/devtools {:mvn/version "0.9.10"}
refactor-nrepl/refactor-nrepl {:mvn/version "2.5.0"}
cider/cider-nrepl {:mvn/version "0.25.5"}
iced-nrepl/iced-nrepl {:mvn/version "1.1.1"}}}}}
Thank you so much.
I am just a beginner, cljs supposed to be simple and easy, and it is, if you know all of the details.
hi all - a very simple question: when I do an eval with fireplace that prints to standard output, I'm not seeing the output anywhere in vim or in my "lein repl" window. Is there a way to see it?
For me println output shows directly in vim. My only idea is check if you're using cider-nrepl in your lein profile/plugins + make sure you're using latest everything
hmm thanks. pretty sure I'm using the latest everything but I'm on Windows so maybe that's the difference.