Pluto.jl icon indicating copy to clipboard operation
Pluto.jl copied to clipboard

Pkg env folder can get deleted during session

Open BioTurboNick opened this issue 2 years ago • 5 comments

If a notebook is left running for a really long time, the temporary folder storing its environment can get cleaned up by the system.

This leaves the notebook in a broken state, but it will manifest in unusual ways, such as by UndefVarErrors due to missing packages that should have been loaded.

It would be helpful if Pluto could detect if the environment folder has been deleted and require the notebook to be restarted.

BioTurboNick avatar Sep 11 '23 14:09 BioTurboNick

Going to bump this. Might be an easy thing for me to address, if I know where to look. Is there something that already is polling regularly that this function could be added into or could duplicate?

I imagine Pluto could just monitor the environment folder to see if it is still present, and if it is not, present the notification bar to have the user reload the notebook. Perhaps an advanced version could proactively regenerate the environment?

BioTurboNick avatar Oct 23 '24 16:10 BioTurboNick

Maybe we should store the env somewhere else that will not get deleted, like in a Scratch.jl space?

With Scratch.jl my only question is how to clean up the environment after you shut down the notebook / shut down Pluto.

fonsp avatar Oct 25 '24 08:10 fonsp

This is where we create the directory:

https://github.com/fonsp/Pluto.jl/blob/ac2c422ddbaf76c1e041be9019977e348400e6da/src/notebook/saving%20and%20loading.jl#L276

fonsp avatar Oct 25 '24 08:10 fonsp

Running into this issue myself! It leads to weird errors...

fonsp avatar Feb 10 '25 11:02 fonsp

I asked for more information about Scratch spaces, it would be nice if the auto cleanup was done by Pkg.gc instead of having to implement this ourselves: https://github.com/JuliaLang/Pkg.jl/issues/4152

fonsp avatar Feb 11 '25 10:02 fonsp

Fix is merged! Will be released in Pluto 0.20.19

fonsp avatar Sep 24 '25 08:09 fonsp

Awesome, thanks!

BioTurboNick avatar Sep 24 '25 14:09 BioTurboNick