haskell / haskell/cabal

"Make targetDir relative to current directory" often doesn't work

Open
#9,776 0 comments 2 reactions 0 assignees View on GitHub
needs triage type: bug
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

In #7581, a call to `makeRelativeToCurrentDirectory` was added in an attempt to shorten command lines. However, in practice, [this call](https://github.com/haskell/cabal/blob/3c06125115c2a86324e9f72f615f381278bb107b/Cabal/src/Distribution/Simple/GHC/Build.hs#L100) to `makeRelative` will fail to make the path relative. For example, with a directory structure like

```
cabal.project
p/p.cabal
```

when building `p` the arguments will look like:

```
buildTargetDir_absolute = /long/working/directory/build/dist-newstyle/more/stuff/
currentWorkingDirectory = /long/working/directory/p/
```

Note the `/p/` at the end of the current working directory, which means that we fail to make the build target directory relative to the current working directory.

The tests `keep-going`, `regression/3324` and `local-tarball` in the `integration-tests2` testsuite all fail if one adds an error after that invocation of `makeRelativeToCurrentDirectory` when it doesn't make the path relative.

Contributor guide

Open the contributing guide

Research direction

Start in Cabal/src/Distribution/Simple/GHC/Build.hs at the makeRelativeToCurrentDirectory call, using the p/p.cabal layout and paths from the report to reproduce the failure. Then run the integration-tests2 tests keep-going, regression/3324, and local-tarball; done means the target directory is made relative when expected and these tests no longer expose the failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
build-system, testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.