Stack failed to construct a build plan [S-4804]

This error occurs when Stack configuration has no package with the given name or if the version number of a package does not match the one from Stack configuration. The error covers the following situations:

See the list of packages provided by the snapshots Stackage.

Examples

Package version does not match Stack configuration

The specific version of the package is not provided by the snapshot. The error that results from stack build is:

 Error: [S-4804]
       Stack failed to construct a build plan.
       
       While constructing the build plan, Stack encountered the following exceptions:
       
       In the dependencies for blah-0.1.0.0:
           say-0.1.0.1 from Stack configuration does not match >=100.2.0.1 
       needed since blah is a build target.
       
       Some different approaches to resolving this:
       
         * Set 'allow-newer: true'
           in /home/USER/.stack/config.yaml to ignore all version constraints and build anyway.
package.yaml
Before
name:                blah

dependencies:
- base >= 4.7 && < 5
- say >= 100.2.0.1

library:
  source-dirs: src

executables:
  blah-exe:
    main:                Main.hs
    source-dirs:         app
    dependencies:
    - blah
After
name:                blah

dependencies:
- base >= 4.7 && < 5
- say >= 0.1.0.1

library:
  source-dirs: src

executables:
  blah-exe:
    main:                Main.hs
    source-dirs:         app
    dependencies:
    - blah
The package does not exist in the snapshot

The given package name is not provided by the snapshot. For example, stack build results in the error:

Error: [S-4804]
       Stack failed to construct a build plan.
       
       While constructing the build plan, Stack encountered the following exceptions:
       
       In the dependencies for blah-0.1.0.0:
           wrong-package must match >=0.2, but the Stack configuration has no specified version (no
                         package with that name found, perhaps there is a typo in a package's
                         build-depends or an omission from the stack.yaml packages list?)
       needed since blah is a build target.
package.yaml
Before
name:                blah

dependencies:
- base >= 4.7 && < 5
- wrong-package >= 0.2

library:
  source-dirs: src

executables:
  blah-exe:
    main:                Main.hs
    source-dirs:         app
    dependencies:
    - blah
After
name:                blah

dependencies:
- base >= 4.7 && < 5

library:
  source-dirs: src

executables:
  blah-exe:
    main:                Main.hs
    source-dirs:         app
    dependencies:
    - blah