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

Force stack to use local packages over Stackage? #2181

Closed
sid-kap opened this issue May 23, 2016 · 13 comments
Closed

Force stack to use local packages over Stackage? #2181

sid-kap opened this issue May 23, 2016 · 13 comments
Milestone

Comments

@sid-kap
Copy link
Contributor

sid-kap commented May 23, 2016

I'm trying to build a package using, as a dependency, the current version of a project in the dependency's Github repo. I've added that repo's Git location and commit ID to the packages section of my stack.yaml.

The problem is that I think that Stack might be selecting the version in the Stackage lts snapshot instead of the version that I specified in stack.yaml. (I'm not sure. Is there a way to check?)

If this is indeed happening, I think it might be happening because the dependency's version number on Stackage is higher than the version number in the git repo (even though the version in the git repo is actually newer, and is the one I want to build against). (To be concrete, the dependency has version 1.3.1.2 on Stackage, but the cabal file of the version in the repo says version 1.3.)

So, in summary:

  1. Is there a way for me to check which versions of the dependencies Stack is building against (and where it's getting the dependencies from)?
  2. How exactly does Stack choose how to satisfy its dependencies? Does the extra-dep flag change this behavior?
  3. If it is the case that Stack is choosing the lts version over the Git version that I specified, then is there a way for me to tell Stack which version to use?
@harendra-kumar
Copy link
Collaborator

  • Use list-dependencies command to list all the dependencies
  • Yes the extra-dep package flag will make this package satisfy the dependencies in your project instead of using a snapshot version. It is just like as if you specified it in the extra-deps section. See the documentation for more details on the flag syntax and behavior - http://docs.haskellstack.org/en/stable/yaml_configuration/.

@mgsloan
Copy link
Contributor

mgsloan commented May 23, 2016

stack exec -- ghc-pkg describe pkg is also useful to find out what versions something was built with.

@mgsloan mgsloan added this to the Support milestone May 23, 2016
@sid-kap
Copy link
Contributor Author

sid-kap commented May 23, 2016

stack exec -- ghc-pkg describe pkg shows me both versions (the Git version and the Stackage version). Is there a way to find out which one my package was built against?

@sid-kap
Copy link
Contributor Author

sid-kap commented May 23, 2016

I think I found the answer to my last question: Each version in the output of stack exec -- ghc-pkg describe dependency-name has a unique hash, and so if I do stack exec -- ghc-pkg describe my-package I see the hash of the one that is used.

@sid-kap
Copy link
Contributor Author

sid-kap commented May 23, 2016

Before I close this, I still would like to know the answers to my questions 2 and 3 above. I will play around with this for a few minutes and report my observations.

@sid-kap
Copy link
Contributor Author

sid-kap commented May 23, 2016

Okay, it seems like Stack is doing what I wanted it to do, so there was actually no problem here. It was building against the local/Git version that I specified, rather than the Stackage version.

It would be nice to document this behavior. Is there a formal spec somewhere where we say how Stack chooses dependencies? If not, can we start one?

@mgsloan
Copy link
Contributor

mgsloan commented May 23, 2016

Not really a formal spec, but: http://docs.haskellstack.org/en/stable/architecture/ and http://docs.haskellstack.org/en/stable/GUIDE/ . Do those not address this point?

I would prefer to hold off on writing down anything too elaborate until #1265 is implemented. Not that the semantics will change too drastically, but if it mentions details of implementation, that may change.

@mgsloan mgsloan closed this as completed May 23, 2016
@sid-kap
Copy link
Contributor Author

sid-kap commented May 23, 2016

As far as I can tell, GUIDE doesn't have any relevant information on this. The "Shadowing" section of the architecture page (http://docs.haskellstack.org/en/stable/architecture/#shadowing), however, explains exactly what I wanted to know.

I think we should put something about this in the Yaml Configuration page, under the "Project config" subheader. In particular, under the "packages", "complex package locations", "Local dependency packages", and "extra-deps" sections, I would like to add something like:

Note: If you specify a package here, it shadows any package of the same name from the snapshot resolver. See the Shadowing section of the architecture page for more details.

Alternatively, we could just add one note under the "resolver" heading (also under "Yaml Configuration/Project config"), like:

Note: Any packages specified under packages or extra-deps "shadows" all packages of the same name from the resolver. See the Shadowing section of the architecture page for more details.

I believe this information belongs in Yaml configuration page (or at least some other prominent location, like the GUIDE) because it is part of the semantics of the Yaml file. In the section that explains what to put yaml file, I believe we ought to specify how those configurations are interpreted by Stack (the semantics).

@sid-kap
Copy link
Contributor Author

sid-kap commented May 23, 2016

Do either of the changes I suggested sound reasonable? If so, I can submit a PR with these changes to the documentation.

@harendra-kumar
Copy link
Collaborator

Sounds good to me. It will explicitly state the behavior which I found missing when I checked it after you asked this question. We can add a note in "Local Dependency packages" because it talks about the extra-dep package flag. We can also add the note in the resolver section as you suggested.

@mgsloan
Copy link
Contributor

mgsloan commented May 23, 2016

Sounds good to me too, thanks!

@sid-kap
Copy link
Contributor Author

sid-kap commented May 23, 2016

@harendra-kumar Why only in the "Local Dependency packages", and not in the "packages", "complex package locations", and "extra-deps" sections? The situation is the same in all four cases. I think we should either mention this in all four sections, or in none of them.

Ideally, we should find one place to keep it, instead of repeating ourselves 5 times.

@sid-kap
Copy link
Contributor Author

sid-kap commented May 24, 2016

I'm going to draft a short paragraph to place directly under "Package config". We can discuss this once I open the PR.

Thanks @harendra-kumar and @mgsloan for all your help!

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

No branches or pull requests

3 participants