ClojureScript

Cannot restart Rhino ClojureScript REPL

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Patch:
    Code

Description

In at least some environments (some have not been able to replicate this, others have), the ClojureScript REPL cannot be restarted. Here's an example interaction, using the stock script/repl script and a clean clone of ClojureScript (v0.0-1465-gdf6f316):

la-mer:cljs chas$ script/repl
Clojure 1.4.0
user=> (require '[cljs.repl :as repl])
nil
user=> (require '[cljs.repl.rhino :as rhino])
nil
user=> (repl/repl (rhino/repl-env))
"Type: " :cljs/quit " to quit"
ClojureScript:cljs.user> (+ 1 2 3)
6
ClojureScript:cljs.user> :cljs/quit
nil
user=> (repl/repl (rhino/repl-env))
"Type: " :cljs/quit " to quit"
ClojureScript:cljs.user> (+ 1 2 3)
"Error evaluating:" (+ 1 2 3) :as "((1 + 2) + 3);\n"
org.mozilla.javascript.EcmaError: TypeError: Cannot read property "StringBuffer" from undefined (cljs/core.cljs#6154)
at cljs/core.cljs:6154 (pr_sb)
at cljs/core.cljs:6168 (pr_str_with_opts)
at cljs/core.cljs:6212 (anonymous)
at cljs/core.cljs:6219 (anonymous)
at <cljs repl>:7

nil
ClojureScript:cljs.user>

Activity

Hide
David Nolen added a comment -

Any leads on this specific directions on how to reproduce?

Show
David Nolen added a comment - Any leads on this specific directions on how to reproduce?
Hide
Chas Emerick added a comment -

I'm afraid not. It happens for me 100% of the time from a fresh clone using script/repl in two different environments:

OS X 10.7.4

java version "1.6.0_33"
Java(TM) SE Runtime Environment (build 1.6.0_33-b03-424-11M3720)
Java HotSpot(TM) 64-Bit Server VM (build 20.8-b03-424, mixed mode)

Ubuntu 12.0.4

java version "1.7.0_03"
OpenJDK Runtime Environment (IcedTea7 2.1.1pre) (7~u3-2.1.1~pre1-1ubuntu3)
OpenJDK Client VM (build 22.0-b10, mixed mode, sharing)
Show
Chas Emerick added a comment - I'm afraid not. It happens for me 100% of the time from a fresh clone using script/repl in two different environments: OS X 10.7.4
java version "1.6.0_33"
Java(TM) SE Runtime Environment (build 1.6.0_33-b03-424-11M3720)
Java HotSpot(TM) 64-Bit Server VM (build 20.8-b03-424, mixed mode)
Ubuntu 12.0.4
java version "1.7.0_03"
OpenJDK Runtime Environment (IcedTea7 2.1.1pre) (7~u3-2.1.1~pre1-1ubuntu3)
OpenJDK Client VM (build 22.0-b10, mixed mode, sharing)
Hide
Nelson Morris added a comment -

I can reproduce this every time from a checkout.

Transcript:

tmp$ git clone https://github.com/clojure/clojurescript.git
Cloning into 'clojurescript'...
remote: Counting objects: 10307, done.
remote: Compressing objects: 100% (4349/4349), done.
remote: Total 10307 (delta 4828), reused 10032 (delta 4589)
Receiving objects: 100% (10307/10307), 1.37 MiB | 346 KiB/s, done.
Resolving deltas: 100% (4828/4828), done.
tmp$ cd clojurescript/
clojurescript$ git rev-parse HEAD
dae155a34cd30dabba94f90e306afac930345dcf
clojurescript$ ./script/bootstrap
Fetching Clojure...
Copying clojure-1.4.0/clojure-1.4.0.jar to lib/clojure.jar...
Cleaning up Clojure directory...
Cleaning up Clojure archive...
Fetching Google Closure library...
Fetching Google Closure library...
Cleaning up Google Closure library archive...
Fetching Google Closure compiler...
Cleaning up Google Closure compiler archive...
Building lib/goog.jar...
jar cf ./lib/goog.jar -C closure/library/closure/ goog
Fetching Rhino...
Copying rhino1_7R3/js.jar to lib/js.jar...
Cleaning up Rhino directory...
Cleaning up Rhino archive...
Copying closure/compiler/compiler.jar to lib/compiler.jar
[Bootstrap Completed]
clojurescript$ ./script/repl
Clojure 1.4.0
user=> (require '[cljs.repl :as repl])
nil
user=> (require '[cljs.repl.rhino :as rhino])
nil
user=> (repl/repl (rhino/repl-env))
"Type: " :cljs/quit " to quit"
ClojureScript:cljs.user> (+ 1 2 3)
6
ClojureScript:cljs.user> :cljs/quit
nil
user=> (repl/repl (rhino/repl-env))
"Type: " :cljs/quit " to quit"
ClojureScript:cljs.user> (+ 1 2 3)
"Error evaluating:" (+ 1 2 3) :as "((1 + 2) + 3);\n"
org.mozilla.javascript.EcmaError: TypeError: Cannot read property "StringBuffer" from undefined (cljs/core.cljs#6161)
at cljs/core.cljs:6161 (pr_sb)
at cljs/core.cljs:6175 (pr_str_with_opts)
at cljs/core.cljs:6219 (anonymous)
at cljs/core.cljs:6226 (anonymous)
at <cljs repl>:7

nil
ClojureScript:cljs.user> :cljs/quit
nil
user=>
clojurescript$ java -version
java version "1.6.0_24"
OpenJDK Runtime Environment (IcedTea6 1.11.3) (6b24-1.11.3-1ubuntu0.12.04.1)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)

Show
Nelson Morris added a comment - I can reproduce this every time from a checkout. Transcript:
tmp$ git clone https://github.com/clojure/clojurescript.git Cloning into 'clojurescript'... remote: Counting objects: 10307, done. remote: Compressing objects: 100% (4349/4349), done. remote: Total 10307 (delta 4828), reused 10032 (delta 4589) Receiving objects: 100% (10307/10307), 1.37 MiB | 346 KiB/s, done. Resolving deltas: 100% (4828/4828), done. tmp$ cd clojurescript/ clojurescript$ git rev-parse HEAD dae155a34cd30dabba94f90e306afac930345dcf clojurescript$ ./script/bootstrap Fetching Clojure... Copying clojure-1.4.0/clojure-1.4.0.jar to lib/clojure.jar... Cleaning up Clojure directory... Cleaning up Clojure archive... Fetching Google Closure library... Fetching Google Closure library... Cleaning up Google Closure library archive... Fetching Google Closure compiler... Cleaning up Google Closure compiler archive... Building lib/goog.jar... jar cf ./lib/goog.jar -C closure/library/closure/ goog Fetching Rhino... Copying rhino1_7R3/js.jar to lib/js.jar... Cleaning up Rhino directory... Cleaning up Rhino archive... Copying closure/compiler/compiler.jar to lib/compiler.jar [Bootstrap Completed] clojurescript$ ./script/repl Clojure 1.4.0 user=> (require '[cljs.repl :as repl]) nil user=> (require '[cljs.repl.rhino :as rhino]) nil user=> (repl/repl (rhino/repl-env)) "Type: " :cljs/quit " to quit" ClojureScript:cljs.user> (+ 1 2 3) 6 ClojureScript:cljs.user> :cljs/quit nil user=> (repl/repl (rhino/repl-env)) "Type: " :cljs/quit " to quit" ClojureScript:cljs.user> (+ 1 2 3) "Error evaluating:" (+ 1 2 3) :as "((1 + 2) + 3);\n" org.mozilla.javascript.EcmaError: TypeError: Cannot read property "StringBuffer" from undefined (cljs/core.cljs#6161) at cljs/core.cljs:6161 (pr_sb) at cljs/core.cljs:6175 (pr_str_with_opts) at cljs/core.cljs:6219 (anonymous) at cljs/core.cljs:6226 (anonymous) at <cljs repl>:7 nil ClojureScript:cljs.user> :cljs/quit nil user=> clojurescript$ java -version java version "1.6.0_24" OpenJDK Runtime Environment (IcedTea6 1.11.3) (6b24-1.11.3-1ubuntu0.12.04.1) OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)
Hide
Chas Emerick added a comment -

The root cause of this problem is some shared state used by each flavour of REPL environment:

Rhino: https://github.com/clojure/clojurescript/blob/master/src/clj/cljs/repl/rhino.clj#L19
Browser-REPL: https://github.com/clojure/clojurescript/blob/master/src/clj/cljs/repl/browser.clj#L18

Specifically related to CLJS-358 is the `loaded-libs` set used by the Rhino REPL environment; if I (reset! rhino/loaded-libs #{}) in between REPL sessions, then the failure noted in the ticket does not occur, and the REPL appears to be quite healthy.

(further discussion @ http://groups.google.com/group/clojure-dev/browse_thread/thread/df89f14489402e25)

Fixing this by bringing the loaded-libs set into the RhinoEnv REPL environment type ended up being fairly straightforward, and is enough for me to call it a fix for this issue (resolving the same issues for browser REPL is much more involved).

Show
Chas Emerick added a comment - The root cause of this problem is some shared state used by each flavour of REPL environment: Rhino: https://github.com/clojure/clojurescript/blob/master/src/clj/cljs/repl/rhino.clj#L19 Browser-REPL: https://github.com/clojure/clojurescript/blob/master/src/clj/cljs/repl/browser.clj#L18 Specifically related to CLJS-358 is the `loaded-libs` set used by the Rhino REPL environment; if I (reset! rhino/loaded-libs #{}) in between REPL sessions, then the failure noted in the ticket does not occur, and the REPL appears to be quite healthy. (further discussion @ http://groups.google.com/group/clojure-dev/browse_thread/thread/df89f14489402e25) Fixing this by bringing the loaded-libs set into the RhinoEnv REPL environment type ended up being fairly straightforward, and is enough for me to call it a fix for this issue (resolving the same issues for browser REPL is much more involved).

People

Vote (0)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: