Skip to content

ghc reports package-id in unused imports warning instead the package name+version+id

Summary

From https://github.com/haskell/cabal/issues/7209#issuecomment-1080118466 ghc reports bad package name in unused imports warning when the package-id name segment does not match the package name

Steps to reproduce

  • cabal build -v3 a project with any dependency containing vowels and ghc-options: -Wunused-packages -Werror=unused-packages
  • check the ghc call made by cabal pass the package id removing vowels from the package name
    • for the ieee package it would be like -package-id -0.7-c9bfa6bf
  • check the v2 store package db has the complete package name for such package id:
# ghc-pkg --package-db ~/.cabal/store/ghc-9.2.2/package.db describe ieee | head -n 5
name:                 ieee
version:              0.7
visibility:           public
id:                   -0.7-c9bfa6bf
key:                  -0.7-c9bfa6bf
  • and check the unused package warning uses the package-id instead the full package name plus version:
<no location info>: warning: [-Wunused-packages]
    The following packages were specified via -package or -package-id flags,
    but were not needed for compilation:
      - -0.7-c9bfa6bf

Expected behavior

  • the error message should use the full package name + package version from package-db
<no location info>: warning: [-Wunused-packages]
    The following packages were specified via -package or -package-id flags,
    but were not needed for compilation:
      - ieee-0.7

Environment

  • GHC version used: 8.10.7, 9.2.2

Optional:

  • Operating System: macos
  • System Architecture: anyñ
Edited by Javier Neira
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information