The latest version of Light Table doesn’t work with the latest compojure-app template. At least not on OS X Mavericks.
Trying to connect fails; it throws this exception:
Error loading lighttable.nrepl.handler: java.lang.RuntimeException: Unable to resolve var: reader/alias-map in this context, compiling:(cljs/analyzer.clj:1499:11)
If instead of generating the project with lein, I download the book source and try to connect to that, it does work. I haven’t figured out which dependency is causing the problem.
Unlike the other posts complaining about LT, I’m not going to point the finger in that direction. Instead, I’m going to list the dependencies, any one of which could be responsible for causing the problem, and let that make my point for me:
- Light Table is 0.6.7
- Java is 1.8.0_05
- Clojure is 1.6.0
- Leiningen is 2.4.3
- Compojure template is version 0.4.2
- Compojure itself is 1.3
- …… I’m not even going to get into the specific dependencies within the generated project.clj file (yes, I compared them to the downloaded version and yes, several versions are different).
I’m actually pretty happy with the decision to base the book on LT as I think it’s a nice tool and I probably wouldn’t have looked at it seriously otherwise. It’s a good excuse to try it out as I’m expanding my knowledge of Clojure. I might even go on to use it in real projects.
However, going through the steps from zero to “hello world” as presented in the book just has too many potential points of failure right now. The stack is too big and too fragile for a “chapter 1” toolchain introduction.
It would be much better to defer the fragile automagical template generation and dependency resolution processes (namely, “lein new compojure-app”) until later chapters when the reader is at least broadly comfortable with the environment and tools. The first few chapters should work from the code samples. It’s also a good idea to suggest a specific known-working version of Light Table, providing a direct link to that version (since it won’t be the latest one).
Also, as has been pointed out in other posts, much of the UI of LT has changed from what is described in the book. That is confusing. I would agree with the author’s point that other editors can be used, were it not for the fact that the book as structured is extremely reliant on Light Table for its presentation. Lots of space is taken up with things like:
- Screenshots of Light Table
- Instructions for opening the project in Light Table
- Instructions for interacting via the REPL that assume Light Table’s “instarepl” is being used
Again, the solution is not to suggest that people use a different editor, which will significantly devalue much of the content of the book. Rather, just suggest that people use the specific versions that are known to work, and try upgrading components one at a time later. That way:
(a) It’s much easier to pinpoint which new version caused a problem;
(b) The reader is no longer dealing with an entirely unfamiliar environment, so can more easily debug the issue.
Unfortunately, the book does not, as far as I can see, list which versions of the software stack are known to work with each other. That information could easily be added in a single table at the start of the chapter 1 (possibility added as errata for now).
I’ve run into similar forward-incompatibility issues with books in the past, but in those cases I’ve always been able to locate the specific versions mentioned in the book and that was enough to get up and running with the examples. By the time I’d completed the books, I knew enough to debug and fix the problems. Chapter 1 is the absolute worst possible time to start having these kinds of issue because all the tools are new, so you have no idea what to do, especially with so many dependencies involved.