Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Labs fail to load because (name lab) throws ClassCastException #13

Closed
mikem opened this issue Jun 21, 2010 · 3 comments
Closed

Labs fail to load because (name lab) throws ClassCastException #13

mikem opened this issue Jun 21, 2010 · 3 comments

Comments

@mikem
Copy link

mikem commented Jun 21, 2010

Steps to reproduce:

  1. launch labrepl with scripts/repl
  2. navigate to http://localhost:8080 in your browser
  3. visit one of the labs (ie: intro)
  4. observe traceback on the page as well as the labrepl console

The traceback begins as follows:

java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.Named
    at clojure.core$name__4021.invoke(core.clj:1227)
    at labrepl.lab$instructions__1728.invoke(lab.clj:20)
    ...
@mikem
Copy link
Author

mikem commented Jun 21, 2010

At line 20 of src/labrepl/lab.clj is the following code:

(let [lab-ns (symbol (str "labs." (name lab)))]

The var lab is a String. In SHA: 3149fdd this line is changed from:

(let [lab-ns (symbol (str "labs." (as-str lab)))]

I guess as-str and name behave differently if their argument is a String. Note that only the argument to labrepl.lab.instructions is a String; labrepl.lab.lab-url and labrepl.lab.url all receive Keyword instances.

This patch fixes the problem

diff --git a/src/labrepl/lab.clj b/src/labrepl/lab.clj
index 83d00dc..a873504 100644
--- a/src/labrepl/lab.clj
+++ b/src/labrepl/lab.clj
@@ -17,7 +17,7 @@

 (defn instructions
   [lab]
-  (let [lab-ns (symbol (str "labs." (name lab)))]
+  (let [lab-ns (symbol (str "labs." lab))]
     (require lab-ns)
     ((ns-resolve lab-ns 'instructions))))

@stuarthalloway
Copy link
Member

You need a more recent version of clojure.jar.

@mikem
Copy link
Author

mikem commented Jun 21, 2010

Of course, you're right.

Here's what happened. I tried labrepl last month, so coming back to it yesterday I first ran git pull to get the latest changes, then lein deps to pull down the latest dependencies. This pulled down clojure-1.2.0-master-20100607.150309-85.jar but left the clojure-1.2.0-master-20100504.200313-67.jar from before lying around. When the repl launched, it must have pulled in the old version since it's first in lexicographical order.

Another gotcha to watch out for in the future.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants