haskell / haskell/cabal

source-repository package git clone: fatal: '--detach' cannot be used with '-b/-B/--orphan'

Open
#8,235 0 comments 0 reactions 0 assignees View on GitHub
cabal-install: source-repository-package type: bug
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

**Describe the bug**
I ran into the following error while working with a forked local dependency:

1. add a `source-repository-package` entry to `cabal.project.local`, pointing to a valid local repository but non-existent tag:
```
source-repository-package
location: /s/bytestring-strict-builder
type: git
tag: unsafe
```
2. `cabal build` errors out as it should:
```
$ cabal build
Cloning into '[...]/dist-newstyle/src/bytestrin_-75233e9c287669b1'...
done.
fatal: invalid reference: unsafe
```
3. I create the branch in the forked repo
4. `cabal build` fails with an unexpected git error:
```
$ cabal build
[... regular git copying output]
From /s/bytestring-strict-builder
* [new branch] unsafe -> origin/unsafe
fatal: '--detach' cannot be used with '-b/-B/--orphan'
```

After this, running `cabal build` again reports the same error. After wiping `dist-newstyle/src/bytestr*`, the build works fine.

**To Reproduce**

I've run the above steps again and arrived at the same result. I have not yet made sure it happens with arbitrary repositories instead of the specific ones I encountered this with, though I expect it to be a general issue.

**Expected behavior**
In step 4, `cabal build` should manage to check out the correct branch.

**System information**
- Operating system: macOS 12.4
- `cabal` 3.6.2.0 via ghcup, `git` in PATH is `git version 2.32.1 (Apple Git-133)` (but I'm not entirely sure this is what `cabal` calls)

**Additional context**
This is related to #6888. However, that ticket is specific to the redundant `branch` setting, while this one appears to be a bug with `tag` which I understand to be the "standard" way to specify a revision.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.