Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

cabal init crashes when encountering directories that aren't valid module names #1052

Closed
byorgey opened this Issue · 1 comment

2 participants

@byorgey
Collaborator

A minimal test case follows:

[byorgey@LVN513-9:~/tmp]$ mkdir pkg
[byorgey@LVN513-9:~/tmp]$ cd pkg
[byorgey@LVN513-9:~/tmp/pkg]$ mkdir "Foo-bar"
[byorgey@LVN513-9:~/tmp/pkg]$ cd Foo-bar
[byorgey@LVN513-9:~/tmp/pkg/Foo-bar]$ cat > Test.hs
x = 43
[byorgey@LVN513-9:~/tmp/pkg/Foo-bar]$ cd ..
[byorgey@LVN513-9:~/tmp/pkg]$ cabal init
Package name? [default: pkg] 
Package version? [default: 0.1.0.0] 
Please choose a license:
 * 1) (none)
   2) GPL-2
   3) GPL-3
   4) LGPL-2.1
   5) LGPL-3
   6) BSD3
   7) MIT
   8) PublicDomain
   9) AllRightsReserved
  10) Other (specify)
Your choice? [default: (none)] 
Author name? [default: Brent Yorgey] 
Maintainer email? [default: byorgey@cis.upenn.edu] 
Project homepage URL? 
Project synopsis? 
Project category:
 * 1) (none)
   2) Codec
   3) Concurrency
   4) Control
   5) Data
   6) Database
   7) Development
   8) Distribution
   9) Game
  10) Graphics
  11) Language
  12) Math
  13) Network
  14) Sound
  15) System
  16) Testing
  17) Text
  18) Web
  19) Other (specify)
Your choice? [default: (none)] 
What does the package build:
   1) Library
   2) Executable
Your choice? 1
Include documentation on what each field means (y/n)? [default: n] 
cabal: ModuleName.fromString: invalid module name "Foo-bar.Test"

The problem is here:

https://github.com/haskell/cabal/blob/master/cabal-install/Distribution/Client/Init/Heuristics.hs#L93

We should not be using ModuleName.fromString on arbitrary directory names since it throws an exception on anything which is not a valid module name. Instead we should use Distribution.Text.simpleParse. If a directory is encountered that appears to contain Haskell modules but corresponds to an invalid module name, a warning should be issued that it will be ignored.

@byorgey byorgey was assigned
@23Skidoo
Collaborator

cabal install crashes

Should be "cabal init".

@byorgey byorgey closed this in 1381826
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.