Skip to content

cabal init allows a license that cabal install does not understand #4496

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

Closed
Smattr opened this issue May 5, 2017 · 9 comments
Closed

cabal init allows a license that cabal install does not understand #4496

Smattr opened this issue May 5, 2017 · 9 comments

Comments

@Smattr
Copy link

Smattr commented May 5, 2017

Summary. For example, a license containing a space:

$ cabal init
...
Please choose a license:
...
  14) Other (specify)
Your choice? [default: BSD3] 14
Please specify? hello world
...
$ cabal install
cabal: tmp.cabal:9: Parse of field 'license' failed.

Despite the promising sounding title, this does not appear to be a duplicate of #3098 that talks about license-file, not license. It is possible this is related to #1074 if cabal install is calling cabal check.

Instructions from @ezyang. First, follow the instructions in the README at https://github.com/haskell/cabal for setting up your dev environment.

As you can see from instance Parsec License, the set of permitted characters for a free-form license text is one or more alpha-numeric characters. To fix this bug, you will have to modify cabal-install/Distribution/Client/Init.hs to check if the other license has valid syntax and reject it / ask the user for another license if it does not.

To see an example of an existing prompt which will reprompt if the text is invalid, see getPackageName.

If you want to go further beyond this ticket, look at getLanguage and make sure it doesn't also suffer from the same error.

A test for this fix is not necessary, but you should run the resulting cabal binary and check that the correct behavior occurs.

If you want a nice follow up task, look at #1074, decide what to do, and fix it!

What you will learn. How to test if a string is alphanumeric in Haskell; how the prompt mechanism in cabal init works. This is a nice and easy task to get started with the cabal-install build system as well.

@ezyang
Copy link
Contributor

ezyang commented May 5, 2017

Thanks for the very clear report @Smattr. I've turned this into a newcomer task for someone new to Haskell who wants to dip their toe in the Cabal project.

@Smattr
Copy link
Author

Smattr commented May 5, 2017

Thanks, @ezyang, and nice write up of an action plan! Gives the reader a very detailed idea of what they're in store for if they take the bait.

@2016rshah
Copy link

I would like to work on this! I think I know how to do it (thanks to this excellently written issue) but I am having trouble setting up the development environment. I forked the repository and cloned it on my local machine. Then I tried to run stack build which failed with

Error: While constructing the build plan, the following exceptions were encountered:

In the dependencies for cabal-install-2.1.0.0(+parsec):
    echo-0.1.2 must match >=0.1.3 && <0.2 (latest applicable is 0.1.3)

In the dependencies for cabal-testsuite-2.1.0.0:
    regex-compat-tdfa must match -any, but the stack configuration has no specified version
                      (latest applicable is 0.95.1.4)

Recommended action: try adding the following to your extra-deps in /Users/rushi/github/cabal/stack.yaml:
- regex-compat-tdfa-0.95.1.4

You may also want to try the 'stack solver' command
Plan construction failed.

so I ran stack solver and got the following:

>>>> Cabal errors begin
Warning: cannot determine version of /usr/bin/strip :
""
cabal: Could not resolve dependencies:
trying: cabal-install-2.1.0.0:-lib
trying: cabal-install-2.1.0.0:-debug-tracetree
trying: cabal-install-2.1.0.0:-debug-conflict-sets
next goal: echo (dependency of cabal-install-2.1.0.0:-lib)
rejecting: echo-0.1.3 (constraint from main config
/private/var/folders/hk/6r231l_j3f723ml2xl69thm00000gp/T/cabal-solver36748/cabal.config
requires ==0.1.2)
rejecting: echo-0.1.2 (conflict: cabal-install-2.1.0.0:lib => echo>=0.1.3 &&
<0.2)
rejecting: echo-0.1.1, echo-0.1 (constraint from main config
/private/var/folders/hk/6r231l_j3f723ml2xl69thm00000gp/T/cabal-solver36748/cabal.config
requires ==0.1.2)
Dependency tree exhaustively searched.
<<<< Cabal errors end

Could not parse cabal-install errors:

>>>> Cabal errors begin
Warning: cannot determine version of /usr/bin/strip :
""
cabal: Could not resolve dependencies:
trying: cabal-install-2.1.0.0:-lib
trying: cabal-install-2.1.0.0:-debug-tracetree
trying: cabal-install-2.1.0.0:-debug-conflict-sets
next goal: echo (dependency of cabal-install-2.1.0.0:-lib)
rejecting: echo-0.1.3 (constraint from main config
/private/var/folders/hk/6r231l_j3f723ml2xl69thm00000gp/T/cabal-solver36748/cabal.config
requires ==0.1.2)
rejecting: echo-0.1.2 (conflict: cabal-install-2.1.0.0:lib => echo>=0.1.3 &&
<0.2)
rejecting: echo-0.1.1, echo-0.1 (constraint from main config
/private/var/folders/hk/6r231l_j3f723ml2xl69thm00000gp/T/cabal-solver36748/cabal.config
requires ==0.1.2)
Dependency tree exhaustively searched.
<<<< Cabal errors end

Any ideas what I might be doing wrong? Can't wait to get started on this contribution!

@ezyang
Copy link
Contributor

ezyang commented May 6, 2017

Despite the presence of a stack config file, I don't think any of the main developers use stack to develop cabal, so I guess it's not surprising it's not working. Try using new-build instead: https://github.com/haskell/cabal#building-cabal-for-hacking

@23Skidoo
Copy link
Member

23Skidoo commented May 6, 2017

Yes, the stack build is broken more often than not. Patches welcome!

@colinwahl
Copy link
Contributor

colinwahl commented May 6, 2017

Hi all! I just gave this issue a shot and opened a PR. It is building on travis now. I just checked and it looks like getLanguage suffers from the same issue, so I will add a fix for that as well. If anyone could look over it, please let me know what I should change!

EDIT: added the fix for getLanguage as well!

colinwahl added a commit that referenced this issue May 6, 2017
checks if license provided is alphanumeric. #4496
@colinwahl
Copy link
Contributor

PR #4504 has been merged. I will close this for now.

@Smattr
Copy link
Author

Smattr commented May 7, 2017

Nice work, everyone! Very speedy resolution. @2016rshah if you have a dev environment setup and are now in need of a new issue to work on, it looks like there are plenty of approachable open ones. Though it's not tagged with newcomer, #3853 might be a valuable one to address. I know little about Cabal internals, but am happy to help with setup problems or Haskell questions. @ezyang, please feel free to contradict anything I've said or give different issue suggestions if you disagree :)

@ezyang
Copy link
Contributor

ezyang commented May 7, 2017

@Smattr I guess I better go newcomer-ify that ticket :) (There's something tricky, which is the code change probably needs to be made in hackage-security, not cabla-install)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants