Search code examples
haskellcabalcabal-installhaskell-platform

fails to find cabal file when file present


I have the following directory structure: ls:

  Project.Cabal
  LICENSE
  Setup.hs
  cabal.sandbox.config
  dist
  src
     Main.hs
     otherstuff
  tests

running cabal install --only-denendencies produces: cabal: Error reading local package. Couldn't find .cabal file in: .

running cabal install -v3 --only-dependencies produces relatively lengthy output that I'm currently choosing not to post in full to avoid being immediatly overwhelming. The final few lines before error are:

The package database already exists:
/Users/abraham/github/hamming_distance/.cabal-sandbox/x86_64-osx-ghc-7.10.2-packages.conf.d
Reading available packages...
Reading installed packages...
("/usr/bin/ghc-pkg",["dump","--package-db=/Users/abraham/github/hamming_distance/.cabal-sandbox/x86_64-osx-ghc-7.10.2-packages.conf.d","-v0"])
("/usr/bin/ghc",["--print-libdir"])
Found no modified add-source deps.
Reading installed packages...
("/usr/bin/ghc-pkg",["dump","--global","-v0"])
("/usr/bin/ghc-pkg",["dump","--package-db=/Users/abraham/github/hamming_distance/.cabal-sandbox/x86_64-osx-ghc-7.10.2-packages.conf.d","-v0"])
("/usr/bin/ghc",["--print-libdir"])
Reading available packages...
cabal: Error reading local package.
Couldn't find .cabal file in: .

Similiarly, running cabal build produces:

Package has never been configured. Configuring with default flags. If this
fails, please run configure manually.
cabal: No cabal file found.
Please create a package description file <pkgname>.cabal

While running `cabal build -v3` produces:
..
..
..
The package database already exists:
/Users/abraham/github/hamming_distance/.cabal-sandbox/x86_64-osx-ghc-7.10.2-packages.conf.d
Reading installed packages...
("/usr/bin/ghc-pkg",["dump","--global","-v0"])
("/usr/bin/ghc-pkg",["dump","--package-db=/Users/abraham/github/hamming_distance/.cabal-sandbox/x86_64-osx-ghc-7.10.2-packages.conf.d","-v0"])
("/usr/bin/ghc",["--print-libdir"])
Reading available packages...
cabal: No cabal file found.
Please create a package description file <pkgname>.cabal

What is going on? Why is my cabal failing? And how do I fix it?


Solution

  • There's already a hint in the error message:

    cabal: No cabal file found.
    Please create a package description file <pkgname>.cabal
    

    Cabal only looks for .cabal files, not .Cabal. Change the extension of your Project.Cabal to the lowercase one.