Ticket #844 (closed defect: fixed)

Opened 2 years ago

Last modified 2 years ago

Cabal reports "cabal: internal error: the package contains a library but there is no corresponding configuration data" when there exists no library in the cabal file

Reported by: fushunpoon Owned by:
Priority: low Milestone:
Component: Cabal library Version: 1.8.0.6
Severity: minor Keywords:
Cc: Difficulty: easy (<4 hours)
GHC Version: Platform: Mac OS

Description (last modified by duncan) (diff)

When trying to build my test project to play with SDL, I encountered the following message:

"cabal: internal error: the package contains a library but there is no corresponding configuration data" on the following cabal file:

even though my project cabal file specifies no libraries. Surely either this is an erroneous message or there is something wrong with the logic in cabal. Note that 'configure' and 'sdlexprs.buildinfo.in' exist as files, and they are attached with this post.

Name:                sdlexprs
Version:             0.1
Synopsis:            Just some hacks using SDL!
License:             LGPL
License-file:       LICENSE
Author:              <<my-name>>
Category:            Graphics
Build-type:          Configure
Extra-source-files:  configure,sdlexprs.buildinfo.in

Cabal-version:       >=1.2

Executable test
   -- Specify the source directory here
   Hs-source-dirs:    src
 
   -- .hs or .lhs file containing the Main module.
   Main-is:           SDLWrapper.hs

Attachments

sdlexprs.buildinfo.in Download (23 bytes) - added by fushunpoon 2 years ago.
A means of getting the string from sdl-config
configure Download (147 bytes) - added by fushunpoon 2 years ago.
The configure file.

Change History

Changed 2 years ago by fushunpoon

A means of getting the string from sdl-config

Changed 2 years ago by fushunpoon

The configure file.

Changed 2 years ago by duncan

  • keywords library configuration data removed
  • description modified (diff)

Changed 2 years ago by fushunpoon

  • priority changed from normal to low
  • difficulty changed from normal to easy (<4 hours)
  • severity changed from normal to minor

I have found out precisely the reason why this error is displayed:

The sdlexprs.buildinfo.in file that I wrote did not declare the cc-options line under the specific executable test. This means that by default it was treated as build information for a library as opposed to an executable when the sdlexprs.buildinfo file is consulted when doing a cabal build.

This problem deserves a better error message earlier on, perhaps as a warning, that even though no Library sections exist in the cabal file, the consulted *.buildinfo file does. This surely is an inconsistency on part of the user. To say that the project "contains a library" is misleading and is confusing, especially when the .cabal file is supposed to be the definitive package description file.

Changed 2 years ago by duncan

  • status changed from new to closed
  • resolution set to fixed

Yes, your analysis is correct (I just discovered the same thing).

So the bug in cabal is that it merges the buildinfo with the packagedescription incorrectly and that it does not do any sanity check of that buildinfo.

As you discovered, the solution for you is to generate buildinfo for the executable rather than the library. The structure of the buildinfo file is documented in the user guide: http://haskell.org/cabal/users-guide/authors.html#system-dependent

Bug fixed with this patch:

Wed May 18 13:33:31 BST 2011  Duncan Coutts <duncan@community.haskell.org>
  * Do a sanity check on the HookedBuildInfo
  Fixes ticket #844. Previously the function that merged the HookedBuildInfo
  into the PackageDescription would add a library section even if none
  previously existed.
  
  Now we generate an error message if the HookedBuildInfo contains info
  for non-existant components (libs/exes), e.g:
  
  Setup: The buildinfo contains info for a library, but the package does not
  have a library.
Note: See TracTickets for help on using tickets.