Cannot start a remote ClojureScript bREPL (it says "Unable to resolve symbol...") - clojure

ClojureScript noob here.
I'm following the following ClojureScript tutorial using Boot: https://github.com/magomimmo/modern-cljs/blob/master/doc/second-edition/tutorial-02.md#browser-repl-brepl
I can follow it and connect a command line/boot repl to my site by running boot repl -c andn then (start-repl), but I'd like to connect to the site using a richer text editor based REPL.
I've downloaded the ProtoRepl for the atom text editor. I can connect to the repl just fine by giving it the repl's host + port, but when I try to run (start-repl) it throws the error:
(start-repl)
=> CompilerException java.lang.RuntimeException: Unable to resolve symbol: start-repl in this context, compiling:(C:\Users\Zain\AppData\Local\Temp\boot.user4327288409706217009.clj:1:1)
It seems like I'm missing some ClojureScript/boot specific imports, but I'm not sure what to add or how to add it.
Here's some additional debugging info:
Running (def start-repl) on the working boot repl connection, vs the failing proto-repl connection:
Boot repl:
cljs.user=> (def start-repl)
#'cljs.user/start-repl
Proto-repl:
(def start-repl)
=>
#'user/start-repl

The start-repl command is provided by the adzerk boot-cljs-repl library. If you're in the cljs.user namespace, the command is going to be:
(adzerk.boot-cljs-repl/start-repl)
If this is your first time entering the bREPL, Proto-REPL is going throw an error on every keystroke. This is Proto-REPL trying and failing to validate/autocomplete your clojure expressions. The quickest way to get rid of these errors is to just disable autocomplete:
Go to Atom's Preferences
click on "Packages"
search for "proto-repl" under "Installed Packages"
click on "Settings" under the "proto-repl" box
scroll down to the "Enable Autocompletion" setting and unclick the checkbox
restart Atom
Run through the steps to start the Brepl again and you should have a decently working browser repl.

It looks like from the tutorial that the start-repl function is in the boot.user namespace. Proto REPL uses the user namespace by default. Try (boot.user/start-repl)

Related

Why this web application built with Clojure, ClojureSript, Figwheel, Lein is not been updated on the browser after editions on the source code?

I am watching a course/tutorial from Eric Normand on
front-end. The
course is a paid private service.
However, he is using a public repo on GitHub, this
one.
After cloning and executing lein fig-dev, the project seems to have
been succesfully built:
2022-08-25 13:46:47.988:INFO::main: Logging initialized #3006ms to org.eclipse.jetty.util.log.StdErrLog
[Figwheel] Validating figwheel-main.edn
[Figwheel] figwheel-main.edn is valid \(ツ)/
[Figwheel] Compiling build dev to "resources/public/js/compiled/app.js"
[Figwheel] Successfully compiled build dev to "resources/public/js/compiled/app.js" in 1.33 seconds.
[Figwheel] Watching paths: ("src") to compile build - dev
[Figwheel:SEVERE] /private/var/folders/fh/7d_1drwd2ps3zw03j9ftkqs80000gn/T/jna1153974339277798676.tmp: dlopen(/private/var/folders/fh/7d_1drwd2ps3zw03j9ftkqs80000gn/T/jna1153974339277798676.tmp, 0x0001): tried: '/private/var/folders/fh/7d_1drwd2ps3zw03j9ftkqs80000gn/T/jna1153974339277798676.tmp' (fat file, but missing compatible architecture (have (unknown,i386,x86_64), need (arm64e)))
[Figwheel] Starting Server at http://localhost:3449
[Figwheel] Starting REPL
Prompt will show when REPL connects to evaluation environment (i.e. a REPL hosting webpage)
Figwheel Main Controls:
(figwheel.main/stop-builds id ...) ;; stops Figwheel autobuilder for ids
(figwheel.main/start-builds id ...) ;; starts autobuilder focused on ids
(figwheel.main/reset) ;; stops, cleans, reloads config, and starts autobuilder
(figwheel.main/build-once id ...) ;; builds source one time
(figwheel.main/clean id ...) ;; deletes compiled cljs target files
(figwheel.main/status) ;; displays current state of system
Figwheel REPL Controls:
(figwheel.repl/conns) ;; displays the current connections
(figwheel.repl/focus session-name) ;; choose which session name to focus on
In the cljs.user ns, controls can be called without ns ie. (conns) instead of (figwheel.repl/conns)
Docs: (doc function-name-here)
Exit: :cljs/quit
Results: Stored in vars *1, *2, *3, *e holds last exception object
Opening URL http://localhost:3449
ClojureScript 1.10.764
cljs.user=> (js/alert "hello")
nil
This is all my log (question was asked as comment below).
The browser starts (I am using Brave) and the application seems to be
succesfully loaded on http://localhost:3449//.
I have a REPL working and I can even do alerts like that happen as
events on the browser at localhost:
cljs.user=> (js/alert "hello")
nil
Ok. The only problem is when I edit the sorce code as he does on the
videos. In his case, the changes make effect on the browser. On my
case, they do not. Nothing happens.
I can only see changes if I rebuilt everything from scratch.
In other projects, I managed to see the changes happening live, but I
was using shadow-cljs there.
How do I fix this?
Obs.: I am using Macbook M1, macOS Monterey 12.5.1
The Hawk filewatcher used in the version of figwheel-main you have does not support the M1 Mac -- that's what the JNA-related SEVERE error is about in the logs.
The current version of figwheel-main is 0.2.18 so you can try that instead of 0.2.12 in project.clj. According to the changelog, 0.2.14 switched from Hawk to Beholder so it may fix the M1 compatibility issue.
Thanks to #SearCorfield, I managed to solve the problem.
Also, Eric Normand (the creator of the course and author of the
repository) has
just updated the project.clj file to have
[com.bhauman/figwheel-main "0.2.18"]. It now works smoothly!

Unable to get `cider-jack-in` to work

See an error message: error in process sentinel: Could not start nREPL server: That’s not a task. Use "lein help" to list all tasks.
In the *Messages* buffer, the full form of the error is:
error in process sentinel: nrepl-server-sentinel: Could not start nREPL server: That’s not a task. Use "lein help" to list all tasks.
M-x cider-version shows
CIDER 0.15.0snapshot (package: 20170525.255)
Tried fiddling around with ~/.lein/profiles.clj to explicitly add in
{:user {:plugins [[cider/cider-nrepl "0.15.0snapshot"]]}}`
... but that didn't change anything.
(getting back to Clojure after a while with a "fresh" install (Emacs, clojure-mode, cider, etc. so might have missed some small environment setup step, just don't know what that is!)
Turns out the incompatibility was not with the nRepl middleware, but with Leiningen itself.
Once I uninstalled the version I had installed using apt-get, and self-installed using the downloaded script, and made sure this new version was what which lein led to, this problem went away.
More details: Running cider-jack-in was triggering a call to lein update-in with further arguments, but the version of Leiningen I had simply didn't show update-in as one of the options when I ran lein help.

omcljs basic tutorial giving error: Uncaught Error: Assert failed: No target specified to om.core/root (not (nil? target))

I am attempting om's basic tutorial, and run into an error even before changing any code.
I followed the instructions, running lein new figwheel om-tut -- --om, cd om-tut, and lein figwheel.
http://localhost:3449/ then displays the html text, not the app-state text which it should be displaying instead. Furthermore, when I open my dev tools to the console I see the error message shown in the following screenshot.
This is unexpected because I have not changed the tutorial at all, just downloaded and run following the instructions to a T. It is also unexpected because the tutorial seemed to work for me just yesterday, running on my same machine.
Any one know what could be the issue?
This is a really old bug in the om.root https://github.com/swannodette/mies-om/issues/2. It should have been fixed by now.

ClojureScript bRepl does not respond at all

I've been tinkering with clojure and clojurescript for some time and I always found the browser repl to be extremely unresponsive. It usually hangs on without giving a result, or throws a broken pipe exception. Now I'm in a situation where it always refuses to work.
Let's say I download the modern-cljs tutorial part 2 and I do all the steps to start the page, load the compiled javascript and start the bRepl. When I try to evaluate something as simple as (+ 3 4) well, it just doesn't work.
I'm on OSX 10.8.4 and my leiningen version is 2.3.2 on Java 1.6.0_51 Java HotSpot(TM) 64-Bit Server VM. Any help is extremely appreciated.
I would suggest to clone the modern-cljs repo, then checkout the tutorial-02 branch, then clean and recompile.
git clone https://github.com/magomimmo/modern-cljs.git
cd modern-cljs
git checkout tutorial-02
lein do clean, cljsbuild clean
lein cljsbuild once
Be sure to have your http-server running (I'm assuming the port is 3000) and its root set to modern-cljs/resources/public directory
Then run the repl-listen substask as follows:
lein trampoline cljsbuild repl-listen
Wait for the cljs prompt. Then visit the localhost:3000/simple.html URL and wait that the connection with the brepl is ready.
At the cljs prompt you should now be able to evaluate cljs expressions. Eventually, reload the above URL.
If it still does not work, try to delete your maven repository:
rm -rf ~/.m2/repository
and redo everything from the lein do chain of commands.
Eventually you can follow the https://github.com/magomimmo/modern-cljs/blob/master/doc/tutorial-18.md#the-need-of-a-more-comfortable-brepl-experience tutorial to set up a more comfortable bREPL which uses https://github.com/cemerick/piggieback
HIH
I've had a few problems with this topic too. And here are the tricks that help me:
Clean leain deps: rm -rf ~/.m2/*
download lein deps: lein deps in your project root
I saw this message: "broken pipe" when there was too much time from the last brepl interaction. So, refresh the browser and that's all
sometimes my brepl hung on the first time i was trying to evaluate the code, again try to refresh the browser
don't forget to run: lein cljsbuild once before start the brepl
Good luck
PS: Anyway if you want to have a comfortable brepl experience you have to take a look to https://github.com/cemerick/austin . I have tested this brepl and works fine https://github.com/juanantonioruz/client
You should try using Chromium unsafely:
OS X:
open -a Chromium --args --disable-web-security
Linux:
chromium --disable-web-security
Then visit your page in the unsafe browser and try to connect to the brepl.
Explanation:
Because while brepl is running on port 9000, the web server hosting the page is necessarily using a different port, which constitutes XSS (see [this stack overflow discussion]).
The easiest way to get around this is to use Chromium unsafely for debugging, but you can enable XSS by some other means if you want.
What ClojureScript release are you specifying in your project.clj? If you aren't specifying a specific release, this likely the source of your troubles. 0.0-1913 is the latest one.
I've also seen a complete hang in the REPL when I forget to call repl/connect from within the browser. Since there is no output, it's hard to diagnose. It's worth verifying before you try more intrusive remedies.

error while using nrepl-jack-in

I am getting the below error whenever I try M-x nrepl-jack-in -
error in process sentinel: Could not start nREPL server: /usr/bin/lein: line 260: java: command not found
I am able to start the repl without any issues by lein repl or lein2 repl - both work.
Thanks,
Murtaza
I had the same problem. Let me guess, you are launching Emacs from the application launcher? Applications launched this way apparently do not use your .bashrc file. If you do your PATH set up in your ~/.profile file instead it should work. You'll need to log out and in for it to take effect though.
You may have an different environment inside emacs from inside your shell. Is Java installed in the same place as lein? If you type M-x shell, and run java -help there does it work? What about "M-x shell-command java -help"