Skip to content

Can't work with symlinked files created in other operating systems

Summary

When I create a symlink of a haskell source file into a directory with other source files, ghc and ghci cannot load a file that was created via a symlink in another operating system

Apologies if this is an OS limitation rather than a problem with GHC

Steps to reproduce

I have created the following test repo to show the error

  1. I have lib.hs in the root
  2. In the mac directory I have symlinked the Lib.hs file into this directory using MacOS. I then have a main Haskell source file that includes this symlinked file
  3. In the linux directory I have symlinked the Lib.hs file into this directory using Linux. I then have a main Haskell source file that includes this symlinked file
  4. When I try and load the files using ghc or ghci for the wrong operating system it doesn't work:

For example, on my Mac:

ghci Linux.hs 
GHCi, version 8.8.4: https://www.haskell.org/ghc/  :? for help
Loaded GHCi configuration from /Users/mwa75/.dotfiles/config/haskell/ghci.conf
[1 of 1] Compiling Main             ( Linux.hs, interpreted )

Linux.hs:6:17: error: Variable not in scope: test :: String
  |
6 | main = putStrLn test
  |                 ^^^^
Failed, no modules loaded.
ghci Mac.hs                                         
GHCi, version 8.8.4: https://www.haskell.org/ghc/  :? for help
Loaded GHCi configuration from /Users/mwa75/.dotfiles/config/haskell/ghci.conf
[1 of 2] Compiling Lib              ( Lib.hs, interpreted )
[2 of 2] Compiling Main             ( Mac.hs, interpreted )
Ok, two modules loaded.

I note the same behaviour on Linux, but its the opposite way around (failing to load the symlinked file created on MacOS but not on Linux)

Expected behavior

I expect ghc and ghci to be able to work with symlinked files created on other operating sysytems. The github repo I have linked is a stripped down version of a problem I am actually seeing when trying to create projects cross platform

Environment

  • GHC version used: The Glorious Glasgow Haskell Compilation System, version 8.8.4

Optional:

  • Operating System: MacOS Big Sur 11.3.1 (I was also seeeing the issue on Catalina), Arch Linux (rolling release so always newest version)
  • System Architecture: x86_64
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information