How to set up Julia to always run a set of code at the beginning of each session?

I want to run a certain piece codes at the beginning of each session, e.g. to set up the proxy. How do I set this up?

1 Like

Updated (thanks to later posts)

On v0.7 or later, go to ~\.julia\config\startup.jl and put the Julia code you wish to run inside. If the config folder doesn’t exists, just create it.

On Windows, the file should be locate C:\Users\_YourUsername_\.julia\config\startup.jl (or wherever your user profile happens to be).

On v0.6 go to ~/.juliarc.jl and enter the code.

Why I am tagging this as a solution even though so many have contributed to this solution?
Thanks to everyone who contributed. I have decided to tag this as the solution so that internet searcher can find the solution quickly. But it was clearly a group effort to clear my confusion early on.

1 Like

It works for me in vanilla Julia (on MacOS.)

Are you om v0.7 or v1? Didnt work for me on v0.6.4 on Windows 7

On Julia 0.6 you’d have to use ~/.juliarc.jl instead.


Just to be clear: On versions 0.6.x use ~/.juliarc.jl. On 0.7 and 1.0 use ~/.julia/config/startup.jl. (Or the equivalent for Windows). These should work for both JuliaPro and plain Julia.

1 Like