Where should cabal install to by default?

apfelmus apfelmus at quantentunnel.de
Mon Aug 4 07:36:34 EDT 2008


Duncan Coutts wrote:
> Manuel M T Chakravarty wrote:
>>
>> * On OS X, its not generally appropriate to install into /usr/local  
>> either.  Each user has ~/Applications and ~/Library directories that  
>> are usually used for per-user installs.  Just generally using sudo and  
>> put binaries into /usr/local is also bad because not every user will  
>> have admin rights on the machine.
> 
> Oh, great. I didn't know OS X had a standard location for per-user
> installs. That's excellent. So is there a preferred layout for those
> dirs? I'm guessing there probably is.

~/Applications seems to be new in OS X 10.5, I sure don't have it in 10.4. But 
it seems sensible nonetheless. (And it's documented here 
http://developer.apple.com/documentation/MacOSX/Conceptual/BPFileSystem/Articles/Domains.html#//apple_ref/doc/uid/20002281-101038-BCIFCABI 
)

Note however that the ~/Applications directory is not directly comparable to a 
UNIX /bin . That's because applications in Mac OS X have binaries, data and all 
other batteries included in one folder, the "application bundle". For instance, 
the Thunderbird application is really a folder "Thunderbird.app" and looks 
something like this

   ~/Applications/Thunderbird.app/Contents/Info.plist
   ~/Applications/Thunderbird.app/Contents/MacOS/thunderbird-bin      -- binary
   ~/Applications/Thunderbird.app/Contents/MacOS/ ...
   ~/Applications/Thunderbird.app/Contents/PkgInfo
   ~/Applications/Thunderbird.app/Contents/Resources/thunderbird.icns -- icons
   ~/Applications/Thunderbird.app/Contents/en.lproj/                  -- 
language specific
   ... etc

Bare-bones UNIX binaries like cabal-install itself and those produced by cabal 
don't really fit that scheme. That's why Mac OS X has a standard UNIX-style tree 
in /usr/local . Not sure what to do with per-user cabal, I'd make a fresh 
UNIX-tree at

   ~/Applications/Cabal/

or even

   ~/Applications/Haskell/

so we have

   ~/Applications/Cabal/bin
   ~/Applications/Cabal/lib
   ~/Applications/Cabal/share

etc.

>> * ~/.cabal is bad on Mac OS, too.  Preferences ought to go into ~/ 
>> Library/Preferences/
> 
> Ok. BTW, in that case we should probably fix
> System.Directory.getAppUserDataDirectory to follow the system convention
> on OSX. Currently it uses $HOME/.appname on all unix systems (and the
> Windows convention on Windows). If necessary we may want to
> split getAppUserDataDirectory into a variant for config and another for
> data.

System.Directory.getAppUserDataDirectory  should return

   ./Progname.app/Contents/Resources

for programs that are packaged as OS X application bundle. Of course, that 
doesn't apply to most UNIX software...

However, configuration files are to go in

   ~/Library/Preferences/

which is sufficiently similar to /etc .

> Since cabal-install is a program should it still be
> using ~/Library/Preferences/ or is there are
> corresponding ~/Applications/Preferences/ ? Where would be
> appropriate for cabal-install put its download cache and build logs?

The ~/Library/  folder is more like /usr/etc and /usr/share than /usr/lib , so 
it works for both executable and shared libraries.

~/Library/Preferences/
     for configuration files.

~/Library/Application Support/
     for application data that you don't need to run the application.
     Like examples files or clip arts.

~/Library/Caches/
     for cache files.

~/Library/Logs/
     for logs.

Some documentation from Apple:
http://developer.apple.com/documentation/MacOSX/Conceptual/BPFileSystem/Articles/WhereToPutFiles.html
http://developer.apple.com/documentation/MacOSX/Conceptual/BPFileSystem/Articles/LibraryDirectory.html


Regards,
apfelmus



More information about the Libraries mailing list