# Dvc gc command doesn't work

**URL:** <https://discuss.dvc.org/t/dvc-gc-command-doesnt-work/1920>\
**Category:** Questions\
**Created:** [January 10, 2024, 12:43pm UTC](https://discuss.dvc.org/t/dvc-gc-command-doesnt-work/1920 "2024-01-10T12:43:11Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![loveis](https://avatars.discourse-cdn.com/v4/letter/l/dec6dc/32.png) [@loveis](https://discuss.dvc.org/u/loveis)\
**Post date:** [January 10, 2024, 12:43pm UTC](https://discuss.dvc.org/t/dvc-gc-command-doesnt-work/1920/1 "2024-01-10T12:43:11Z")

</div>

I accidentally deleted the cache folder in my project. And then I tested `dvc gc` after a series of experiments and runs of `dvc repro`. The error that appeared was something like this - `no unused local cache`. And accordingly, `dvc gc -w` did not delete anything. How can I fix it?

---

<div class="post-metadata">

**Author:** ![pmrowla](https://avatars.discourse-cdn.com/v4/letter/p/7ab992/32.png) [@pmrowla](https://discuss.dvc.org/u/pmrowla)\
**Post date:** [January 12, 2024, 10:43am UTC](https://discuss.dvc.org/t/dvc-gc-command-doesnt-work/1920/2 "2024-01-12T10:43:35Z")

</div>

`dvc gc -w` removes files from your cache directory that are not referenced in your current workspace. If you have already deleted the entire cache folder, `dvc gc` will not do anything.

Can you please clarify what you are expecting to be deleted when you run `dvc gc`?

---

<div class="post-metadata">

**Author:** ![alan\_s](https://avatars.discourse-cdn.com/v4/letter/a/41988e/32.png) [@alan\_s](https://discuss.dvc.org/u/alan_s)\
**Post date:** [January 15, 2024, 1:35pm UTC](https://discuss.dvc.org/t/dvc-gc-command-doesnt-work/1920/3 "2024-01-15T13:35:35Z")

</div>

Hi, let me add some details to my colleague’s question. I ran several repros and exps commands in my repo but when I try to clear cache of exps nothing changes and I get message:

No unused ‘local’ cache to remove.  
No unused ‘legacy’ cache to remove.

Here is the final output:

 ![изображение_2024-01-15_161852741](https://canada1.discourse-cdn.com/flex035/uploads/dataversioncontrol/original/1X/e4dfc0e68cc927478e480b078654a08393c9ff51.png)  
I am allowed to add only one media, but i descrived all steps [here](https://teletype.in/@python_analysis/Fr33a592qfe)

Please help us to understand the behavior of dvc gc. My dvc version is DVC version: 3.2.1.

---

<div class="post-metadata">

**Author:** ![pmrowla](https://avatars.discourse-cdn.com/v4/letter/p/7ab992/32.png) [@pmrowla](https://discuss.dvc.org/u/pmrowla)\
**Post date:** [January 24, 2024, 5:26am UTC](https://discuss.dvc.org/t/dvc-gc-command-doesnt-work/1920/4 "2024-01-24T05:26:03Z")

</div>

Please update to the latest DVC release (3.41.0) and then retry using `dvc gc`

---

<div class="post-metadata">

**Author:** ![alan\_s](https://avatars.discourse-cdn.com/v4/letter/a/41988e/32.png) [@alan\_s](https://discuss.dvc.org/u/alan_s)\
**Post date:** [January 26, 2024, 12:46pm UTC](https://discuss.dvc.org/t/dvc-gc-command-doesnt-work/1920/5 "2024-01-26T12:46:20Z")

</div>

Thanks, your advice helped me. But could you give me deeper explanation of the results, please? After I ran dvc gc -A, system reported about 3 removed objects.

But nothing was deleted from .dvc/cache/runs (where I expected), and at the same time in other directory - .dvc/cache/files/md5 3 folders were cleaned.

1. Now I guess that real results of dvc outputs for exps and repros are cached in .dvc/cache/files/md5. Is my suggestion right? Than what does .dvc/cache/runs store?

2. I saved repo before running dvc gc -A and understood that only versions of last repros or exp runs before git commiting were saved. For my repro:  

3. Is there a way to run dvc exp without storing results in cache like dvc repro with --no-commit option?

---

<div class="post-metadata">

**Author:** ![pmrowla](https://avatars.discourse-cdn.com/v4/letter/p/7ab992/32.png) [@pmrowla](https://discuss.dvc.org/u/pmrowla)\
**Post date:** [January 28, 2024, 1:30am UTC](https://discuss.dvc.org/t/dvc-gc-command-doesnt-work/1920/6 "2024-01-28T01:30:02Z")

</div>

> Than what does .dvc/cache/runs store?

`dvc gc` does not affect `.dvc/cache/runs`. That directory is used for storing DVC run cache. Run cache is how DVC identifies whether or not a stage needs to be re-run or has not changed, none of the actual output data for `dvc repro` or `dvc exp run` is stored in the run cache.

> **[Run Cache](https://dvc.org/doc/user-guide/pipelines/run-cache#run-cache-automatic-log-of-stage-runs)**
>
> Open-source version control system for Data Science and Machine Learning projects. Git-like experience to organize your data, models, and experiments.

> Am I rigth thinking that git commit references results of last dvc exp run or dvc repro, because both save results to dvc cache?

I’m not sure I understand your question. What do you mean by “saved your repo”? If you use `dvc gc -A`, any DVC files which are referenced by Git commits in your repo will be preserved.

With `-A`, DVC will go through your Git history, and check each commit for any `.dvc` or `dvc.lock` files. Any DVC tracked data used by those `.dvc`/`dvc.lock` files will be preserved, and `dvc gc` will remove unused data from the DVC cache.

> Is there a way to run dvc exp without storing results in cache like dvc repro with --no-commit option?

No, if you need this behavior you can just use `dvc repro`. `dvc exp run` needs to store the results of your experiment somewhere, and this is done by storing any DVC tracked results in the DVC cache.

---

<div class="post-metadata">

**Author:** ![alan\_s](https://avatars.discourse-cdn.com/v4/letter/a/41988e/32.png) [@alan\_s](https://discuss.dvc.org/u/alan_s)\
**Post date:** [February 25, 2024, 7:14am UTC](https://discuss.dvc.org/t/dvc-gc-command-doesnt-work/1920/7 "2024-02-25T07:14:05Z")

</div>

Thank you, very much!
