How to use custom sysimage if cannot set flags on Julia startup


I have a custom Julia package (only local) inside an R project. I’m interacting with the Julia package via GitHub - stefan-m-lenz/JuliaConnectoR: A functionally oriented interface for calling Julia from R.
I’d like to precompile this package and its functions since their use is quite static and with similar inputs.

I understood how to create a custom sysimage using PackageCompiler.jl but I don’t know how to use it.
Since JuliaConnectoR does not allow setting up flags on Julia startup is there another way to use the custom sysimage? like an environment variable or a Julia function to load the .so file after startup?


You can maybe create a wrapper script and tell JuliaConnectoR to use that? E.g. something like

exec /path/to/julia --sysimage=/path/to/ "${@}"
1 Like

Uhm, apparently not without modifying or overriding JuliaConnectoR code (I’m trying to do that now).

Btw, what’s “${@}”?

The docs say:

The package requires that Julia (version ≥ 1.0) is installed and that the Julia executable is in the system search PATH or that the JULIA_BINDIR environment variable is set to the bin directory of the Julia installation.

so I guess if call my script julia, make it executable and put it in a folder in PATH it should pick it up.

It is all the parameters passed to this script, see e.g. this answer on StackOverflow.

1 Like

After speaking with the package author (a friend of mine), while he implements the possibility to pass flags at startup he suggested me to use aliases.
I’m now trying to understand how to since it seems the aliases disappear between command-line sessions.
e.g. in R:

> system("alias julia2='julia'")
> system("julia2")
sh: julia2: command not found

Wouldn’t that mean that every time I use Julia from the command-line it would use the wrapper script?

Yea I guess. You can use a directory dependent PATH variable with direnv. I wrote about it in this post about direnv and Julia.

1 Like

I don’t know R, but can’t you set the PATH envvar from your R process before it tries to spawn the Julia process?

Eventually I decided to fork and edit the JuliaConnector package directly to allow arguments.