Tuesday, October 04, 2011

Funky Cygwin Path Issues

In getting familiar with Stuart Sierra's lovely Clojure test library Lazytest, I ran into a problem running it from the windows command console. The test output had special control codes not properly processed by the console:
E:\development\clojure\calibration>java -cp src;test;lib/*;lib/dev/* lazytest.watch src test

At  #<Date Tue Oct 04 07:45:47 CDT 2011>
Reloading calibration.test.core, calibration.core

←[33mNamespaces (no cases run)←[0m

←[33mRan 0 test cases.←[0m
←[32m0 failures.←[0m

I use mintty for cygwin, which will process those codes correctly, but I then had trouble with the Java classpath:

yawmark$ java -cp "src:test:lib/*:lib/dev/*" lazytest.watch src test
java.lang.NoClassDefFoundError: lazytest/watch
Caused by: java.lang.ClassNotFoundException: lazytest.watch
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: lazytest.watch.  Program will exit.
Exception in thread "main" [~]

After a little online research, I found that I needed to decorate the classpath a bit:
java -cp `cygpath --path --windows "src:test:lib/*:lib/dev/*"` lazytest.watch src test
After that, all is once again right with the world.

No comments:

Post a Comment