# Danger of deleting .julia?

**URL:** <https://discourse.julialang.org/t/danger-of-deleting-julia/93372>\
**Category:** General Usage\
**Created:** [January 22, 2023, 8:19pm UTC](https://discourse.julialang.org/t/danger-of-deleting-julia/93372 "2023-01-22T20:19:09Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![jar1](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@jar1](https://discourse.julialang.org/u/jar1)\
**Post date:** [January 22, 2023, 8:19pm UTC](https://discourse.julialang.org/t/danger-of-deleting-julia/93372/1 "2023-01-22T20:19:09Z")

</div>

[From thread](https://discourse.julialang.org/t/julia-1-9-0-beta2-precompilation-taking-almost-twice-as-long/92498/20)

> [@Julia 1.9.0-beta2 precompilation taking almost twice as long](https://discourse.julialang.org/t/julia-1-9-0-beta2-precompilation-taking-almost-twice-as-long/92498/19):
>
> > [@Julia 1.9.0-beta2 precompilation taking almost twice as long](https://discourse.julialang.org/t/julia-1-9-0-beta2-precompilation-taking-almost-twice-as-long/92498/19):
> >
> > Did you delete your .julia folder
> 
> Please refrain from doing such dangerous suggestions again.

What is the danger of deleting .julia?

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [January 22, 2023, 8:25pm UTC](https://discourse.julialang.org/t/danger-of-deleting-julia/93372/2 "2023-01-22T20:25:13Z")

</div>

If I don’t store my packages under development there, the danger is zero. And I don’t. I delete the .julia folder all the time.

Edit: As @giordano pointed out it also possible to lose history and the startup file. My startup file is machine generated and I don’t care about the history. But YMMV. Beware.

---

<div class="post-metadata">

**Author:** ![ctkelley](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ctkelley/32/10684_2.png) [@ctkelley](https://discourse.julialang.org/u/ctkelley)\
**Post date:** [January 22, 2023, 8:40pm UTC](https://discourse.julialang.org/t/danger-of-deleting-julia/93372/3 "2023-01-22T20:40:03Z")

</div>

If you delete .julia, save the config and environments directories. That will save you some trouble. It’s rare that things get so bad (at least for me) that I need to delete the whole thing.

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [January 22, 2023, 8:45pm UTC](https://discourse.julialang.org/t/danger-of-deleting-julia/93372/4 "2023-01-22T20:45:58Z")

</div>

I have no config directory there. What could be in this directory?

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [January 22, 2023, 8:52pm UTC](https://discourse.julialang.org/t/danger-of-deleting-julia/93372/5 "2023-01-22T20:52:26Z")

</div>

The main risk is carelessly deleting the `dev/` subdirectory which contains local development not yet pushed to a remote repository. Most of the other stuff is either downloaded or automatically generated, but teaching people to just nuke the entire depot whenever they have problems is just bad.

Deleting the entire depot is basically never a solution for a problem. If the compiled cache is corrupted, just clear that one. If the registry is corrupted, remove and reinstall that one. Piecewisely deleting individual subdirectories which may be involved with the problem you’re facing can help identify the culprit, deleting the entire depot is a nuclear option which serves little purpose besides potentially making people lose their work.

---

<div class="post-metadata">

**Author:** ![ctkelley](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ctkelley/32/10684_2.png) [@ctkelley](https://discourse.julialang.org/u/ctkelley)\
**Post date:** [January 22, 2023, 8:56pm UTC](https://discourse.julialang.org/t/danger-of-deleting-julia/93372/6 "2023-01-22T20:56:03Z")

</div>

Your startup.jl lives there. If you don’t have one, config is not a problem for yo.

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [January 22, 2023, 8:59pm UTC](https://discourse.julialang.org/t/danger-of-deleting-julia/93372/7 "2023-01-22T20:59:42Z")

</div>

> [@PetrKryslUCSD](#):
>
> If I don’t store my packages under development there, the danger is zero.

> [@ufechner7](#):
>
> I have no config directory there.

_You_ might not have, but people in general may have. Suggesting to users to delete `.julia` _without_ a disclaimer is really bad advice. It is like I would suggest something like “did you format your harddrive” because _I_ do nightly remote backups.

Even if you don’t have development packages in the `.julia` folder there are things that you will lose. The people saying there is no danger might not care about those things, but some people will.

Some things you _will_ lose that **can not be recovered automatically** :

- Global package environment
- Development repositorires (default under `.julia/dev`)
- REPL history
- Any `startup.jl` configuration
- Package preferences/configuration
- Packages scratch folders
- Manifest history usage (Pkg won’t be able to garbage collect unused packages, although doesn’t really matter if you go nuclear and delete everything I guess)
- Package snapshots: If you installed a package on a branch, and that branch have been deleted on the remote repository you can not instantiate that manifest again

> [@giordano](#):
>
> Deleting the entire depot is basically never a solution for a problem. If the compiled cache is corrupted, just clear that one. If the registry is corrupted, remove and reinstall that one. Piecewisely deleting individual subdirectories which may be involved with the problem you’re facing can help identify the culprit, deleting the entire depot is a nuclear option which serves little purpose besides potentially making people lose their work.

Exactly. Post Julia 1.0 it is never a good solution.

---

<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:** [January 22, 2023, 9:15pm UTC](https://discourse.julialang.org/t/danger-of-deleting-julia/93372/8 "2023-01-22T21:15:08Z")

</div>

There are some good reasons to consider starting from a fresh Julia depot, mostly for testing or debugging purposes. Before deleting a depot, I would consider the follow alternatives.

1. Setting the environment variable [`JULIA_DEPOT_PATH`](https://docs.julialang.org/en/v1/manual/environment-variables/#JULIA_DEPOT_PATH).
2. Moving the depot to a backup location.

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [January 22, 2023, 11:08pm UTC](https://discourse.julialang.org/t/danger-of-deleting-julia/93372/9 "2023-01-22T23:08:08Z")

</div>

I personally see a lot of value in testing software with a clean slate. Hence I take the step of deleting the depot quite often.

It is true that this may be also accomplished by using the variable pointing to the depot. Renaming the depot (potentially temporarily) is also possible, but personally I would rather not store many gigabytes of data unnecessarily.

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [January 22, 2023, 11:32pm UTC](https://discourse.julialang.org/t/danger-of-deleting-julia/93372/10 "2023-01-22T23:32:24Z")

</div>

> [@PetrKryslUCSD](#):
>
> I personally see a lot of value in testing software with a clean slate.

I occasionally do that as well for testing purposes, but I start Julia with

```julia
JULIA_DEPOT_PATH=$(mktemp -d) julia

```

I still don’t have any good use case for deleting my entire depot.

What I don’t like is people actively suggesting other users to nuke their depot, especially if without explaining all the consequences. Please just don’t do it.

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [January 23, 2023, 1:14am UTC](https://discourse.julialang.org/t/danger-of-deleting-julia/93372/11 "2023-01-23T01:14:20Z")

</div>

> [@giordano](#):
>
> `JULIA_DEPOT_PATH=$(mktemp -d) julia`

This is clever.

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [January 23, 2023, 1:23am UTC](https://discourse.julialang.org/t/danger-of-deleting-julia/93372/12 "2023-01-23T01:23:46Z")

</div>

> [@giordano](#):
>
> What I don’t like is people actively suggesting other users to nuke their depot, especially if without explaining all the consequences. Please just don’t do it.

I believe there is nothing wrong with suggesting to delete .julia, IF the consequences are explained.  
(Which I do.) Fact is: if I kept the .julia for the past two years unchanged, I would be out of disk space at this point.

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [January 23, 2023, 8:59am UTC](https://discourse.julialang.org/t/danger-of-deleting-julia/93372/13 "2023-01-23T08:59:35Z")

</div>

> [@PetrKryslUCSD](#):
>
> Fact is: if I kept the .julia for the past two years unchanged, I would be out of disk space at this point.

> **[GitHub - giordano/PkgCleanup.jl: Cleanup unused Julia environments and artifacts](https://github.com/giordano/PkgCleanup.jl)**
>
> Cleanup unused Julia environments and artifacts

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [January 23, 2023, 3:08pm UTC](https://discourse.julialang.org/t/danger-of-deleting-julia/93372/14 "2023-01-23T15:08:46Z")

</div>

That is great, that does address my need to clean up house from time to time.

---

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [January 23, 2023, 8:37pm UTC](https://discourse.julialang.org/t/danger-of-deleting-julia/93372/15 "2023-01-23T20:37:50Z")

</div>

Similar trick to start up with a temporary project activated:

```julia
julia --project=$(mktemp -d)

```

---

<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:** [January 24, 2023, 12:50am UTC](https://discourse.julialang.org/t/danger-of-deleting-julia/93372/16 "2023-01-24T00:50:29Z")

</div>

I wish this worked on Windows. Could we consider a dedicated command line option for this without depending on `mktemp`?

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [January 24, 2023, 2:07am UTC](https://discourse.julialang.org/t/danger-of-deleting-julia/93372/17 "2023-01-24T02:07:35Z")

</div>

I run the git bash on Windows. Saves me a lot of headaches with the lame cmd.  
The mktemp is of course available in the bash.

---

<div class="post-metadata">

**Author:** ![albheim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/albheim/32/34660_2.png) [@albheim](https://discourse.julialang.org/u/albheim)\
**Post date:** [January 24, 2023, 11:09am UTC](https://discourse.julialang.org/t/danger-of-deleting-julia/93372/18 "2023-01-24T11:09:13Z")

</div>

Given that both global environments and paths have their equivalents between `julia --project=<@glob | some/path>` and `pkg> activate <@glob | some/path>` it would be nice if the `pkg> activate --temp` option also had an equivalent that mapped in the same (similar?) way.

Mapping it the same I guess we would get `julia --project=--temp`, which feels a little strange, and maybe would become annoying with parsing since equals can be omitted, e.g. `julia --project --temp`? Don’t have any good alternative suggestion as of now.

I didn’t know about the `mktemp` command in unix, so that works okay, but for windows, for people who don’t know about `mktemp`, or just to have it consistent, I think it would be nice with having something more equivalent here.

---

<div class="post-metadata">

**Author:** ![BVPs](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bvps/32/2190_2.png) [@BVPs](https://discourse.julialang.org/u/BVPs)\
**Post date:** [January 27, 2023, 6:50pm UTC](https://discourse.julialang.org/t/danger-of-deleting-julia/93372/19 "2023-01-27T18:50:02Z")

</div>

Sometimes, if you delete your `~/.julia` and start with a clean slate, the precompilation times etc. would improve quite a bit. This happened recently on my old MacBook Pro. When I want to delete `~/.julia` folder, I usually rename it to `~/.julia.bak` or something just in case. Then, I often copy the history log `~/.julia.bak/logs/repl_history.jl` and `~/.julia.bak/config/` folder (if you setup `startup.jl` there). Maybe I may check some other files and folders, but then I can safely delete `~/.julia.bak`.

---

<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:** [January 27, 2023, 9:54pm UTC](https://discourse.julialang.org/t/danger-of-deleting-julia/93372/20 "2023-01-27T21:54:42Z")

</div>

If you just want to improve precompilation times in the manner you described, just start a new environment and keep your base environment sparse.

```julia
using Pkg
pkg"activate @mynewproject"

```

The `@` creates a shared project stored in `.julia/environments/`
