small medium large xlarge

23 Aug 2014, 20:12
Robert Tweed (2 posts)

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.

23 Aug 2014, 20:42
Dmitri Sotnikov (149 posts)

Hi Robert,

I understand that a few people have experienced issues with Light Table, it appears that a lot of these can be fixed by running lein clean in the project.

I just tried running the skeleton app generated by lein new compojure-app myapp from Light Table 0.6.7 and haven’t got the same error in my case. I’m also on Mavericks running Jdk 1.8 and other relevant dependencies appear to be the same.

The template generation itself shouldn’t be in any way fragile. All the template does is create a new project from static sources. In my opinion there would be little value in generating the equivalent by hand.

The problem tends to be around the fragility of Light Table itself unfortunately. While, chapter 1 is focused on Light Table, the rest of the book is very much editor agnostic.

The REPL works pretty much the same way in every Clojure editor and since projects are managed by Leiningen, there’s very little difference in how they’re opened and managed by the editors.

Unfortunately, I don’t believe that older versions of Light Table are made available anywhere. I believe a few people have mentioned the same issue that you ran into with older versions as well, so it appears to be a persistent bug that still hasn’t been fixed in it.

23 Aug 2014, 22:50
Robert Tweed (2 posts)

Hi Dmitri,

Thanks for the response. I didn’t get a chance to try lein clean. I had deleted the original project folder and replaced it with a copy of the downloaded sample to work on. So to reproduce the problem and see if lein clean would fix it, I generated a new clean project, exactly the same way I did before. This time it worked.

It’s quite strange. It’s also not like it’s an intermittent problem. I tried it about 5 times initially without success, and I’ve run it again about 5 times with success each time.

It bears further investigation, but it’s not something I’m going to spend time looking into right now. For now, I’m just glad to have a working environment so I can get back to the rest of the book.

If I get a chance to investigate further later, I’ll report back. I am curious to know whether lein clean would in fact fix he problem and if so, why. I’m even more curious to know why it suddenly started working for no obvious reason. I’d stab a guess that lein keeps a cache of dependent files somewhere and somehow it was necessary to recompile one of them. It certainly looks more like a problem with lein than an issue with Light Table per se.

23 Aug 2014, 22:54
Dmitri Sotnikov (149 posts)

I’m actually fairly positive that the problem is Light Table specific. I’ve only seen the problem using Light Table and the error refers to cljs/analyzer.clj which is a ClojureScript error and has nothing to do with Clojure or Leiningen.

It looks like Light Table somehow gets itself in a bad state. There also appears to be an issue open for Light Table on GitHub referring to this problem. Hopefully, it gets fixed in the near future. :)