Build failure of hpc >= 0.6.0.3 with directory ^>= 1.3.8.0 (which is within version bound) due to fragile Safe Haskell inferrence
When I built hpc ==0.6.2.0
with directory ==1.3.8.1
, I saw the following build failure:
[1 of 4] Compiling Trace.Hpc.Util ( Trace/Hpc/Util.hs, dist/build/Trace/Hpc/Util.o, dist/build/Trace/Hpc/Util.dyn_o )
Trace/Hpc/Util.hs:35:1: error:
System.Directory: Can't be safely imported!
The module itself isn't safe.
|
35 | import System.Directory (createDirectoryIfMissing)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: cabal: Failed to build hpc-0.6.2.0. See the build log above for
details.
This build failure is unacceptable, as the dependency list of hpc >=0.6.0.3 && <=0.6.2.0
says it depends on directory >=1.1 && <1.4
, which includes directory ==1.3.8.1
.
In fact, I believe that if you build hpc >=0.6.0.3 && <=0.6.2.0
with directory >=1.3.8.0 && <=1.3.8.1
, your build will fail with a similar error.
As you see from the error, this problem is due to the change of the inferred Safe Haskell status of the module System.Directory
from directory
. Since our module Trace.Hpc.Util
is declared Safe
, it requires all the imports within it, including System.Directory
, to be Safe
or Trustworthy
.
In directory < 1.3.8
, System.Directory
was inferred to be Safe, fulfilling the restriction. However it is now inferred to be Unsafe in directory >= 1.3.8.0
, since the implementation of the module newly relies on some Unsafe modules from filepath >= 1.4.100
.
I think we have two things to do:
-
DONE : Update the package metadata of hpc-0.6.0.3, 0.6.1.0, 0.6.2.0
on Hackage, so that these versions would depend ondirectory >=1.1 && <1.3.8
. -
DONE; A Fix was provided in !23 (merged), which has been improved in !28 (merged). : Publish a new version of hpc
in whichTrace.Hpc.Util
isTrustworthy
instead ofSafe
, so that they build withdirectory >= 1.3.8.0
andfilepath >= 1.4.100.1
. In fact, a fix for this was once implemented in 9a078290, but got erased in 333052e3.