Search code examples
linuxhaskellcabal

Why am I getting the error "cabal: 'init' doesn't take any extra arguments" for the command "cabal init <projectname>"


I have installed GHC 9.0.1 on Debian 12 and "cabal --version" yields:

$ cabal --version
cabal-install version 3.6.2.0
compiled using version 3.6.3.0 of the Cabal library 

I have started following the Cabal documentation guide, and when I run:

$ cabal init myapp --non-interactive

It throws back the error:

cabal: 'init' doesn't take any extra arguments: myapp

Not sure what the issue is, but it would appear that the "cabal init" command isn't expecting any additional parameters, therefore you can't create a project in this way. I guess it could have been changed or removed in newer versions or something like that, but I'm not sure. There also appears to be no manual for Cabal, only the "--help" flag which is very minimal and only for quick reference.

I can easily generate a .cabal file and structure using the current working directory by simply using cabal init, but I would like to be able generate a new project tree using "cabal init " as instructed in the guide.

Any idea as to why this isn't working for me?


Solution

  • That's a decently old version of cabal-install. 3.12 came out a couple days ago. If you're going to stick with an old version, you should read the documentation for that version. https://cabal.readthedocs.io/en/3.6/getting-started.html says:

    $ mkdir myfirstapp
    $ cd myfirstapp
    

    Once you have an empty directory we can initialize our package:

    $ cabal init --cabal-version=2.4 --license=NONE -p myfirstapp