# Doesn't Julia automatically delete the source code of a package?

**URL:** <https://discourse.julialang.org/t/doesnt-julia-automatically-delete-the-source-code-of-a-package/99152>\
**Category:** New to Julia\
**Tags:** package\
**Created:** [May 20, 2023, 8:43am UTC](https://discourse.julialang.org/t/doesnt-julia-automatically-delete-the-source-code-of-a-package/99152 "2023-05-20T08:43:07Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![WuSiren](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wusiren/32/42529_2.png) [@WuSiren](https://discourse.julialang.org/u/WuSiren)\
**Post date:** [May 20, 2023, 8:43am UTC](https://discourse.julialang.org/t/doesnt-julia-automatically-delete-the-source-code-of-a-package/99152/1 "2023-05-20T08:43:08Z")

</div>

Why can I still find the source code of a package named `xxx` in the directory `C:\Users\name\.julia\packages` after running `rm xxx` to delete the package in Julia’s package management mode? Doesn’t Julia automatically delete it? Also, why are the source codes of the old version still retained after running `update xxx` to upgrade a package?

---

<div class="post-metadata">

**Author:** ![dawbarton](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dawbarton/32/215461_2.png) [@dawbarton](https://discourse.julialang.org/u/dawbarton)\
**Post date:** [May 20, 2023, 9:08am UTC](https://discourse.julialang.org/t/doesnt-julia-automatically-delete-the-source-code-of-a-package/99152/2 "2023-05-20T09:08:26Z")

</div>

There might be multiple environments or projects using the same package source, so removing it from one environment doesn’t mean that it’s unused. You can use the `gc` command to garbage collect (delete) any completely unused packages.

---

<div class="post-metadata">

**Author:** ![dawbarton](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dawbarton/32/215461_2.png) [@dawbarton](https://discourse.julialang.org/u/dawbarton)\
**Post date:** [May 20, 2023, 9:09am UTC](https://discourse.julialang.org/t/doesnt-julia-automatically-delete-the-source-code-of-a-package/99152/3 "2023-05-20T09:09:28Z")

</div>

Julia will automatically run `gc` on a periodic basis but I can’t remember how often that is.

---

<div class="post-metadata">

**Author:** ![WuSiren](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wusiren/32/42529_2.png) [@WuSiren](https://discourse.julialang.org/u/WuSiren)\
**Post date:** [May 20, 2023, 9:12am UTC](https://discourse.julialang.org/t/doesnt-julia-automatically-delete-the-source-code-of-a-package/99152/4 "2023-05-20T09:12:53Z")

</div>

I see. Thank you!

---

<div class="post-metadata">

**Author:** ![WuSiren](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wusiren/32/42529_2.png) [@WuSiren](https://discourse.julialang.org/u/WuSiren)\
**Post date:** [May 20, 2023, 9:28am UTC](https://discourse.julialang.org/t/doesnt-julia-automatically-delete-the-source-code-of-a-package/99152/5 "2023-05-20T09:28:32Z")

</div>

By the way, does each version of Julia (installer or portable version) always place package source files under the directory `C:\Users\name\.julia\packages`?

What I meant to say was, why doesn’t the portable version place the package source files in its own root directory to facilitate cross-platform use?

 ![image](https://global.discourse-cdn.com/julialang/original/3X/e/5/e5343c885b20458125d3128a002d4bd8019ae07b.png)

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [May 20, 2023, 9:34am UTC](https://discourse.julialang.org/t/doesnt-julia-automatically-delete-the-source-code-of-a-package/99152/6 "2023-05-20T09:34:47Z")

</div>

You can change where Julia places files via the environment variable `JULIA_DEPOT_PATH` or the variable `DEPOT_PATH` within Julia.

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [May 20, 2023, 10:10am UTC](https://discourse.julialang.org/t/doesnt-julia-automatically-delete-the-source-code-of-a-package/99152/7 "2023-05-20T10:10:02Z")

</div>

I don’t use environments and also see multiple versions of a packages and that are not removed with `rm` nor by `gc`. And if we are using master versions of a package the number of sources is even larger.

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [May 20, 2023, 11:19am UTC](https://discourse.julialang.org/t/doesnt-julia-automatically-delete-the-source-code-of-a-package/99152/8 "2023-05-20T11:19:14Z")

</div>

The three stages of cleanup are

1. `gc`
2. `gc --all`
3. [GitHub - giordano/PkgCleanup.jl: Cleanup unused Julia environments and artifacts](https://github.com/giordano/PkgCleanup.jl)

---

<div class="post-metadata">

**Author:** ![dawbarton](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dawbarton/32/215461_2.png) [@dawbarton](https://discourse.julialang.org/u/dawbarton)\
**Post date:** [May 20, 2023, 1:09pm UTC](https://discourse.julialang.org/t/doesnt-julia-automatically-delete-the-source-code-of-a-package/99152/9 "2023-05-20T13:09:25Z")

</div>

I’ve no idea about the portable version, but you can control where packages are stored using the [`JULIA_DEPOT_PATH`](https://docs.julialang.org/en/v1/manual/environment-variables/#JULIA_DEPOT_PATH) environment variable.
