[SOLVED] Choice of startup.jl files

It would be nice if the command julia --startup-file{yes|no} could be modified to julia --startup-file{filename.jl}. I realise that I can do julia -L <filename> but that, surely, is for a different purpose.

There is a case for having a choice of startup.jl files IMHO. Is there a way of doing this? Thx.

I think that you can set DEPOT_PATH now to a different directory (with 1.3). See

https://github.com/JuliaLang/julia/pull/31682

This still does not allow arbitrary filenames, but offers some customization.

As an alternative solution depending on what you want to do, you can run any arbitrary julia file before starting a REPL by just using Julia to execute the file as a script with the -i flag to start a REPL afterward.

❯ echo 'println("hello world")' > example.jl

~
❯ julia --startup-file=no -i example.jl 
hello world
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.2.0 (2019-08-20)
 _/ |\__'_|_|_|\__'_|  |  
|__/                   |

julia> 

I think the startup file might be run earlier than the script, so this might not be a drop-in solution depending on what you’re doing.

1 Like

Many thanks both!
@Tamas_Papp I didn’t know about DEPOT_PATH – sounds like a good idea.
@non-Jedi I’ll experiment with a semi-blank start_up.jl that does an include() depending on a choice.
:slightly_smiling_face:

Workarounds may help you in the short run, but I think that being able to specify a custom startup file path (with arbitrary filenames) is a reasonable feature request.

Please check if there is an existing issue and consider opening one.

@Tamas_Papp It’s probably too trivial for a feature request. My startup.jl now just contains:

println(" Enter configuration file")
confFile = readline()
include(confFile)

which seems to do what I want.

1 Like