REPL workflow reload doesn't work

question

#1

I think I followed:
https://docs.julialang.org/en/stable/manual/workflow-tips/#A-basic-editor/REPL-workflow-1

but it doesn’t seem to work.

Created Tmp.jl
Inside Tmp.jl:

module Tmp

end

Then started the REPL

include("Tmp.jl")

works fine, but

reload("Tmp")

produces this error:

ERROR: ArgumentError: Module Tmp not found in current path.
Run `Pkg.add("Tmp")` to install the Tmp package.
Stacktrace:
 [1] reload(::String) at ./loading.jl:371
 [2] macro expansion at ./REPL.jl:97 [inlined]
 [3] (::Base.REPL.##1#2{Base.REPL.REPLBackend})() at ./event.jl:73


#2

In your case, rather than calling reload, you can just do include("Tmp.jl") again.

The manual, on the other hand, is assuming that the Tmp.jl file is somewhere on your LOAD_PATH and that you’ve loaded it with:

import Tmp

rather than include("Tmp.jl").

You can read more about LOAD_PATH here: https://docs.julialang.org/en/stable/manual/modules/#Module-file-paths-1

To include your current directory in LOAD_PATH, do:

julia> push!(LOAD_PATH, pwd())                     

julia> import Tmp

julia> reload("Tmp")
WARNING: replacing module Tmp

#3

By the way, I think the manual is not very clear on this point, so I’ve opened a PR to improve it: https://github.com/JuliaLang/julia/pull/24223


#4

Also, you can automate everything with the magical


#5

IIRC, Revise won’t automatically track files loaded by include. So for a workflow involving files not in the LOAD_PATH, some extra work would be needed to have Revise track those files, right?


#6

I think you are right, see
https://github.com/timholy/Revise.jl/issues/40
But practically, packages are so lightweight that I do all nontrivial development using one, so this is not a constraint for me.