Skip to content

edge cases in broken templates give odd errors #1535

Closed
@kadoban

Description

@kadoban

These are rather dumb, but I could still see them coming up in practice and it might not be the worst idea to handle them:

Blank Template

Steps to Reproduce
~$ touch blah.hsfiles
~$ stack new blah blah
Downloading template "blah" to create project "blah" in blah/ ...
/home/mud/blah/: getDirectoryContents: does not exist (No such file or directory)
Expected

An error message about the template being empty.

Template without .cabal

Steps to Reproduce
~$ printf "{-# START_FILE BOGUS #-}\n" > blah.hsfiles
~$ stack new blah blah
Downloading template "blah" to create project "blah" in blah/ ...
Writing default config file to: /home/mud/blah/stack.yaml
Basing on cabal files:

In order to init, you should have an existing .cabal file. Please try "stack new" instead
Expected

Either an inited package or (since that's probably not really sane without a .cabal file) a better error message about the template being broken. Edit: I just noticed that it works file with an empty .cabal file, so maybe it would make sense for stack.yaml to do the same thing when .cabal doesn't exist?

In particular it's kind of amusing, but not really helpful, that it tells you to run "stack new" when that's what you just tried.

If there's a real use for a template that doesn't include a .cabal file (I can't think of one, but maybe someone else can), it might be acceptable to just have a big warning about why init didn't do anything, and ideally remove the suggestion about "stack new".

Version
Version 0.1.10.1, Git revision 83ec40fc5fd6d300c73d23deb1f41d30168fc236 (2783 commits) x86_64

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions