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

Depending on a modified Happy or Alex package requires non-trivial patching #2767

Open
da-x opened this issue Nov 8, 2016 · 2 comments
Open
Milestone

Comments

@da-x
Copy link
Contributor

da-x commented Nov 8, 2016

Today even with Stack 1.2.0, it is not possible to depend on modified tools such as Alex and Happy - without patching them, and referring to them in a rather odd way that I'd explain shortly

The use case I am trying to deal with depending on an unreleased version of Happy.

We'll start by having the following in the stack.yaml of the project in which we add the dependency:

packages:
- location: https://github.com/simonmar/happy/archive/4aff81fc89a74fd57e3494d026e569e247919d99.zip
  extra-dep: true
- .

However, even though Stack builds the new version of Happy, it does not make use of it when generating the parser code. Instead the older version of Happy is used and we get an error. See example in branch explist-broken in my project happy-alex-example.

NOTE: doing git clean -x -d -f when moving between the branches mentioned here is crucial to see the problem reproduces.

Now, it seems that if I do this patch to Happy, adding an empty Haskell library and also make adjustments so that happy is added to build-depends - it seems to work. See the other branch explist in my project happy-alex-example.

I sense that this workaround is not the optimal solution to this problem, therefore I opened this issue.

@mgsloan
Copy link
Contributor

mgsloan commented Nov 11, 2016

Looks like when happy is installed locally, it is indeed properly used with the build. So all that seems to be required is stack build happy before running stack build.

Given that having a library dep solves the issue, the issue is that we don't know that we need to build a new happy when it's overridden. Conceptually, this is related to #595

@mgsloan mgsloan added this to the P2: Should milestone Nov 11, 2016
@da-x
Copy link
Contributor Author

da-x commented Nov 17, 2016

it seems that in order for my solution to work, stack build happy --resolver=... needs to happen outside of the project, and its resolver need to match the one of the stack.yaml of the project. I.e., we need to have the unmodified happy executable of the same snapshot installed before everything else.

These are the steps for a working build (explist branch):

  1. Build Happy outside project: cd / && stack build happy --resolver=<to match project's>
  2. Build the project: cd ~/project && stack build

(For reproducability I'd throw in "Ensure no happy in $PATH (i.e. clean environment), and in the Stack root" as step (0).)

Also, if I were unfortunate enough to perform stack build happy inside the project before building the unpatched version outside it (i.e. cd ~/project && stack build happy as first step), then I wind up with an inoperable .stack-work, and must erase it for stack build to work further on, even after the (1) is done unrelated (the error is setup: The program 'happy' is required but it could not be found, but I can send more details).

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

2 participants