timholy / Revise.jl

Automatically update function definitions in a running Julia session
https://timholy.github.io/Revise.jl/stable
Other
1.19k stars 109 forks source link

Quality of life issue – avoid revising when user is exiting REPL #796

Open MilesCranmer opened 8 months ago

MilesCranmer commented 8 months ago

Sorry if this has been posted before.

Sometimes I will modify some struct, then, realizing I need to restart my REPL to get the changes, quit:

julia> exit()

However, rather than exiting immediately as I have requested, Revise will continue to run (for sometimes a second, if not more), while attempting to load my recent (breaking) changes in to the REPL. This inevitably leads to some ugly and irrelevant error messages like this:

julia> exit()
┌ Warning: Replacing docs for `SymbolicRegression.MLJInterfaceModule.SRRegressor :: Union{}` in module `SymbolicRegression.MLJInterfaceModule`
└ @ Base.Docs docs/Docs.jl:243
┌ Warning: Replacing docs for `SymbolicRegression.MLJInterfaceModule.MultitargetSRRegressor :: Union{}` in module `SymbolicRegression.MLJInterfaceModule`
└ @ Base.Docs docs/Docs.jl:243
┌ Error: Failed to revise /Users/mcranmer/PermaDocuments/SymbolicRegression.jl/src/MLJInterface.jl
│   exception =
│    invalid redefinition of constant MLJInterfaceModule.SRFitResult
│    Stacktrace:
│     [1] top-level scope
│       @ util.jl:609
│    Revise evaluation error at /Users/mcranmer/PermaDocuments/SymbolicRegression.jl/util.jl:609
│    
└ @ Revise ~/.julia/packages/Revise/sCmwS/src/packagedef.jl:722
┌ Warning: The running code does not match the saved version for the following files:
│ 
│   /Users/mcranmer/PermaDocuments/SymbolicRegression.jl/src/MLJInterface.jl
│ 
│ If the error was due to evaluation order, it can sometimes be resolved by calling `Revise.retry()`.
│ Use Revise.errors() to report errors again. Only the first error in each file is shown.
│ Your prompt color may be yellow until the errors are resolved.
└ @ Revise ~/.julia/packages/Revise/sCmwS/src/packagedef.jl:832

That hide whatever I was doing from the end of my terminal screen.

This is a quality of life request: I was wondering if there were any options for automatically turning off Revise whenever the user quits the REPL with exit()?

A workaround that seems to work is to use ctrl-D which does not trigger Revise (so it seems?), avoiding this issue. However this is not usable in some settings – like if I'm ssh'd somewhere and ctrl-D instead exits my entire tmux session or something. So I'd like to have a clean exit command that I can use

IanButterworth commented 8 months ago

See https://github.com/timholy/Revise.jl/issues/562

MilesCranmer commented 8 months ago

Thanks. So I guess it doesn't work anymore maybe?

(from that thread) – @schillic In recent versions (I tried Revise v3.5.2 with Julia v1.8.5) the quick exit() workaround does not work anymore. I thought I'd report that here.

I wonder if it could also be an issue of OhMyREPL.jl running things before exit() is called...?