Question

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.

Was it helpful?

Solution 2

I've had a few problems with this topic too. And here are the tricks that help me:

  1. Clean leain deps: rm -rf ~/.m2/*
  2. download lein deps: lein deps in your project root
  3. 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
  4. sometimes my brepl hung on the first time i was trying to evaluate the code, again try to refresh the browser
  5. 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

OTHER TIPS

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

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top