[GHC] #11536: Multitude of different error messages when installed package is missing a module

#11536: Multitude of different error messages when installed package is missing a module -------------------------------------+------------------------------------- Reporter: thomie | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.3 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: #8060, #9009, | #11023 Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- (I might clean this up later) Key points: * missing module in 'exposed-modules' field of .cabal file * package name equals some (functioning) installed package * ghc-pkg happily registers the package * errors don't show up until one tries to use the module * error messages are all different and all quite terrible Makefile to reproduce: {{{ GHCPKG=ghc-pkg #GHC=ghc-8.0.0.20160127 GHC=ghc-7.10.3 PACKAGEDB=../.cabal-sandbox/x86_64-linux-$(GHC)-packages.conf.d/ all : $(MAKE) --no-print-directory clean $(MAKE) --no-print-directory setup $(MAKE) --no-print-directory setup1 $(MAKE) --no-print-directory run1 @echo @echo $(MAKE) --no-print-directory clean $(MAKE) --no-print-directory setup $(MAKE) --no-print-directory setup2 $(MAKE) --no-print-directory run2 clean : rm -rf .cabal-sandbox cabal.sandbox.config rm -rf temp dist System *.cabal setup : mkdir temp mkdir -p System/FilePath cabal -v0 sandbox init echo "name: filepath " >> filepath.cabal echo "version: 99999.1.0 " >> filepath.cabal echo "build-type: Simple " >> filepath.cabal echo "cabal-version: >=1.10 " >> filepath.cabal echo "library " >> filepath.cabal echo " exposed-modules: " >> filepath.cabal echo " System.FilePath " >> filepath.cabal echo " System.FilePath.Posix " >> filepath.cabal echo " build-depends: base >=4.8 " >> filepath.cabal echo " default-language: Haskell2010" >> filepath.cabal echo "module System.FilePath (module System.FilePath.Posix) where"
System/FilePath.hs echo "import System.FilePath.Posix " System/FilePath.hs
echo "module System.FilePath.Posix where" >> System/FilePath/Posix.hs echo "takeFileName = id " >> System/FilePath/Posix.hs setup1 : @echo @echo 111111111111111111111111111111111 @echo - Remove a module from 'exposed-modules' @echo - Install package @echo - Run some tests @echo sed -i '/System.FilePath.Posix/d' filepath.cabal cabal install -v0 --with-ghc="$(GHC)" run1 : @echo @echo FAILURE MODE 1A @echo -cd temp && "$(GHC)" -v0 -package-db="$(PACKAGEDB)" -e 'import System.FilePath.Posix' @echo @echo FAILURE MODE 1B @echo -cd temp && "$(GHC)" -v0 -package-db="$(PACKAGEDB)" -e 'import System.FilePath' -e 'takeFileName "foo/bar"' @echo @echo FAILURE MODE 1C @echo echo 'import System.FilePath' > temp/Foo.hs echo 'main = print $$ takeFileName "foo/bar"' >> temp/Foo.hs -cd temp && "$(GHC)" -v0 -package-db="$(PACKAGEDB)" Foo.hs -fforce-recomp setup2 : @echo @echo 222222222222222222222222222222222 @echo - Install package @echo - Remove a module from 'exposed-modules' @echo - Reinstall package @echo - Run some tests @echo cabal install -v0 --with-ghc="$(GHC)" sed -i '/System.FilePath.Posix/d' filepath.cabal cabal install -v0 --with-ghc="$(GHC)" run2 : @echo @echo FAILURE MODE 2A, same as 1A @echo -cd temp && "$(GHC)" -package-db="$(PACKAGEDB)" -e 'import System.FilePath.Posix' @echo @echo FAILURE MODE 2B @echo -cd temp && "$(GHC)" -package-db="$(PACKAGEDB)" -e 'import System.FilePath' -e 'takeFileName "foo/bar"' @echo @echo FAILURE MODE 2C @echo echo 'import System.FilePath' > temp/Foo.hs echo 'main = print $$ takeFileName "foo/bar"' >> temp/Foo.hs -cd temp && "$(GHC)" -package-db="$(PACKAGEDB)" Foo.hs -fforce- recomp }}} Output (run `make`): {{{ # FAILURE MODE 1A # # cd temp && "ghc-7.10.3" -v0 -package-db="../.cabal-sandbox/x86_64-linux- ghc-7.10.3-packages.conf.d/" -e 'import System.FilePath.Posix' # # <no location info>: # Could not find module ‘System.FilePath.Posix’ # It is a member of the hidden package ‘filepath-1.4.0.0@filep_Ey7a1in9roBAE8bUFJ5R9m’. # make[1]: [run1] Error 1 (ignored) # # FAILURE MODE 1B # # cd temp && "ghc-7.10.3" -v0 -package-db="../.cabal-sandbox/x86_64-linux- ghc-7.10.3-packages.conf.d/" -e 'import System.FilePath' -e 'takeFileName "foo/bar"' # <interactive>: Failed to load interface for ‘System.FilePath.Posix’ # Perhaps you haven't installed the "dyn" libraries for package ‘filepath-99999.1.0’? # Use -v to see a list of the files searched for. # make[1]: [run1] Error 1 (ignored) # # FAILURE MODE 1C # # echo 'import System.FilePath' > temp/Foo.hs # echo 'main = print $ takeFileName "foo/bar"' >> temp/Foo.hs # cd temp && "ghc-7.10.3" -v0 -package-db="../.cabal-sandbox/x86_64-linux- ghc-7.10.3-packages.conf.d/" Foo.hs -fforce-recomp # Failed to load interface for ‘System.FilePath.Posix’ # There are files missing in the ‘filepath-99999.1.0’ package, # try running 'ghc-pkg check'. # Use -v to see a list of the files searched for. # make[1]: [run1] Error 1 (ignored) }}} More output: {{{ # FAILURE MODE 2A, same as 1A # # cd temp && "ghc-7.10.3" -package-db="../.cabal-sandbox/x86_64-linux- ghc-7.10.3-packages.conf.d/" -e 'import System.FilePath.Posix' # # <no location info>: # Could not find module ‘System.FilePath.Posix’ # It is a member of the hidden package ‘filepath-1.4.0.0@filep_Ey7a1in9roBAE8bUFJ5R9m’. # make[1]: [run2] Error 1 (ignored) # # FAILURE MODE 2B # # cd temp && "ghc-7.10.3" -package-db="../.cabal-sandbox/x86_64-linux- ghc-7.10.3-packages.conf.d/" -e 'import System.FilePath' -e 'takeFileName "foo/bar"' # <interactive>: # ByteCodeLink.lookupCE # During interactive linking, GHCi couldn't find the following symbol: # filepzuDQlytQXekB83614cuzzvF62_SystemziFilePathziPosix_takeFileName_closure # This may be due to you not asking GHCi to load extra object files, # archives or DLLs needed by your current session. Restart GHCi, specifying # the missing library using the -L/path/to/object/dir and -lmissinglibname # flags, or simply by naming the relevant files on the GHCi command line. # Alternatively, this link failure might indicate a bug in GHCi. # If you suspect the latter, please send a bug report to: # glasgow-haskell-bugs@haskell.org # # make[1]: [run2] Error 1 (ignored) # # FAILURE MODE 2C # # echo 'import System.FilePath' > temp/Foo.hs # echo 'main = print $ takeFileName "foo/bar"' >> temp/Foo.hs # cd temp && "ghc-7.10.3" -package-db="../.cabal-sandbox/x86_64-linux- ghc-7.10.3-packages.conf.d/" Foo.hs -fforce-recomp # [1 of 1] Compiling Main ( Foo.hs, Foo.o ) # Linking Foo ... # Foo.o: In function `sKS_info': # (.text+0xae): undefined reference to `filepzuDQlytQXekB83614cuzzvF62_SystemziFilePathziPosix_takeFileName_closure' # Foo.o: In function `SLc_srt': # (.data+0x88): undefined reference to `filepzuDQlytQXekB83614cuzzvF62_SystemziFilePathziPosix_takeFileName_closure' # collect2: error: ld returned 1 exit status # make[1]: [run2] Error 1 (ignored) }}} == Analysis * 1A: why mention a hidden (global) package, when it is hidden by a *broken* package. * 1B: misleading suggestion about "dyn" libraries * 1C: why does GHC say I should run ghc-pkg, but 'ghc-pkg check' says everything is fine? * 2A: same as 1A * 2B: scary: ByteCodeLink.lookupCE * 2C: terrible: undefined reference == Bonus With ghc-8.0.1-rc1, failure modes 1B, 1C, 2B and 2C look like this: {{{ # [1 of 1] Compiling Main ( Foo.hs, Foo.o ) # # Foo.hs:1:1: error: # Bad interface file: /home/thomas/tmp/test/filepath/.cabal- sandbox/lib/x86_64-linux- ghc-8.0.0.20160127/filepath-1.4.1.0-87VdeZTuOMDJQ40Wd1kNnE/System/FilePath.hi # Something is amiss; requested module filepath-1.4.1.0@filepath-1.4.1.0-435e90352be17e51f8e362eb5810bcd5:System.FilePath differs from name found in the interface file filep_87VdeZTuOMDJQ40Wd1kNnE:System.FilePath # make: [run2] Error 1 (ignored) }}} Related tickets: * https://github.com/haskell/cabal/issues/2982: Cabal will build and install broken library if other-modules is not complete * https://github.com/haskell/cabal/issues/3093: Missing files in package * #9009 Confusing error message when loading package with TH * #11023: ghci and ghc-pkg disagree about what's exposed * #8060: Undefined symbols when using Template Haskell linked from another object with unexposed modules #8060 was closed with:
GHC is not really in the business of checking the well-formedness of archive files installed in the package database, so there is not much GHC can do here.
-- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11536 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC