Open andreasabel opened 3 years ago
IMHO, cabal check
should warn:
dist
directory in the packageFoo.x
and Foo.hs
)And declare this issue as wontfix, as it's unclear what cabal build
or install
should do when there is an ambiguity or dist
.
I have no idea why build
works and install
doesn't. I think both should fail. Probably we look for dist/
when installing due some old packages on Hackage, but really we shouldn't.
EDIT: I remember that alex
itself did such trick for bootstrap, i.e. including preprocessed files. That didn't work very well, and we changed that so developers of alex
need to preprocess inputs themselves when developing / before sdist
. That's a slight inconvenience for alex
developers but a huge win for everyone else. BNFC
is even simpler: I think it shouldn't include preprocessed LexBNF.hs
(in latest version) at all, and let alex
do its job.
@phadej wrote:
- when there is
dist
directory in the package
Well, this dist
directory was added by the former self of cabal sdist
. (It is not coming from extra-source-files
etc.)
- there is conflicting files (e.g.
Foo.x
andFoo.hs
)
Same here. The cabal file just declares LexBNF
in source-modules
/other-modules
and then cabal sdist
added both the .x
and the .hs
file.
And declare this issue as wontfix, as it's unclear what cabal build or install should do when there is an ambiguity or dist.
So cabal
is at the level of politicians that state: "I don't care about what I said yesterday." ? :-D
In the nature of things (meaning, hackage), cabal will have to handle the products of its former selves.
In the nature of things (meaning, hackage), cabal will have to handle the products of its former selves.
Yes, But before working around previous mistakes, we have to put fences so we don't repeat them. Otherwise people will rely on them and complexity only grows with time.
Then the problematic cases can be dealt one-by-one.
Well, this dist directory was added by the former self of cabal sdist?
Is it?
At least it's not added by cabal-install-3.6
. (Try cabal get BNFC-2.8.3 && cd BNFC-2.8.3 && cabal sdist
).
I also tried with cabal-install-2.0
(released august 2017) and no dist/
in there. BNFC-2.8.3 is uploaded august 2019.
You can also upload BNFC-2.8.3.1
without dist
directory, which would fix an issue for all, and that should work (try with candidate, installing from tarball url should work similarly to installing package from Hackage).
And in BNFC-2.9.3 there is Lex.x
and Lex.hs
, and that is unfortunate. That's why I suggested that a cabal check
is added, so such packages couldn't be uploaded to Hackage in the future. Why you have Lex.hs
in your source tree? next to Lex.x
?
Previous discussion about such a warning here and in later comments: https://github.com/haskell/cabal/issues/7251#issuecomment-763705185
And https://github.com/haskell/cabal/issues/7258 seems relevant. Even reported by @andreasabel, I still wonder why Andreas is polluting his source tree by running alex
there, but I do agree that cabal check
shouldn't succeed in that case. And I think we can make cabal sdist
fail too, if it's going to include (haskell | preprocess) files which only differ in extension. (Different folders is harder, as these can be guarded by flags, but there could be ambiguity that way too).
@phadej wrote:
it's not added by
cabal-install-3.6
. (...). I also tried withcabal-install-2.0
(released august 2017) and nodist/
in there. BNFC-2.8.3 is uploaded august 2019.
Indeed. My apologies.
I am very puzzled by this, but evidence suggests that it was my own former self that tampered with the tarball before uploading it to hackage. I have no recollection of this, but it could have been that I wanted to be "on the safe side" and have the generated parser source included in case alex
/happy
were not available to the installer or would generate code with a different interface as at the time of shipping. Maybe I took alex
as an inspiration, see https://github.com/haskell-infra/hackage-trustees/issues/321#issue-1051382788: alex-3.2.1
also ships dist/
with pre-build scanner and parser.
It seems now that in some cases cabal
does use the pre-build code (remote install) and in some cases it does not (local install). Thinking about it, this is maybe even working as intended.
Only that I have, ironically, become a victim of my own precautions.
You can also upload
BNFC-2.8.3.1
withoutdist
directory, which would fix an issue for all,
Excellent suggestion!
IMHO,
cabal check
should warn:* when there is `dist` directory in the package
Ok, this would prevent boot-strapping tricks like used by alex-3.2.1
, but maybe they are obsolete now?
In my case, cabal check
would not have seen the dist/
directory as I likely added it manually later. But cabal upload
could complain.
Why you have
Lex.hs
in your source tree? next toLex.x
?
To be able to load my code into ghci
from a simple emacs haskell-mode.
TL;DR It seems that
cabal install BNFC-2.8.3
does not runalex
, butcabal get BNFC-2.8.3 && cd BNFC-2.8.3 && cabal install
does so. Consequently GHC-9.2.1-build fails in the former case but succeeds in the latter case.What is then the truth value of BNFC-2.8.3 builds with GHC-9.2.1 ?
This question came up in the wild, when I was investigating whether
BNFC-2.8.3
builds with GHC 9.2.1.1. Fails when directly installing from hackage
2. Succeeds when first downloading
WAT?
Installation succeeds when
LexBNF.x
is processed byalex-3.2.6
, which is my installed version:The plan for the local install indeed contains
alex-3.2.6
:These are the versions of
LexBNF.hs
in the directory structure:The third has been created during build by
alex-3.2.6
.Further analysis of remote install
Note that constraining
alex == 3.2.6
does not help with the remote install:It is noteworthy that the package contains both:
LexBNF.x
LexBNF.hs
created with somealex < 3.2.6
More precisely, the tarball has:
Some excerpts from
-v3
:Here, we break to remember that the Grinch stole the vowels from
alex
, just leaving uslx
(#7209).We break to wonder why no constraint on
alex
made it into the final description.I did not see an invocation of
alex
in-v3
. It seems thatLexBNF
is taken from the shippeddist/build/bnfc/bnfc-tmp/
.