Skip to content

Misleading error message when trying to import a module from the wrong version of a package #10770

Open
@Soupstraw

Description

Describe the feature request

I recently ran into an issue where cabal had resolved the sdl2 package to a really old version since I hadn't specified the bounds for the sdl2 dependency. I was trying to import a module that exists only in newer versions of the package and then I was greeted with the following error:

app/Main.hs:5:1: error: [GHC-87110]
    Could not load module ‘SDL’.
    It is a member of the hidden package ‘sdl2-2.5.5.0’.
    Perhaps you need to add ‘sdl2’ to the build-depends in your .cabal file.
    Use -v to see a list of the files searched for.
  |
5 | import SDL
  | ^^^^^^^

It took me a while to figure out that the version of sdl2 that cabal was using was actually 1.2.0 and adding explicit bounds to sdl2 fixed the issue.
I think this error message could be improved to something like this:

app/Main.hs:5:1: error: [GHC-87110]
    Could not load module ‘SDL’.
    It is a member of the package `sdl2-2.5.5.0`, but you're currently using `sdl2-1.2.0`.
    Perhaps you need to add explicit bounds to the `sdl2` dependency in your .cabal file.
    Use -v to see a list of the files searched for.
  |
5 | import SDL
  | ^^^^^^^

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions