Skip to content

Subdir field of source-repository-package should accept multiple arguments. #5472

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

Closed
merijn opened this issue Jul 30, 2018 · 11 comments
Closed

Comments

@merijn
Copy link
Collaborator

merijn commented Jul 30, 2018

I'm playing around with the freshly merged source-repository-package (#2189, #5351), after searching the cabal-install source to figure out all the field names, I noticed an annoyance. The implementation of remote dependencies was prescient enough to allow me to specify a subdirectory to look for a cabal file in, but sadly only allows me to list a single subdirectory to look in.

I have several related packages in a single repository, these depend on each other, but some haven't been released yet, so I need to depend on multiple package from the same repo. Unfortunately, I can only specify one subdir to look in for cabal files. I've worked around this by listing the same repo multiple times, but this super ugly:

source-repository-package
  type: git
  location: https://github.com/merijn/broadcast-chan.git
  tag: 996aecdacc2eb8501a1a27c8559153d93ed3d6d2
  subdir: broadcast-chan

source-repository-package
  type: git
  location: https://github.com/merijn/broadcast-chan.git
  tag: 996aecdacc2eb8501a1a27c8559153d93ed3d6d2
  subdir: broadcast-chan-conduit

source-repository-package
  type: git
  location: https://github.com/merijn/broadcast-chan.git
  tag: 996aecdacc2eb8501a1a27c8559153d93ed3d6d2
  subdir: broadcast-chan-tests

Ideally subdir should just take a list of subdirectories so I can instead simply write:

source-repository-package
  type: git
  location: https://github.com/merijn/broadcast-chan.git
  tag: 996aecdacc2eb8501a1a27c8559153d93ed3d6d2
  subdir: broadcast-chan broadcast-chan-conduit broadcast-chan-tests
@hvr
Copy link
Member

hvr commented Jul 30, 2018

I have to cringe at a singular subdir taking multiple args ;-)

other than that, I think that's a reasonable request (and indeed it's been suggested to @dcoutts already iirc)

@typedrat do you think you could look into this one?

@merijn
Copy link
Collaborator Author

merijn commented Jul 30, 2018

@hvr Well, we could just change it to subdirs instead of subdir, since it's not in any officially released version of cabal-install. Alternatively, change it to subdirs and keep subdir as backwards compat alternative.

@hvr
Copy link
Member

hvr commented Jul 30, 2018

@merijn I like the idea to introduce a subdirs fieldname; but isn't the parser for source-repository-package shared with the one for source-repos in the .cabal pkg description? If so, we'd need to make sure that subdirs is only allowed for source-repository-package but not for source-repositorys

Generally, there's likely more fields we'd want to add to source-repository-package but which makes no sense for the source-repository declaration in .cabal files.

@hvr
Copy link
Member

hvr commented Aug 3, 2018

IMPORTANT: Due to #5487 there's a minor added complexity: we'd need to resolve the multiple subdirs to a unique a subdir in the plan.json output for the respective package

@mpickering
Copy link
Collaborator

This would be a good feature.

@erikd
Copy link
Member

erikd commented Mar 3, 2019

Just hit this myself. Is there a workaround?

@dcoutts
Copy link
Contributor

dcoutts commented Mar 4, 2019

@hvr I really think this is just a case of expanding it out at the syntax layer. The underlying mechanisms already have support for subdir and doing only a single download even when there are multiple uses of the same repo (including for git when different uses use different commits/branches).

For @erikd and others: yes the workaround is just list the repo multiple times, once for each subdir. It only gets downloaded once.

@patrickt
Copy link

patrickt commented Jun 3, 2019

Would love this!

@phadej
Copy link
Collaborator

phadej commented Jun 3, 2019

Implementation comment: the SourceRepo type in Cabal the lib should not be changed,
as that would change .cabal file format. That type need to be forked into cabal-install.

@phadej phadej self-assigned this Jul 25, 2019
phadej added a commit that referenced this issue Jul 25, 2019
which can be parametrised over container of subdirs: [], Maybe, Proxy...
@michaelpj
Copy link
Collaborator

This would be nice!

@int-index
Copy link
Collaborator

The lack of this feature has definitely been annoying for me. I have the following lines in my cabal.project:

source-repository-package
  type: git
  location: https://github.com/int-index/slay
  tag: 69b533004637319c2f210dfb17f44acfce3f59d2
  subdir: core

source-repository-package
  type: git
  location: https://github.com/int-index/slay
  tag: 69b533004637319c2f210dfb17f44acfce3f59d2
  subdir: combinators

source-repository-package
  type: git
  location: https://github.com/int-index/slay
  tag: 69b533004637319c2f210dfb17f44acfce3f59d2
  subdir: cairo

And each time the tag: field changes, I have to update it in three places instead of one place.

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

10 participants