Can I specify the sysimage inside a Julia file?

Is it possible to set the parameters of the interpreter by the Julia file which is executed? Maybe something similar to modelines.

I would have two usecases in mind:

Run a script with compile=min to be closer to a script language.

Select a sysimage.

You can use shebang #! syntax but it wouldn’t work on Windows. You may also have to fudge around the single-argument limitation of using shebangs somehow.

Note that if you’re wondering if you can change the sysimage or interpreter “on the fly” (at runtime), this is not currently possible, especially changing the sysimage (switching to the interpreter might be possible, and if you find out how, please do let me know :slight_smile:).

Something I’ve found to work reliably (with bash on Linux) is the following trick:

exec /path/to/julia --possibly-multiple --julia-options "${BASH_SOURCE[0]}"

println("Hello World!")

(you’ll have to adapt this slightly if your script takes arguments)