haskell / haskell/cabal

Unexpected behaviour with file://host/path repository URLs

Open
#7,937 5 comments 0 reactions 0 assignees View on GitHub
attention: pr-welcome re: config-file type: bug
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

**Describe the bug**
If you configure a repo with a URL of the form `file://foo/bar` (as opposed to the intended `file:///foo/bar`), `foo` is silently stripped.

EDIT: It turns out that an RFC-conformant `file:` URI is of the form `file://host/path`, with `host` defaulting to `localhost`, meaning `/path` is accessible on that host. So if this is a bug, it's that `cabal` doesn't complain that it can't handle a non-default host...

**To Reproduce**
Steps to reproduce the behavior:

```
$ cat cabal.config
repository test-local-repo
url: file://dir/cabal-repo
$ cabal --config-file=cabal.config v2-update
Downloading the latest package list from test-local-repo
/cabal-repo/00-index.tar.gz: copyFile: does not exist (No such file or directory)
```

**Expected behavior**
I expect an error for the missing leading slash (or perhaps to look for the repo in `/dir/cabal-repo`)

**System information**
- Operating system: macos
- `cabal` 3.6.2.0

Contributor guide

Open the contributing guide

Research direction

Reproduce the behavior using cabal.config with `repository test-local-repo` and `url: file://dir/cabal-repo`, then run `cabal --config-file=cabal.config v2-update`. Trace how `cabal` parses file repository URLs and verify that a non-default host is rejected clearly instead of silently stripping `dir` or accessing the wrong path.

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
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.