haskell / directory

Platform-independent library for basic file system operations
https://hackage.haskell.org/package/directory
Other
58 stars 47 forks source link

directory bundled with GHC-9.6 is not safe (inferred) anymore. #162

Closed phadej closed 9 months ago

phadej commented 11 months ago
[polinukli] /code/shared-haskell/haskell-ci master % ghci-9.4.6 -XHaskell2010
GHCi, version 9.4.6: https://www.haskell.org/ghc/  :? for help
Loaded GHCi configuration from /home/phadej/.ghci
Prelude> :set -XSafe
Prelude> import System.Directory
Prelude System.Directory> 
Leaving GHCi.
[polinukli] /code/shared-haskell/haskell-ci master % ghci-9.6.2 -XHaskell2010
GHCi, version 9.6.2: https://www.haskell.org/ghc/  :? for help
Loaded GHCi configuration from /home/phadej/.ghci
Prelude> :set -XSafe
Prelude> import System.Directory

<no location info>: error: [GHC-44360]
    System.Directory: Can't be safely imported!
    The module itself isn't safe.

Could directory be made explicitly Trustworthy (or Unsafe it's that's the case). filepath is explicitly Safe https://github.com/haskell/filepath/blob/51501dba4f963087eac2b67ed13b64fe0304d63b/System/FilePath.hs#L2-L4, so I'd expect directory to be too.

Rufflewind commented 11 months ago

This reminds me of https://github.com/haskell/directory/issues/147. I don't think directory should support SafeHaskell at all going forward, and thus the question of whether directory is Safe or Unsafe is indeterminate / undefined.

CC @Bodigrim

Rufflewind commented 11 months ago

BTW, what happens if you try to import System.OsPath under ghc-9.6.2?

phadej commented 11 months ago

@Rufflewind I don't import that. I use System.Directory.

Rufflewind commented 11 months ago

I don't import that. I use System.Directory.

I asked that question to help diagnose the root cause, in case someone was curious. Since System.Directory depends on System.OsPath, the inferred Safe-ty of System.Directory relies on that. This is what I could gather from my system:

GHCi, version 9.6.2: https://www.haskell.org/ghc/  :? for help
ghci> :set -XSafe

<no location info>: warning:
    -XGeneralizedNewtypeDeriving is not allowed in Safe Haskell; ignoring -GeneralizedNewtypeDeriving
ghci> import System.OsPath

<no location info>: error: [GHC-44360]
    System.OsPath: Can't be safely imported!
    The module itself isn't safe.

Regardless, SafeHaskell is not supported by directory, so I don't think any action is planned to be taken here.

Rufflewind commented 9 months ago

Closing because SafeHaskell is not supported by directory.