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

cabal sdist does not pick up files with multiple dots #5057

Closed
RyanGlScott opened this issue Jan 20, 2018 · 6 comments
Closed

cabal sdist does not pick up files with multiple dots #5057

RyanGlScott opened this issue Jan 20, 2018 · 6 comments

Comments

@RyanGlScott
Copy link
Member

I've distilled this example into https://github.com/RyanGlScott/cabal-sdist-bug/tree/910078306b4e127996bd7c9208a7e741b9f74351. This has a .cabal file with the following extra-source-files:

extra-source-files: check-hs/*.check.hs

And one can verify that there are indeed several files in that location with a .check.hs extension. But when one attempts to run cabal sdist on that project, cabal becomes confused:

$ cabal sdist
Warning: Cannot run preprocessors. Run 'configure' command first.
Building source dist for cabal-sdist-bug-0.1.0...
cabal: filepath wildcard 'check-hs/*.check.hs' does not match any files.

For some reason, cabal seems to get confused when the wildcard asterisk is used in conjunction with file extensions with multiple dots like .check.hs (at least, that's my current theory). In order to work around this bug, I have to manually enumerate every single .check.hs, like what I currently must do in base-compat.

$ cabal --version
cabal-install version 2.0.0.1
compiled using version 2.0.1.1 of the Cabal library
@hvr
Copy link
Member

hvr commented Jan 20, 2018

I don't know whether this was a deliberate design choice (maybe to discourage overzealous use of globbing? =) ) , but I remember Cabal behaving this way ever since it gained support for globbing... :-)

@RyanGlScott
Copy link
Member Author

...OK? If this is intended behavior, how am I supposed to glob for these sorts of files?

@mitchellwrosen
Copy link

mitchellwrosen commented Jan 20, 2018

Here's the issue:

> parseFileGlob "check-hs/*.check.hs"
Just (FileGlob "check-hs/" ".check.hs")

So we're looking for .check.hs files, so far so good...

> splitExtensions "Control.Monad.Compat.check.hs"
("Control", ".Monad.Compat.check.hs")

Oops, we are looking for files with the .check.hs extension, yet Control.Monad.Compat.check.hs's extension is .Monad.Compat.check.hs.

@mitchellwrosen
Copy link

Here ya go #5061

@hvr
Copy link
Member

hvr commented Jan 21, 2018

Ok, I've investigated a bit, and the current behaviour was in fact a deliberate design choice (which I happen to sympathize with):

quoting 31f2678:

Fix the semantics of the simple file globbing to be sane

I realised when I started to document it that the behaviour
was not terribly consistent or sensible. The meaning now is:

  The limitation is that * wildcards are only allowed in
  place of the file name, not in the directory name or
  file extension. In particular, wildcards do not include
  directories contents recursively. Furthermore, if a
  wildcard is used it must be used with an extension, so
  "data-files: data/*" is not allowed. When matching a
  wildcard plus extension, a file's full extension must
  match exactly, so "*.gz" matches "foo.gz" but not
  "foo.tar.gz".

The reason for providing only a very limited form of wildcard
is to concisely express the common case of a large number of
related files of the same file type without making it too easy
to accidentally include unwanted files.

...and in fact, the same wording can be found in the user's guide at http://cabal.readthedocs.io/en/latest/developing-packages.html#pkg-field-data-files

That being said, I realise that allowing *.tar.gz wildcards would not conflict with that rationale; it's just odd that the documentation didn't suggest a *.tar.gz wildcard for the foo.tar.gz example...

@quasicomputational
Copy link
Contributor

Related bug: #784.

quasicomputational added a commit to quasicomputational/cabal that referenced this issue Jun 10, 2018
This has the effect of allowing a glob `*.html` to match the file
`foo.en.html`. For compatibility, this is only allowed with
`cabal-version: 3.0` or later; for earlier spec versions, a warning
will be generated by `cabal check` if there are files affected by this
change in behaviour.

Fixes haskell#5057. Fixes haskell#784. Closes haskell#5061.
quasicomputational added a commit to quasicomputational/cabal that referenced this issue Jun 11, 2018
This has the effect of allowing a glob `*.html` to match the file
`foo.en.html`. For compatibility, this is only allowed with
`cabal-version: 3.0` or later; for earlier spec versions, a warning
will be generated by `cabal check` if there are files affected by this
change in behaviour.

Fixes haskell#5057. Fixes haskell#784. Closes haskell#5061.
23Skidoo pushed a commit to quasicomputational/cabal that referenced this issue Jun 13, 2018
This has the effect of allowing a glob `*.html` to match the file
`foo.en.html`. For compatibility, this is only allowed with
`cabal-version: 3.0` or later; for earlier spec versions, a warning
will be generated by `cabal check` if there are files affected by this
change in behaviour.

Fixes haskell#5057. Fixes haskell#784. Closes haskell#5061.
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

5 participants