haskell / haskell/cabal

`cabal init`: `--package-dir` seems to be ignored

Open
#9,157 5 comments 0 reactions 0 assignees View on GitHub
cabal-install: cmd/init type: bug
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

**Describe the bug**
`cabal init --package-dir some-dir` does not work (does not work = the files do not get written inside `some-dir`).

**To Reproduce**

```
f@mkiii:~/download$ cabal init --package-dir=/tmp/app/ -nm
Warning: this is a debug build of cabal-install with assertions enabled.
[Log] Guessing dependencies...
[Log] Using cabal specification: 3.0
[Warning] unknown license type, you must put a copy in LICENSE yourself.
[Log] Creating fresh file CHANGELOG.md...
[Log] Creating fresh directory ./app...
[Log] Creating fresh file app/Main.hs...
[Log] Creating fresh file app.cabal...
[Warning] No synopsis given. You should edit the .cabal file and add one.
[Info] You may want to edit the .cabal file and add a Description field.

f@mkiii:~/download$ lsc
app app.cabal CHANGELOG.md
f@mkiii:~/download$ ls /tmp/app/
f@mkiii:~/download$
```

**Expected behavior**
After running `cabal init --package-dir=/tmp/app/ -nm`, I want folders, cal files etc. to be written in `/tmp/app`.

**System information**
- Debian bookworm
- cabal 3.11, ghc 9.2.8

**Additional context**

`--help` entry for `--package-dir`

```
--package-dir=DIRECTORY Root directory of the package (default =
current directory).
```

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the reported `cabal init --package-dir=/tmp/app/ -nm` command and inspect the `cabal init` handling of `--package-dir`. Confirm that generated folders and files are currently written in the working directory; done means they are instead written under `/tmp/app`.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.