Skip to content

cabal build interprets Extra-source-files relative to CWD #6334

Closed

Description

@leonschoorl

Describe the bug
When using a cabal.project file cabal build seems to interpret "Extra-source-files" relative to the current working directory.
This has changed in cabal-install-head-3.1+git20191103.2.129775a-6~18.04 (from hvr's ppa).
cabal-install-3.0 did not have this problem.

To Reproduce
Here is a minimal setup:
/tmp/test-cabal/cabal.project:

packages:
  ./somepackage

/tmp/test-cabal/somepackage/somepackage.cabal:

Cabal-version:        2.2
Name:                 somepackage
Version:              0.1

Extra-source-files:   README.md

Library
  Build-depends:      base
  Default-language:   Haskell2010

/tmp/test-cabal/somepackage/README.md:

Readme ...

Building somepackage from the toplevel dir fails because it can't find the README.md:

$ cd /tmp/test-cabal
$ cabal-head v2-build somepackage
Resolving dependencies...
Build profile: -w ghc-8.8.1 -O1
In order, the following will be built (use -v for more details):
 - somepackage-0.1 (lib) (configuration changed)
Configuring library for somepackage-0.1..
Preprocessing library for somepackage-0.1..
Building library for somepackage-0.1..
cabal-head: filepath wildcard 'README.md' does not match any files.

But if I go into somepackage (where it's located)

$ cd /tmp/test-cabal/somepackage
$ cabal-head v2-build somepackage
Build profile: -w ghc-8.8.1 -O1
In order, the following will be built (use -v for more details):
 - somepackage-0.1 (lib) (first run)
Preprocessing library for somepackage-0.1..
Building library for somepackage-0.1..
$

Expected behavior
I expect locations in a .cabal file would be interpreted relative to the location of that .cabal file.

Additional context
Interestingly cabal sdist works fine:

$ cd /tmp/cabal-test
$ cabal-head v2-sdist somepackage
Wrote tarball sdist to
/tmp/test-cabal/dist-newstyle/sdist/somepackage-0.1.tar.gz
$ tar taf dist-newstyle/sdist/somepackage-0.1.tar.gz
somepackage-0.1/
somepackage-0.1/README.md
somepackage-0.1/somepackage.cabal

Activity

  1. phadej commented on Nov 6, 2019

    @phadej
    Collaborator

    my 5cents: Cabal (starting from cabal-install?) should move from

    • using FilePath (in favour of something like Path Absolute & Path Unrooted distinction as in hackage-security)
    • never change its own CWD, but rather be specific in which cwd the subprocesses are spawned.
  2. phadej commented on Nov 13, 2019

    @phadej
    Collaborator

    This is reproducible with current cabal-install-head in HVR PPA 3.1+git20191103.2.129775a-6~18.04. (e.g. on cabal own codebase)

    I'll bisect which commit causes this, if it's easy to fix, I'll try that, otherwise hopefully revert would help.

  3. phadej commented on Nov 15, 2019

    @phadej
    Collaborator

    My git-bisect says this is caused by 3b54835 by @quasicomputational

  4. added a commit that references this issue on Nov 15, 2019
    4af7179
  5. added a commit that references this issue on Nov 15, 2019
    a61012c
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