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

Build instructions in contributing.rst are wrong #274

Closed
andreasabel opened this issue Mar 19, 2024 · 17 comments
Closed

Build instructions in contributing.rst are wrong #274

andreasabel opened this issue Mar 19, 2024 · 17 comments
Labels

Comments

@andreasabel
Copy link
Member

- If you *do* have an existing Happy executable on the PATH or in the default
installation location (`~/.cabal/bin` for example), do regular
::
$ cabal build
like with any other project.

On a fresh working copy of master ( 535ce96 ):

$ happy -V
Happy Version 1.20.1.1  ...

$ cabal build
....
Preprocessing library for happy-frontend-2.0...
happy: /Users/abel/project/open-source/happy-master/././HappyTemplate-arrays-coerce: openFile: does not exist (No such file or directory)
Error: [Cabal-7125]
Failed to build happy-frontend-2.0 (which is required by exe:happy from happy-2.0).

ATTN: @Ericson2314 @int-index

@int-index
Copy link
Collaborator

Sounds like an issue with the happy that you have in your $PATH. Similar issue: #262.

I can't reproduce the failure.

@andreasabel
Copy link
Member Author

Do you mean you can only bootstrap happy-2 by happy-2 ? Then maybe this should be added to the doc.

To me it looks more like happy-2 wants some template that has not been created. Maybe cabal build does not create these templates, or not at the right time?

@int-index
Copy link
Collaborator

Do you mean you can only bootstrap happy-2 by happy-2 ?

Not at all. I mean that your installation of happy-1 might be somehow misconfigured.

@andreasabel
Copy link
Member Author

Well, it is not. I use it all the time, to rebuild Agda, to test BNFC etc.

Also, the non-existing file mentioned in the error is in the domain of happy-master:

/Users/abel/project/open-source/happy-master/././HappyTemplate-arrays-coerce

@int-index wrote:

Sounds like an issue with the happy that you have in your $PATH. Similar issue: #262.

You hypothesis there was never confirmed.

And here is the counterevidence: I can exactly reproduce #262 (and my error) in a workflow:
https://github.com/haskell/happy/actions/runs/8378168492/job/22942066511?pr=275#step:6:28

happy: /home/runner/work/happy/happy/././HappyTemplate-arrays-coerce: openFile: does not exist (No such file or directory)

The workflow (c9b18cb) follows the build instructions in the manual.

Maybe your system isn't clean, that's why you cannot reproduce the issue? You might have happy-2 install artefacts lying around, maybe after running bootstrap.hs or some previous happy-2 installation.

@int-index
Copy link
Collaborator

OK, I've reproduced this on another machine. Seems to be a non-deterministic failure, sensitive to build order. Could you try this sequence of commands?

$ cabal build happy-frontend
$ cabal build

Building happy-frontend first seems to help.

@andreasabel
Copy link
Member Author

$ cabal build happy-frontend
$ cabal build

Yes this works.

But why?
Is the bootstrap turned on just if cabal build happy-frontend is invoked, and not with cabal build all or `cabal build [happy]?

flag bootstrap
description:
Optimize the implementation of happy using a pre-built happy,
and add support for attribute grammars.
manual: True
default: True

@int-index
Copy link
Collaborator

The bootstrap flag is turned on either way. You can also confirm this by specifying it manually

cabal build happy-frontend -f +bootstrap
cabal build all -f +bootstrap

@int-index
Copy link
Collaborator

The failure seems to be caused by cabal extending the environment with happy_backend_glr_datadir, happy_backend_lalr_datadir, happy_datadir, and happy_tabular_datadir.

I can reliably reproduce the failure as follows

happy_datadir="$(pwd)/./." cabal build happy-frontend

@int-index
Copy link
Collaborator

int-index commented Mar 21, 2024

Could it be a problem in cabal? Here's the version I have on the machine where the problem is reproducible

$ cabal --version
cabal-install version 3.10.2.1
compiled using version 3.10.1.0 of the Cabal library

And here's the version on the machine where I cannot reproduce the problem

$ cabal --version
cabal-install version 3.10.2.1
compiled using version 3.10.2.1 of the Cabal library

You can see that it uses a newer version of the Cabal library. It also does not extend the environment with happy_datadir.

@int-index
Copy link
Collaborator

I can reliably reproduce the failure as follows

No, I take that back. It does reproduce the problem on one machine but not on the other one. I'm lost again.

@sgraf812
Copy link
Collaborator

sgraf812 commented Jun 6, 2024

FWIW, I can reproduce with happy_datadir="$(pwd)/./." cabal build happy-frontend and the following cabal:

$ cabal --version
cabal-install version 3.10.2.1
compiled using version 3.10.2.1 of the Cabal library

So it does not appear to be related to the version of Cabal.

On the machine where you can't reproduce, to you happen to have a cabal.project.local file? I currently use cabal configure -f -bootstrap to work around the problem, which creates said file to disable bootstrapping.

@sgraf812
Copy link
Collaborator

sgraf812 commented Jun 6, 2024

I could come up with a minimal reproducer for what I think is a bug in Cabal; see haskell/cabal#10072.

@sgraf812
Copy link
Collaborator

Given that

  1. it is unlikely that the Cabal bug Do not pass environment variables to happy/alex, or at least allow a way to filter cabal#10072 gets fixed
  2. it would take several years for installed cabal-install binaries to catch up even if that bug gets fixed

I would suggest to simply check in the code of the generated happy parser. It is absolutely rare that we must touch the parser anyway, and it is simple enough to check in the new code anyway. All the dog-fooding arguments still apply and we could reasonably just link .../frontend/.../Bootstrapped.ly into the test folder.

I then wonder what we need the "Oracle" parser for... Would we still need the cabal flag in the first place then?

@int-index
Copy link
Collaborator

int-index commented Jun 13, 2024

I then wonder what we need the "Oracle" parser for...

The initial idea (in #170) was to avoid bootstrapping entirely, thus reducing the complexity of the build, and avoiding check-in of generated code. I still think it's a viable route.

But then we decided to make it into an optional flag (in #175), and we actually ended up with more complexity, not less. And it wouldn't be so bad if we didn't start hitting Cabal limitations (#211, #255, #256, haskell/cabal#7189, and now haskell/cabal#10072). And, as far as I can see, there's no one stepping up to address these limitations.

At this point let's just cut our losses and drop the -bootstrap flag and the "oracle" parser with it. They will remain with us in the git history, and we can bring them back if someone, in a feat of enthusiasm, decides to patch Cabal to cooperate.

@int-index
Copy link
Collaborator

Here we go: #277

@sgraf812
Copy link
Collaborator

Thanks so much, Vlad! Really looking forward to seeing your fix merged.

@sgraf812
Copy link
Collaborator

#277 was a success; I'll close this issue.

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

No branches or pull requests

3 participants