Install/update packages from startup.jl

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. 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

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

Isn´t that just

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

It does not do anything if they are already installed.

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

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).

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.

1 Like