cabal-plan
cabal-plan copied to clipboard
Bad error message `No hackage.haskell.org repository` for legacy `remote-repo` entry in the cabal configuration
It would be good if the help texts contained some example uses.
I fail to discover how to invoke cabal-plan
to get my license report.
This is what I tried:
$ cabal install -f license-report cabal-plan
...
$ cabal-plan --version
cabal-plan 0.7.2.0
$ cabal-plan license-report --help
Usage: cabal-plan license-report [--licensedir DIR] PATTERN
Generate license report for a component
Available options:
--licensedir DIR Write per-package license documents to folder
PATTERN Pattern to match.
-h,--help Show this help text
$ cabal-plan license-report Agda:exe:agda
cabal-plan: user error (No hackage.haskell.org repository)
$ ping hackage.haskell.org
PING ...: 56 data bytes
64 bytes from ... icmp_seq=0 ttl=60 time=15.678 ms
In particular, I do not understand the error No hackage.haskell.org repository
and how to address it.
After some research, looking at the source code of cabal-plan
(passing the safety pig ;-)), I could fix the problem by replacing in my .cabal/config
remote-repo: hackage.haskell.org:http://hackage.haskell.org/packages/archive
with
repository hackage.haskell.org
url: http://hackage.haskell.org/
However, according to https://cabal.readthedocs.io/en/latest/installing-packages.html#legacy-repositories this is just expanding a synonym:
remote-repo: hackage.haskell.org:http://hackage.haskell.org/packages/archive
This is just syntactic sugar for
repository hackage.haskell.org url: http://hackage.haskell.org/packages/archive
although, in (and only in) the specific case of Hackage, the URL http://hackage.haskell.org/packages/archive will be silently translated to http://hackage.haskell.org/.
JFTR: I just ran into this as well
I just ran into this, and wanted to make the workaround/fix more explicit in case anyone else still has an ancient .cabal/config around.
Basically, the remote-repo
field in Cabal config files is “legacy” (read: obsolete and not well supported). To fix it, rewrite any
remote-repo: {{repository}}:{{url}}
to
repository {{repository}}
url: {{url}}
Since providing a better error message here would basically entail parsing remote-repo
anyway, it seems like it’s no harder to just support the legacy syntax. I.e., I feel like this issue should be closed, and instead, it would be nice if Cabal itself warned on legacy syntax.