Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cabal init prints error message forever when using invalid license #6619

Closed
wants to merge 1 commit into from

Conversation

v0d1ch
Copy link
Contributor

@v0d1ch v0d1ch commented Mar 27, 2020

fixes #6227
When choosing non adequate license error message is printed in a loop.
I fixed that behavior and now we get something like this:

The license must be alphanumeric. If your license name has many words, the convention is to use camel case (e.g. PublicDomain). Please choose a different license.

Guessing dependencies...

Generating LICENSE...
Warning: unknown license type, you must put a copy in LICENSE yourself.
Generating Setup.hs...

The issue where the user sees the exception on failed parsing is still there:

Cannot parse license: a-a-1
CallStack (from HasCallStack):
  error, called at ./Distribution/ReadE.hs:42:24 in Cabal-3.0.0.0-fb617b94c4973e1d5149e5c5439c47b4e57443a0819f354a288475aa6cef5eae:Distribution.ReadE

I don't know if we want to prevent this from happening.
In my mind users should't see these kinds of exceptions but maybe it should be a separate issue.

When choosing non adequate license error message
is printed in a loop
@v0d1ch v0d1ch changed the title 6337 cabal init prints error message forever when using invalid license Cabal init prints error message forever when using invalid license Mar 27, 2020
@m-renaud
Copy link
Collaborator

m-renaud commented Apr 4, 2020

Hey @v0d1ch, thanks for taking a look at this (and sorry for the delay)! With your change what's the behaviour if init is run in interactive mode without a license being specified from the CLI? The current behaviour is it will re-prompt if you don't select a valid choice, for example:

Please choose a license:
   1) GPL-2.0-only
  ...
  13) NONE
  14) Other (specify)
Your choice? [default: BSD-3-Clause] 15
15 is not a valid choice.
Your choice? [default: BSD-3-Clause] 

Agreed that hiding the parse error message and showing something more user friendly is out of scope here, it would require changing the command line argument parsing in Client/Setup.hs. I recently split up Init.hs into sub-modules so you'll need to rebase your changes on top of master and update Client/Init/Command.hs.

phadej added a commit to phadej/cabal that referenced this pull request Apr 6, 2020
- Always ask for SPDX expression, we can "convert" them to old format
- No default license
- cabal-version is asked using CabalSpecVersion type
- seems to fix what haskell#6619 tries to fix:

```
% /code/shared-haskell/cabal/dist-newstyle/build/x86_64-linux/ghc-8.8.3/cabal-install-3.3.0.0/x/cabal/build/cabal/cabal init -l 'FOO AND BAR'
Cannot parse license: FOO AND BAR
CallStack (from HasCallStack):
  error, called at ./Distribution/ReadE.hs:42:24 in Cabal-3.3.0.0-inplace:Distribution.ReadE
```

an error, but it doesn't loop.
phadej added a commit to phadej/cabal that referenced this pull request Apr 6, 2020
- Always ask for SPDX expression, we can "convert" them to old format
- No default license
- cabal-version is asked using CabalSpecVersion type
- seems to fix what haskell#6619 tries to fix:

```
% /code/shared-haskell/cabal/dist-newstyle/build/x86_64-linux/ghc-8.8.3/cabal-install-3.3.0.0/x/cabal/build/cabal/cabal init -l 'FOO AND BAR'
Cannot parse license: FOO AND BAR
CallStack (from HasCallStack):
  error, called at ./Distribution/ReadE.hs:42:24 in Cabal-3.3.0.0-inplace:Distribution.ReadE
```

an error, but it doesn't loop.
phadej added a commit to phadej/cabal that referenced this pull request Apr 6, 2020
- Always ask for SPDX expression, we can "convert" them to old format
- No default license
- Add cabal-version: 3.0 to the list
- cabal-version is asked using CabalSpecVersion type
- seems to fix what haskell#6619 tries to fix:

```
% /code/shared-haskell/cabal/dist-newstyle/build/x86_64-linux/ghc-8.8.3/cabal-install-3.3.0.0/x/cabal/build/cabal/cabal init -l 'FOO AND BAR'
Cannot parse license: FOO AND BAR
CallStack (from HasCallStack):
  error, called at ./Distribution/ReadE.hs:42:24 in Cabal-3.3.0.0-inplace:Distribution.ReadE
```

an error, but it doesn't loop.
@phadej
Copy link
Collaborator

phadej commented Apr 6, 2020

I think #6661 fixes the looping issue as a side-effect.

The command line parser doesn't produce an UnknownLicense str anymore which caused later code to loop.

@phadej phadej closed this Apr 6, 2020
phadej added a commit to phadej/cabal that referenced this pull request Apr 6, 2020
- Always ask for SPDX expression, we can "convert" them to old format
- No default license
- Add cabal-version: 3.0 to the list
- cabal-version is asked using CabalSpecVersion type
- seems to fix what haskell#6619 tries to fix:

```
% /code/shared-haskell/cabal/dist-newstyle/build/x86_64-linux/ghc-8.8.3/cabal-install-3.3.0.0/x/cabal/build/cabal/cabal init -l 'FOO AND BAR'
Cannot parse license: FOO AND BAR
CallStack (from HasCallStack):
  error, called at ./Distribution/ReadE.hs:42:24 in Cabal-3.3.0.0-inplace:Distribution.ReadE
```

an error, but it doesn't loop.
phadej added a commit to phadej/cabal that referenced this pull request Apr 6, 2020
- Always ask for SPDX expression, we can "convert" them to old format
- No default license
- Add cabal-version: 3.0 to the list
- cabal-version is asked using CabalSpecVersion type
- seems to fix what haskell#6619 tries to fix:

```
% /code/shared-haskell/cabal/dist-newstyle/build/x86_64-linux/ghc-8.8.3/cabal-install-3.3.0.0/x/cabal/build/cabal/cabal init -l 'FOO AND BAR'
Cannot parse license: FOO AND BAR
CallStack (from HasCallStack):
  error, called at ./Distribution/ReadE.hs:42:24 in Cabal-3.3.0.0-inplace:Distribution.ReadE
```

an error, but it doesn't loop.
@phadej phadej mentioned this pull request Jul 10, 2020
@phadej phadej added this to the 3.4.0.0-rc1 milestone Jul 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cabal init -l BSD-3-Clause prints error message forever
3 participants