How can I restart Julia

What command can I run to restart Julia and does this have impact on any of the packages already installed.

You can find key shortcuts at The Julia REPL · The Julia Language, so its ^D (you can also type exit()) and then restart it again.
That of course depends on which system/IDE you are on (Terminal or Mac OS App or VS Code or what you use)

All packages installed will still be installed (e.g. with add MyPackage, YourPackage), but you have to do using YourPackages again to be able to use them.

Do you have a specific reason to restart?

1 Like

I define a macro in my .bashrc file like this:

alias jl='julia --project'

so that I can quickly restart Julia with <CTRL>+<D>jl<ENTER> . Restarting Julia is for example useful if you redefined a struct or a typed global variable.

3 Likes

Link to related thread:

2 Likes

What is the --project for?

A Project is a folder that contains a Project.toml file. This file contains a list of the packages that you are using for this project. This avoids problems in the long run. For details see: Working with Julia projects | Julia programming notes

Starting Julia without --project will use the global Project.toml . To see see what is in your global environment type ]st . Try to keep your global environment clean.

3 Likes

If you’re using VSCode you can use ALT + J + K to kill/close Julia, then you can use ALT + J + O to open a new Julia REPL. I tend to hold down the ALT key then type “jkjo” to perform this quickly.

This will not impact any packages installed, but you will have to reload packages in like “using Package”.

You can also use Ctrl + Shift + P and then enter restart and select Julia: Restart REPL in VSCode.
If you do not use any other command with restart, it will be at the top position after entering restart and you can directly execute it with enter.
If you haven’t entered a different command, you can even skip entering restart and hit enter directly.
This works if you do not have an open REPL, too.

You can simply type ALT + j and then ALT + r to close the running Julia session, if any, and then (re)start a new one. The r is mnemonic for “restart”.