How to clear workspace variables?

I’ve installed it revise.jl How can I use this bag? How can I clear the previous working variables after modifying the program to see the new variable values


Your question is a bit hard to understand.

Revise.jl basically allows you to change function definitions without having to restart the REPL. You don’t need to clear your previous definitions.

Similarly, when you run your code, it will overwrite previous variable values. You don’t need to clear those either before running the code.

If this does not answer your question, please provide an example of what you are trying to accomplish.


You can’t. Julia doesn’t have a way of clearing the “workspace”, even with Revise.


Just run your function again with the new parameter values.


I would love to get this functionality. It seems like it keeps coming up, from the google results for it as well…

I think this happens because both people come from R and Mathlab to Julia, and both have this feature. I am not sure if people coming from other languages miss it. You have an use case that is not covered by assigning nothing to the binding?

You might find Pluto.jl useful. It promises that the objects defined in your workspace are exactly the objects in your notebook.


Good point. It would be interesting to know how they achieve this. The only way I know is re-running Julia.

It is mentioned in their juliacon talk. If I remember correctly it’s done via something like internal modules where a new module is created in the background to get a new namespace. But this could be entirely wrong

I am also a R refugee but the only time this bothers me is when developing new structs that cannot be overwritten. Ironically I feel like julia would benefit more than R from rm(list=ls()) to clear the workspace without restarting.

1 Like

This is known to be an issue, but unfortunately handling it is not easy. See


Pluto also allows this.


Not as in “this can not be done without clearing the workspace”, but as in it messes with my workflow. I have a julia script that I use as a calculator, mainly in my mechanics and thermodynamics class. I seperate tasks with “##”, and as you can imagine, I sometimes define something like theta a bunch of times,in multiple tasks. It would be nice to know that if I forget to define a value for the current task, the value from the previous one is not used without warning. It is more for peace of mind than functionality… I know that is not the most common use for julia, but it just seems like it should be possible, and I would like it :sunny:

This is what I do in my jupyter notebook:

x, y, z = let
    inner_x, inner_y, inner_z

other_results = let x = deepcopy(x), y = deepcopy(y), z = deepcopy(z)

So, each cell has a let block, and if I use some global variable I use the let line to assign deepcopies of these values to new bindings (so nothing outside the let scope is ever changed), if I think the cell should introduce some global values, I let them escape the let block (e.g. x, y, z, other_returns).

I do not exactly see you use case because:

  1. If you would manually delete some names, then you can (probably) set them to nothing with the same effort (ok, in some cases this may not work, but then NaN, missing, or struct NothingReally; end will probably work).
  2. If you wanna go nuclear (something like rm(list=ls())), then you can just restart Julia (this may be too slow), or actually use some macro that finds all defined bindings and assign nothing to them.
  3. If you want a compromise, you may want Pluto.jl or use let scopes (or even module scopes) to avoid leaking bindings between one ‘task’ and the next.

Its not really a big issue either. More to say that for variables its not really an issue to not ‘delete’ them.

Yes, It’s so inconvenient!