                     [java.io ~'InputStreamReader ~'OutputStream
                      ~'OutputStreamWriter ~'PrintWriter]
                     [clojure.lang ~'LineNumberingPushbackReader]))
-           (try (require ['~'clojure.java.shell])
-                (require ['~'clojure.java.browse])
-                (catch Exception _#))
-           (use ['~'clojure.main :only ['~'repl]])
+         (try ;; transitive requires don't work for stuff on bootclasspath
+           (require ['~'clojure.java.shell])
+           (require ['~'clojure.java.browse])
+           (catch Exception _#))
+         (use ['~'clojure.main :only ['~'repl]])
          (let [server# (ServerSocket. ~port 0 (~'InetAddress/getByName ~host))
                acc# (fn [s#]
                       (let [ins# (.getInputStream s#)

             .start)
           (format "REPL started; server listening on %s:%s." ~host ~port)))))

(defn- copy-out [reader]
  (Thread/sleep 100)
  (.write *out* (.read reader))
  (while (.ready reader)
    (.write *out* (.read reader)))
  (flush))

(defn repl-client [reader writer]
  (copy-out reader)
  (let [eof (Object.)
        input (try (read *in* false eof)
                   (catch Exception e

      (recur reader writer))))

(defn- connect-to-server [socket]
  (let [reader (InputStreamReader. (.getInputStream socket))
        writer (OutputStreamWriter. (.getOutputStream socket))]
    (.start (Thread. #(copy-out-loop reader)))
    (repl-client reader writer)))

(defn poll-repl-connection [port]
  (Thread/sleep 100)
