Cabal: outstanding copyFile bug?

Simon Marlow simonmarhaskell at
Tue Aug 22 08:20:02 EDT 2006

Frederik Eaton wrote:
> Hi,
> I tried installing Cabal-1.1.4, but a bug from a long time ago is
> still present. Is it the case that if the new Cabal is in my package
> database, then it will be used?
> $ ghc-pkg list                                                        
> /home/frederik/arch/i386//lib/ghc-6.4.2/package.conf:
>     Cabal-1.1.4, GLUT-2.0, HGL-3.1, HUnit-1.1, OpenGL-2.0,
>     QuickCheck-1.0, X11-1.1, base-1.0, (concurrent-1.0), (data-1.0),
>     fgl-5.2, haskell-src-1.0, haskell98-1.0, hsql-1.7, hsql-mysql-1.7,
>     (hssource-1.0), (lang-1.0), mtl-1.0, (net-1.0), network-1.0,
>     parsec-1.0, (posix-1.0), readline-1.0, rts-1.0, stm-1.0,
>     template-haskell-1.0, (text-1.0), unix-1.0, (util-1.0)
> /home/frederik/.ghc/i386-linux-6.4.2/package.conf:
>     Futility-0.1.8, GSL-0.5
> The bug occurs when there is an existing file with the same path as
> one which Cabal is trying to install - rather than unlinking and
> creating a new file, it seems that Cabal tries to open the existing
> file and write to it.
> ...
> Skipping  Main             ( programs/move-spool.hs, dist/build/move-spool/move-spool-tmp/Main.o )
> dist/build/move-spool/move-spool is up to date, linking not required.
> Installing: /home/frederik/lib/Futility-0.1.8/ghc-6.4.2 & /home/frederik/bin Futility-0.1.8...
> *** Exception: /home/frederik/bin/fssh: copyFile: resource busy (Text file busy)

I've fixed this in System.Directory.copyFile, although there doesn't seem to be 
a foolproof way to do it: if you unlink before opening, there's a chance that 
someone else can create the file in between.  Still, this appears to be what 
install(3) does.


More information about the Libraries mailing list