How to update packages and create a system image

Hello,

I am using a bash script to create a new system image when the source code, in particular the set of used packages of my project has changed (after git pull).

The core are the following three lines:

rm -f Manifest.toml
julia --project -e "include(\"./test/update_packages.jl\");"
julia --project -e "using Pkg; Pkg.precompile()"
julia --project -e "include(\"./test/create_sys_image.jl\");"

This is the content of the file update_packages.jl:

@info "Updating packages ..."
using Pkg
Pkg.instantiate()
Pkg.update()
Pkg.precompile()

Explanation:

  1. I need to delete Manifest.toml, because in the git repository the content
    of Project.toml sometimes changes, and I get an error message if new packages
    are added if I do not delete Manifest.toml
  2. The update_packages.jl script sometimes fails with the message:
    “Not all packages could be precompiled. Please restart Julia and try again…”
    The third line of the bash script is doing that.
  3. This is the main script to create a new system image. Before executing it I
    want to be sure that all packages are up-to-date.

While this works fine, I wonder if there is a way to achieve the same goal without
using bash, because bash might not be available on Windows or Mac.

Any ideas how to do that in pure Julia?

I think this kind of functionality should become part of base.

Uwe

Hmmm, would it possible to spawn a background session of Julia and run the code in that session using @spawn? So you can run this in Julia. Not sure, just an idea.

Also, if the windows is controlled by you, you can easily install some kind of bash like git-bash on it then this will work. I see some programs have a .bat file just for windows so on windows the .bat file is invoked instead or something.