# Install/update packages from startup.jl

**URL:** <https://discourse.julialang.org/t/install-update-packages-from-startup-jl/121288>\
**Category:** General Usage\
**Tags:** question, startup\
**Created:** [October 14, 2024, 12:36pm UTC](https://discourse.julialang.org/t/install-update-packages-from-startup-jl/121288 "2024-10-14T12:36:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [October 14, 2024, 12:36pm UTC](https://discourse.julialang.org/t/install-update-packages-from-startup-jl/121288/1 "2024-10-14T12:36:13Z")

</div>

I am wondering if there is a robust solution to

1. making sure that some packages are installed when `startup.jl` runs,

2. periodically updating some (probably the same) packages.

Eg one of these packages is Revise.jl, which [advises a `try ... catch` block](https://timholy.github.io/Revise.jl/stable/config/). This means that, while I usually forget to install it whenever a new Julia version is added, I can just do it manually.

But I rarely every recall to update my root environment (which I keep absolutely minimal). An ideal solution would check every week or so.

I can hack together something but, being lazy, I am wondering if someone has done this already.

Pseudocode for my `startup.jl` would look like

```julia
if isinteractive()
    ensure_installed_maybe_update(["Revise",
                                   "AbbreviatedStackTraces",
                                   "EmacsVterm"];
                                   check_interval = "1week")
    using Revise
    ...
end

```

---

<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:** [October 14, 2024, 12:40pm UTC](https://discourse.julialang.org/t/install-update-packages-from-startup-jl/121288/2 "2024-10-14T12:40:15Z")

</div>

Isn´t that just

```julia
if isinteractive()
     import Pkg; Pkg.add("Revise") # etc
end

```

It does not do anything if they are already installed.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [October 14, 2024, 12:46pm UTC](https://discourse.julialang.org/t/install-update-packages-from-startup-jl/121288/3 "2024-10-14T12:46:11Z")

</div>

> [@lmiq](#):
>
> does not do anything if they are already installed

Are you sure about this? AFAIK it may do a registry update.

---

<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:** [October 14, 2024, 12:47pm UTC](https://discourse.julialang.org/t/install-update-packages-from-startup-jl/121288/4 "2024-10-14T12:47:34Z")

</div>

It does with some frequency (not all the time). But that’s maybe what you want, unless, you want to run that with specified frequency (which then I would solve adding one date check as well).

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [October 14, 2024, 12:50pm UTC](https://discourse.julialang.org/t/install-update-packages-from-startup-jl/121288/5 "2024-10-14T12:50:43Z")

</div>

Sorry, maybe the question was unclear:

1. I don’t want a registry update **in case there are no packages to add** triggered by this script. The idea is that startup time should not be significantly modified 99% of the time.

2. Sure, if packages need to be added, let’s add them, in that case anything goes, including registry updates.

3. I want to **check for updates** once in a while. This should fail silently when I have no net connection.

Again, I can probably put this together, just checking if someone has a script like this.
