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 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 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.


Philip said...

Hey Leif, good to hear you're back on EclipseFP. I've been using the 0.10.0 version for some time now and I'm really looking forward to the next release.
BTW 0.10.0 has some compatibility issues with CDT, I would not recommend to integrate both in the same eclipse install.

Philip said...

p.s.: good work so far!

Leif Frenzel said...

Hi Philip,

thanks :-)

About the CDT integration issues: anything in particular I should look for?

Thanks && ciao,

Philip said...

Ok, I hope this is really a compatibility issue and not just my stupidness.

The most noticeable thing is that once I install eclipseFP, i cannot "run" (Ctrl+F11) my C projects anymore.

When I try, I get the "Run As" window and can "Select a way to run 'main.cpp'" but the only choices are GHCi and Hugs. Understandably, they don't work.

Leif Frenzel said...

No, that's very likely a problem with EclipseFP's Run/Run as shortcuts.

There have been some changes in the way the Run/Run as menu generally works, since Eclipse 3.3. Probably I'll have to adjust the EclipseFP run shortcuts.

I've also noticed that the GHCi and HUGS shortcuts show up sometimes for files where they definitely not belong to.

So I'll check that out. Thanks :-)