dart-lang / dart-lang/pub

`pub get` should more gracefully handle non-git dirs in the git pub cache

Open
#2,129 1 comment 2 reactions 0 assignees View on GitHub
type-enhancement
Dominant language
Dart
Stars
1.1k
Forks
242
Avg merge
4d 21h
Merged PRs (30d)
15

Description

I ran into an issue today where I couldn't run a `pub get` (or upgrade) in any flutter_web project (even fresh ones).

The error I was getting was this:

```
fatal: not a git repository (or any parent up to mount point /usr/local)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
```

This was quite cryptic, and didn't indicate even _which_ package dependency had failed. I later ran with `-v` and got some better information, it was trying to run a `git fetch` inside of the pub cache (specifically, at `~/.pub-cache/git/cache/flutter_web-c860685d0da1a4da933bd4d77e11442441614877`), which was a completely empty directory.

I am not sure exactly how an empty directory got added there, presumably a previous `git clone` or something had failed.

Deleting the directory solved my problems, but it was difficult to resolve.

I think it would be reasonable to handle this scenario explicitly, by handling the `not a git repository` error and deleting the entire directory from the pub cache and retrying.

Contributor guide

Open the contributing guide

Research direction

Start by tracing the `pub get` and upgrade code that runs `git fetch` in `~/.pub-cache/git/cache/flutter_web-c860685d0da1a4da933bd4d77e11442441614877`; reproduce the failure with an empty directory there. Done means the cache entry is handled explicitly, the failing package is identified, and retrying succeeds without exposing the cryptic Git error.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.