# ANN: a solution to the precompilation problem: JuliaManager.jl / jlm CLI, a system image manger for Julia

**URL:** <https://discourse.julialang.org/t/ann-a-solution-to-the-precompilation-problem-juliamanager-jl-jlm-cli-a-system-image-manger-for-julia/22849>\
**Category:** Package Announcements\
**Tags:** compilation, precompilation\
**Created:** [April 6, 2019, 9:08pm UTC](https://discourse.julialang.org/t/ann-a-solution-to-the-precompilation-problem-juliamanager-jl-jlm-cli-a-system-image-manger-for-julia/22849 "2019-04-06T21:08:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tkf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkf/32/17635_2.png) [@tkf](https://discourse.julialang.org/u/tkf)\
**Post date:** [April 6, 2019, 9:08pm UTC](https://discourse.julialang.org/t/ann-a-solution-to-the-precompilation-problem-juliamanager-jl-jlm-cli-a-system-image-manger-for-julia/22849/1 "2019-04-06T21:08:39Z")

</div>

I wrote a command line program [`jlm`](https://github.com/tkf/JuliaManager.jl) to fix some pains in using Julia:

- We can create multiple projects with new Pkg.jl quite easily. However, switching projects is painful because it causes [re-precompilation of the packages](https://github.com/JuliaLang/julia/issues/27418). `jlm` fixes it by using different precompilation cache for different project (actually any directory once you run `jlm init`) [1].

- [MKL.jl](https://github.com/JuliaComputing/MKL.jl) is a very convenient way to use MKL with Julia. However, using it with standard Julia installation is problematic due to the precompilation issue. See the [documentation](https://jlm.readthedocs.io/en/latest/#using-mkl-jl-patched-julia-and-standard-julia-side-by-side) for how to use `jlm` with MKL.jl.

- It’s possible to create system images to contain a custom set of packages using PackageCompiler.jl. However, again, switching system images invokes the precompilation issue. You can avoid it if you compile the system images in a `jlm`-compatible way. I wrote a few recipes to create such system images here: [GitHub - tkf/julia-sysimage-recipes: Recipes to build system images for Julia](https://github.com/tkf/julia-sysimage-recipes). (But this feature needs some documentation.)

Quick usage quoted from README:

> ```julia
> (v1.2) pkg> add JuliaManager
> ...
> 
> julia> using JuliaManager
> 
> julia> JuliaManager.install_cli()
> ...
> 
> ```
> 
> You need to add `~/.julia/bin` to `$PATH` as would be indicated if it  
> not. Then, you can use `jlm`:
> 
> ```console
> $ cd PATH/TO/YOUR/PROJECT
> 
> $ jlm init # first run will be slow
> ...
> 
> $ jlm run
> _
> _ _ _(_)_ | Documentation: https://docs.julialang.org
> (_) | (_) (_) |
> _ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
> | | | | | | |/ _` | |
> | | |_| | | | (_| | | Version 1.1.0 (2019-01-21)
> _/ |\ __'_|_|_|\__'_| | Official https://julialang.org/ release
> |__/ |
> 
> julia>
> 
> ```
> 
> See `jlm --help` or the [documentation](https://jlm.readthedocs.io/en/latest/) for more  
> information.

`jlm` still is a quite alpha software. It does not support Windows at the moment (although it shouldn’t be difficult) and only tested in Linux. `jlm` command is implemented in Python and requires Python ≥ 3.5. JuliaManager.jl is tested with Julia 1.0, 1.1, and 1.2-DEV.

[1] This is an implementation of my early proposal [RFC: a "workaround" for the multi-project precompilation cache problem without long-term code debt](https://discourse.julialang.org/t/rfc-a-workaround-for-the-multi-project-precompilation-cache-problem-without-long-term-code-debt/22233). It turned out I can do this without waiting for my PR to be merged if I “_gorilla_-patch” the system image. Furthermore, I improved what I proposed a bit so that you don’t need to create a system image for each project (which may take some time). Note that, even though gorilla sounds stronger than monkey, `jlm` never modifies the original system image. It is designed to not interrupt standard `julia` usage; if you invoke `julia` command as usual there should be no effect of `jlm`.
