Skip to content

ls dependencies --tree fails when targets are provided #4552

Closed

Description

@dpwiz

General summary/comments (optional)

I've built a stack from the git master and tried to test the thing.

Steps to reproduce

$ stack ls dependencies aeson --tree

Expected

Dependency tree for aeson package.

Actual

Packages
Map.!: given key is not an element in the map
CallStack (from HasCallStack):
  error, called at libraries/containers/Data/Map/Internal.hs:610:17 in containers-0.6.0.1:Data.Map.Internal

Stack version

$ stack --version
Version 1.10.0 (6854 commits) x86_64 hpack-0.31.1

Method of installation

Activity

  1. mattaudesse commented on Feb 3, 2019

    @mattaudesse
    Member

    Thanks for reporting this @wiz

  2. dbaynard commented on Feb 4, 2019

    @dbaynard
    Contributor

    The correct behaviour is not defined anywhere. Having investigated (not on master): without --tree, it only lists dependencies of the target. However, if run outside a project, the command will list nothing — and will error if there's no target.

    @wiz can you please check (and post) the outputs of the following variants?

    1. With and without --tree,
    2. In and not in a project directory (i.e. a directory with a stack.yaml in it, or an ancestor, directory), and
    3. With and without a target.

    (i.e. 8 commands)

    The PRs introducing --tree are #4339, #4413. @akshaymankar can you take a look?

  3. added a commit that references this issue on Feb 4, 2019
    bc8303a
  4. akshaymankar commented on Feb 4, 2019

    @akshaymankar
    Contributor

    The new code for --tree wasn't respecting targets passed to the command, I've fixed that. I should also not have used the unsafe Map.!, I will refactor that and PR soon.

    There still remains a couple of problems which I discovered while experimenting:

    1. ls dependencies doesn't fail or produce any output when called with a target while running outside a project.
    2. ls dependencies doesn't fail or produce any output when called with target in a project, but the target doesn't exist in packages in stack.yaml, even if it is a dependency of the project.

    --tree flag causes error in both of above scenarios because of Map.!, which hopefully would not be an issue after I deal with it.

    We should probably define behaviour in these situations and implement that, if not at least stack should produce an error.

  5. added a commit that references this issue on Feb 4, 2019
    c8025b3
  6. dbaynard commented on Feb 5, 2019

    @dbaynard
    Contributor

    We should probably define behaviour in these situations

    I'd like to hear @wiz's thoughts.

    For me: If we call stack build TARGET outside of a project, stack builds the targets. So I'd argue stack ls dependencies TARGET ought to display the dependencies of the target… but as it would be good for ls dependencies not to need network access, I would rather see it fail (gracefully) if this is not possible.

    @borsboom is probably the person to ask, here.

  7. added 2 commits that reference this issue on Feb 5, 2019
    e689487
    c292e8f
  8. dpwiz commented on Feb 7, 2019

    @dpwiz
    ContributorAuthor

    @dbaynard Sorry for the delay. I collected the outputs you've mentioned: https://gist.github.com/wiz/94a9613005c4835416dbaf0aaf87ed67

  9. dpwiz commented on Feb 7, 2019

    @dpwiz
    ContributorAuthor

    On a related note, --tree ignores the --prune option.

  10. dpwiz commented on Feb 7, 2019

    @dpwiz
    ContributorAuthor

    It appears I tried to use ls dependencies for something it wasn't designed for - exploring dependencies of targets, not the stack project as a whole 🤔

  11. dbaynard commented on Feb 7, 2019

    @dbaynard
    Contributor

    Thanks, @wiz. That's helpful (I like how you found some more bugs in the process).

    stack ls dependencies aeson --tree

    So you ran this from the stack source directory?

    On a related note, --tree ignores the --prune option.

    We should fix that, too.

    It appears I tried to use ls dependencies for something it wasn't designed for - exploring dependencies of targets, not the stack project as a whole 🤔

    To be fair, it should be clear in the documentation. Thanks for pointing this out.

  12. dpwiz commented on Feb 7, 2019

    @dpwiz
    ContributorAuthor

    So you ran this from the stack source directory?

    Yep, in a project directory. stack new, cd, add aeson dependency, run ls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions