# Adding package to new environment takes long time?

**URL:** <https://discourse.julialang.org/t/adding-package-to-new-environment-takes-long-time/119518>\
**Category:** General Usage\
**Created:** [September 17, 2024, 7:48pm UTC](https://discourse.julialang.org/t/adding-package-to-new-environment-takes-long-time/119518 "2024-09-17T19:48:48Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![p\_f](https://avatars.discourse-cdn.com/v4/letter/p/45deac/32.png) [@p\_f](https://discourse.julialang.org/u/p_f)\
**Post date:** [September 17, 2024, 7:48pm UTC](https://discourse.julialang.org/t/adding-package-to-new-environment-takes-long-time/119518/1 "2024-09-17T19:48:48Z")

</div>

I have already installed DifferentialEquations.jl in many different environments.

I just created a new environment and did `]add DifferentialEquations`

This took \> 5 mins, and then precompilation happened for another maybe 5 mins.

The same thing is now happening with GLMakie. Should it take up to 20 minutes just to create and use a new environment with packages that are already installed somewhere? Do new environments not reuse existing installations of packages?

---

<div class="post-metadata">

**Author:** ![dqeeq](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@dqeeq](https://discourse.julialang.org/u/dqeeq)\
**Post date:** [September 17, 2024, 9:14pm UTC](https://discourse.julialang.org/t/adding-package-to-new-environment-takes-long-time/119518/2 "2024-09-17T21:14:59Z")

</div>

> Should it take up to 20 minutes just to create and use a new environment with packages that are already installed somewhere?

No

> Do new environments not reuse existing installations of packages?

No

Can you confirm that you have `~/.julia/packages/DifferentialEquations`?

---

<div class="post-metadata">

**Author:** ![p\_f](https://avatars.discourse-cdn.com/v4/letter/p/45deac/32.png) [@p\_f](https://discourse.julialang.org/u/p_f)\
**Post date:** [September 17, 2024, 9:29pm UTC](https://discourse.julialang.org/t/adding-package-to-new-environment-takes-long-time/119518/3 "2024-09-17T21:29:26Z")

</div>

> [@dqeeq](#):
>
> Can you confirm that you have `~/.julia/packages/DifferentialEquations`?

Confirmed

`.julia/packages/DifferentialEquations` contains two folders:  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/6/8/6859403f78ea3d92b797b846c50f89de1b8660c8.png)  
so some form of the package has been installed since March 10th.

---

<div class="post-metadata">

**Author:** ![dqeeq](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@dqeeq](https://discourse.julialang.org/u/dqeeq)\
**Post date:** [September 17, 2024, 9:39pm UTC](https://discourse.julialang.org/t/adding-package-to-new-environment-takes-long-time/119518/4 "2024-09-17T21:39:40Z")

</div>

What happens if you now install [DifferentialEquations.jl](https://juliahub.com/ui/Packages/General/DifferentialEquations) in a third environment?  
I guess you are using two versions of the same package.

---

<div class="post-metadata">

**Author:** ![p\_f](https://avatars.discourse-cdn.com/v4/letter/p/45deac/32.png) [@p\_f](https://discourse.julialang.org/u/p_f)\
**Post date:** [September 17, 2024, 9:49pm UTC](https://discourse.julialang.org/t/adding-package-to-new-environment-takes-long-time/119518/5 "2024-09-17T21:49:00Z")

</div>

It is now much quicker, so it is reusing what was installed earlier.

I assume the solution is to just run `]up` more frequently. I just don’t use an environment with `DifferentialEquations` in very often. When installing packages in the future I will just force it to install a version that already exists so I don’t have to wait.

I was just surprised it took so long to update the package. If I added a third package, I am waiting up to 30+ minutes before I can do anything in my new environment. Perhaps that’s just how it is.

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [September 17, 2024, 10:32pm UTC](https://discourse.julialang.org/t/adding-package-to-new-environment-takes-long-time/119518/6 "2024-09-17T22:32:10Z")

</div>

If you add this to your `startup.jl` file:

```julia
Pkg.UPDATED_REGISTRY_THIS_SESSION[] = true

```

It should update less often and reuse installed packages more.

---

<div class="post-metadata">

**Author:** ![p\_f](https://avatars.discourse-cdn.com/v4/letter/p/45deac/32.png) [@p\_f](https://discourse.julialang.org/u/p_f)\
**Post date:** [September 17, 2024, 10:57pm UTC](https://discourse.julialang.org/t/adding-package-to-new-environment-takes-long-time/119518/7 "2024-09-17T22:57:10Z")

</div>

That’s brilliant, cheers!

---

<div class="post-metadata">

**Author:** ![carstenbauer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/carstenbauer/32/4981_2.png) [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)\
**Post date:** [September 18, 2024, 5:17am UTC](https://discourse.julialang.org/t/adding-package-to-new-environment-takes-long-time/119518/8 "2024-09-18T05:17:48Z")

</div>

I recommend [`JULIA_PKG_PRESERVE_TIERED_INSTALLED`](https://docs.julialang.org/en/v1/manual/environment-variables/#JULIA_PKG_PRESERVE_TIERED_INSTALLED).

More on the `--preserve` argument for `] add` (taken from `]?add`):

```julia
Argument Description
  –––––––––––––––– ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
  installed Like all except also only add versions that are already installed
  all Preserve the state of all existing dependencies (including recursive dependencies)
  direct Preserve the state of all existing direct dependencies
  semver Preserve semver-compatible versions of direct dependencies
  none Do not attempt to preserve any version information
  tiered_installed Like tiered except first try to add only installed versions
  tiered Use the tier that will preserve the most version information while
                   allowing version resolution to succeed (this is the default)

```

Relatedly: [Make `PRESERVE_TIERED_INSTALLED` the default · Issue #3905 · JuliaLang/Pkg.jl · GitHub](https://github.com/JuliaLang/Pkg.jl/issues/3905)

---

<div class="post-metadata">

**Author:** ![p\_f](https://avatars.discourse-cdn.com/v4/letter/p/45deac/32.png) [@p\_f](https://discourse.julialang.org/u/p_f)\
**Post date:** [September 18, 2024, 10:55pm UTC](https://discourse.julialang.org/t/adding-package-to-new-environment-takes-long-time/119518/9 "2024-09-18T22:55:17Z")

</div>

Thank you! I think I will make this the default
