Revise with nested `include`?

Hi, I have a simple question about nested include when using Revise.jl. Consider the following nested structure:

module1.jl:

module Module1
    function f1()
        println("abc")
    end
    include("module2.jl")
end

And then module2.jl:

function f2()
    println("123")
end

When I do

julia> using Revise
julia> includet("module1.jl")
julia> using .Module1

I can update the function f1 by modifying module1.jl, but I cannot modify f2 via modifying module2.jl. As I understand it, it is because Revise.jl does not “penetrate” the include statement in module1.jl.

Is there an easy way around this? I suppose I can change include to includet, but that would add Revise as a dependency to Module1, when it’s otherwise unnecessary, which I would like to avoid.

Thanks in advance!

I noticed there was already a discussion of this in an earlier topic, sorry for a duplicate post!

If you use using Module1 instead of includet then it should work fine. includet is for quick hacks.

1 Like

Thank you! That makes sense. I will make my module into a package to make the best use of Revise.

Note that it’s not even necessary to make your module into a package, it’s enough to have it in a file with the module’s name ("Module1.jl"), and have your file in your LOAD_PATH.

1 Like

Hello, I have the same issue, so rather than starting a new theread I continue this one…

Let’s say I have 3 files:

a.jl (the application in the real case) :

using Revise
includet("b.jl")
using .Foo
foo(1)

b.jl (the model structure in the real case) :

module Foo
using Revise
include("c.jl")
export foo
foo(y) = x + y 
end

c.jl (default parameters in the real case) :

x= 3

If I use includet in b.jl I have UndefVarError: \x` not defined in `Main.Foo`but if I use justincludeinb.jlthan I can't quickly changexand see its effects when callingfoo`.

For this case I don’t want to create a package, I would like to have something self-contained in the folder that I can share with collegues (that even don’t use git).

How should I procede ? (I use VSCode if it matters)

I tried the trick to use push!:

a.jl :

using Pkg
Pkg.activate(@__DIR__)
using Revise
push!(LOAD_PATH,@__DIR__)
using Foo
foo(1)

It works but only if there is no ENV… if I add another package so that there is a Project/Manifest.toml, than I got an error in using Foo that Foo is not found…