Skip to content

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

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
leonschoorl opened this issue Nov 6, 2019 · 3 comments
Closed

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

leonschoorl opened this issue Nov 6, 2019 · 3 comments

Comments

@leonschoorl
Copy link
Contributor

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
@phadej
Copy link
Collaborator

phadej commented Nov 6, 2019

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.

@phadej
Copy link
Collaborator

phadej commented Nov 13, 2019

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.

@phadej
Copy link
Collaborator

phadej commented Nov 15, 2019

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

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

2 participants