Friday, February 15, 2008

Cohatoe 0.9 preview

This is another preview version of Cohatoe. Since the last one, I have switched from PC to Mac (and thus from Windows to MacOS X as my primary working OS), and I have also started the transition to GHC 6.8.2 for Cohatoe. So there is now a Cohatoe version for MacOS X, and one for Linux. Both require GHC 6.8.2.

The transition is not yet complete: Cohatoe is broken on Windows so far (doesn't work yet for GHC 6.8.2, and does no longer work for older versions, so if you are on Windows, you don't want to update Cohatoe ;-); and there are still some issues on both Linux and Mac OS X (details are in the changelog file). But those latter ones can be worked around, and I wanted to make some progress on EclipseFP as well, so I decided to get this out in the current state and switch my attention to EclipseFP for the moment.

Have fun :-)


Finding the right path

Cohatoe calls some external programs (external, that is, to the Eclipse process), namely ghc-pkg and runghc, and of course ghc itself (e.g. to ask it for its version and the libraries folder). To do so, it initiates a new process from within Java code, and this process inherits the environment from its parent process (the JVM that runs Eclipse).

The standard GHC installation is in /usr/local/bin/, and this path is added to the PATH environment variable all right; but that happens in the shell's startup file .profile. Normally one starts Eclipse by double-clicking the Eclipse.app in the eclipse/ folder. In this case, .profile is not read and thus PATH is not updated. Therefore, as far as Cohatoe is concerned, GHC cannot be assumed to be on the PATH.

So I have introduced a system property where the path to a GHC installation can be configured: it is named cohatoe.ghc.

This also helps with multiple GHC installations (a user could have several GHC versions on the system and might want to put a different one on the PATH than the one Cohatoe needs).

You can pass cohatoe.ghc either on the command line or in the eclipse.ini file (on Macs, the latter is hidden in Eclipse.app/Contents/MacOS/). It must point to the folder which contains the GHC executable, e.g. -Dcohatoe.ghc=/usr/local/bin. (Make sure you put this into the command line after the -vmargs; else Eclipse will take it as an option for Eclipse, not as one that it has to pass to the JVM.)

If the cohatoe.ghc property is not set, Cohatoe falls back to assuming GHC to be on the PATH; if it isn't there either, the only thing we can do is to write a message to the error log.