tools.nrepl

Android: nREPL starts with no namespace

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Completed
  • Affects Version/s: 0.2.0
  • Fix Version/s: None
  • Component/s: None
  • Labels:
  • Environment:
    Android w/ Clojure 1.4.0, REPLy client / Eclipse CCW client

Description

When I start the nREPL on the Android device (by calling `(clojure.tools.nrepl.server/start-server :port 9999)`) it all goes well. But when I try to connect to this REPL using any of the clients I find myself in an empty namespace (or something like that). The var ns is unbound, no functions from the clojure.core are available. At the beginning REPLy tries to perform some actions but they fail (says that it cannot find symbol `defn` - because nothing from clojure.core is being mapped).

However I can do (in-ns 'anywhere) it works. Everything else in the REPL works correctly (as far as I see). The issue itself is minor but I'm afraid that it is caused by some crash during nREPL initialization that might lead to other problems in future.

Activity

Hide
Alexander Yakushev added a comment -

Can't edit, I meant the *ns* var, of course.

Show
Alexander Yakushev added a comment - Can't edit, I meant the *ns* var, of course.
Hide
Alexander Yakushev added a comment - - edited

With the help of Daniel Solano Gómez I managed to fix this bug. The problem was caused by the lack of user namespace in the Android-patched Clojure. nREPL assumes that the user namespace is present and uses it by default.

Here's the so called fix I ended up with:

...
(let [user-ns (create-ns 'user)]
  (binding [*ns* user-ns]
    (clojure.tools.nrepl.server/start-server :port 9999)))
...

The issue can be closed now.

Show
Alexander Yakushev added a comment - - edited With the help of Daniel Solano Gómez I managed to fix this bug. The problem was caused by the lack of user namespace in the Android-patched Clojure. nREPL assumes that the user namespace is present and uses it by default. Here's the so called fix I ended up with:
...
(let [user-ns (create-ns 'user)]
  (binding [*ns* user-ns]
    (clojure.tools.nrepl.server/start-server :port 9999)))
...
The issue can be closed now.
Hide
Chas Emerick added a comment -

A follow up Q: user is created by clojure.lang.RT's static initialization. Is the lack of that in "Android-patched Clojure" an optimization of some sort?

Show
Chas Emerick added a comment - A follow up Q: user is created by clojure.lang.RT's static initialization. Is the lack of that in "Android-patched Clojure" an optimization of some sort?
Hide
Alexander Yakushev added a comment -

Exactly, Daniel Solano Gómez removed it because it's initialization took additional time, it seems.

Show
Alexander Yakushev added a comment - Exactly, Daniel Solano Gómez removed it because it's initialization took additional time, it seems.
Chas Emerick made changes -
Field Original Value New Value
Resolution Completed [ 1 ]
Status Open [ 1 ] Closed [ 6 ]

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: