Opened 9 years ago

Closed 8 years ago

#4812 closed bug (fixed)

doesDirectoryExist always returns False on Mac OS X

Reported by: YitzGale Owned by:
Priority: high Milestone: 7.4.1
Component: libraries/directory Version: 6.12.3
Keywords: Cc: gale@…, pho@…
Operating System: MacOS X Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

On an Intel MacBook with Mac OS X 10.6.5 (Snow Leopard), with GHC 6.12.3 from a standard Haskell Platform installation, System.Directory.doesDIrectoryExist always returns False for any path.

This issue was first reported here: http://www.haskell.org/pipermail/haskell-cafe/2010-November/086603.html

At that time, several other users on the same platform responded that they were not experiencing the problem. I also tested at that time, and I did not experience the problem.

Now it has started happening here. During the past day I upgraded some basic packages from Hackage, so I suspect that is related.

I have tried it with directory-1.0.1.1 and filepath-1.1.0.4 as originally supplied with the HP install, and also with directory-1.1.0.0 and filepath-1.2.0.0 from hackage, all with the same problem occurring.

One of the packages I upgraded was unix, from 2.4.0.2 to 2.4.1.0. I tried hiding the newer version, but when I run doesDirectoryExist and GHCi loads the directory package, it ignores my hiding and loads the newer unix package. If I both hide the newer unix package and manually specify the older one, GHCi complains about duplicate symbol definitions and departs.

All of that is especially strange, since unix is not even a dependency of directory.

Attachments (1)

stat.2 (11.8 KB) - added by YitzGale 9 years ago.
Man page for stat on Darwin

Download all attachments as: .zip

Change History (10)

comment:1 Changed 9 years ago by simonmar

unix is a dependency of directory, from directory.cabal:

      if os(windows) {
          build-depends: Win32
      } else {
          build-depends: unix
      }

I suspect the problem has something to do with this

Fri Feb 26 09:31:44 GMT 2010  Simon Marlow <marlowsd@gmail.com>
  * Fix #3878: various directory tests were wrong on Unix systems
    {
    hunk ./System/Directory.hs 206
    -  let is_dir = Posix.fileMode stat .&. Posix.directoryMode /= 0
    +  let is_dir = Posix.isDirectory stat
    hunk ./System/Directory.hs 376
    -              if Posix.fileMode stat .&. Posix.directoryMode /= 0 $
    +              if Posix.isDirectory stat
    hunk ./System/Directory.hs 621
    -   let is_dir = Posix.fileMode stat .&. Posix.directoryMode /= 0
    +   let is_dir = Posix.isDirectory stat
    hunk ./System/Directory.hs 901
    -       return (Posix.fileMode stat .&. Posix.directoryMode /= 0))
    +       return (Posix.isDirectory stat))
    hunk ./System/Directory.hs 915
    -       return (Posix.fileMode stat .&. Posix.directoryMode == 0))
    +       return (not (Posix.isDirectory stat)))
    }

that patch itself should be fine, and it certainly works here, so something else must be going wrong. I suspect it's one of those 32/64-bit problems with the FFI on OS X 10.6: probably the unix package is using the wrong offsets for struct stat, so that Posix.isDirectory isn't working correctly.

Does that give someone enough clues to fully diagnose the problem?

comment:2 Changed 9 years ago by YitzGale

Cc: gale@… added

Changed 9 years ago by YitzGale

Attachment: stat.2 added

Man page for stat on Darwin

comment:3 Changed 9 years ago by YitzGale

Darwin has two totally different stat structures, one for 32 bits and one for 64 bits. I attached the stat man page with the relevant information.

comment:4 in reply to:  3 Changed 9 years ago by simonmar

Replying to YitzGale:

Darwin has two totally different stat structures, one for 32 bits and one for 64 bits. I attached the stat man page with the relevant information.

Right, so it must be that hsc2hs is running the C compiler in 64-bit mode instead of 32-bit mode when it compiles the hsc files in the unix package. I was under the impression that this had already been straightened out - can someone with a Mac figure out what's going on?

comment:5 Changed 9 years ago by PHO

Cc: pho@… added

comment:6 Changed 9 years ago by igloo

Milestone: 7.0.3

This may be caused by #4852.

comment:7 Changed 8 years ago by igloo

Milestone: 7.2.17.4.1

comment:8 Changed 8 years ago by simonmar

difficulty: Unknown
Priority: normalhigh

This must be fixed now, right?

comment:9 in reply to:  8 Changed 8 years ago by YitzGale

Resolution: fixed
Status: newclosed

Replying to simonmar:

This must be fixed now, right?

Currently works for me with GHC 7.0.2, apparently installed via Haskell Platform 2011.2.0.0.

unix-2.4.2.0
directory-1.1.0.0
}}
Note: See TracTickets for help on using tickets.