From bcfd62a3a4e64b4e91c8ce521156650ff57f944a Mon Sep 17 00:00:00 2001 From: John Omotani Date: Tue, 30 Apr 2024 16:29:46 +0100 Subject: [PATCH] When adding `using Revise` to startup.jl, guard with try-catch --- machines/shared/machine_setup.jl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/machines/shared/machine_setup.jl b/machines/shared/machine_setup.jl index 51bb48ee9..d8c228969 100644 --- a/machines/shared/machine_setup.jl +++ b/machines/shared/machine_setup.jl @@ -262,8 +262,15 @@ function machine_setup_moment_kinetics(machine::String; no_force_exit::Bool=fals result = run(`grep "using Revise" $startup_path`, wait=false) if !success(result) println("Adding `using Revise` to $startup_path") + # When initialising a new copy of the repo, if Revise is not installed yet + # having just `using Revise` in the startup.jl would cause an error, so + # guard it with a try/catch. open(startup_path, "a") do io - println(io, "\nusing Revise") + println(io, "\ntry") + println(io, " using Revise") + println(io, "catch") + println(io, " println(\"Warning: failed to load Revise\")") + println(io, "end") end end end