# Revise with nested \`include\`?

**URL:** https://discourse.julialang.org/t/revise-with-nested-include/97916
**Category:** General Usage
**Tags:** question
**Created:** [April 25, 2023, 8:26pm UTC](https://discourse.julialang.org/t/revise-with-nested-include/97916 "2023-04-25T20:26:11Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![tomohiro\_soejima](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomohiro_soejima/32/8056_2.png) [@tomohiro\_soejima](https://discourse.julialang.org/u/tomohiro_soejima)
#### Post date: [April 25, 2023, 8:26pm UTC](https://discourse.julialang.org/t/revise-with-nested-include/97916/1 "2023-04-25T20:26:11Z")

</div>

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

`module1.jl`:

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

```

And then `module2.jl`:

```julia
function f2()
    println("123")
end

```

When I do

```julia
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!

---

<div class="post-metadata">

### Author: ![tomohiro\_soejima](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomohiro_soejima/32/8056_2.png) [@tomohiro\_soejima](https://discourse.julialang.org/u/tomohiro_soejima)
#### Post date: [April 25, 2023, 8:30pm UTC](https://discourse.julialang.org/t/revise-with-nested-include/97916/2 "2023-04-25T20:30:55Z")

</div>

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

> [@\`Revise.jl\` dosn't work on \`include\`ed files](https://discourse.julialang.org/t/revise-jl-dosnt-work-on-include-ed-files/26872/3):
>
> I think this should work fine assuming the following: Tvaccine has is a package. It is in your LOAD\_PATH Tvaccine.jl has a few include(„somefile“) lines from the beginning. I am pretty sure revised worked fine for me in such a set up. Have you tried that? Maybe, it does not work, when you add a new include(„newfile“) to the main code file, but this should be the exception (at least in my workflow)

---

<div class="post-metadata">

### Author: ![tim.holy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim.holy/32/52_2.png) [@tim.holy](https://discourse.julialang.org/u/tim.holy)
#### Post date: [April 26, 2023, 4:11pm UTC](https://discourse.julialang.org/t/revise-with-nested-include/97916/3 "2023-04-26T16:11:19Z")

</div>

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

---

<div class="post-metadata">

### Author: ![tomohiro\_soejima](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomohiro_soejima/32/8056_2.png) [@tomohiro\_soejima](https://discourse.julialang.org/u/tomohiro_soejima)
#### Post date: [April 26, 2023, 5:13pm UTC](https://discourse.julialang.org/t/revise-with-nested-include/97916/4 "2023-04-26T17:13:21Z")

</div>

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

---

<div class="post-metadata">

### Author: ![rfourquet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rfourquet/32/3610_2.png) [@rfourquet](https://discourse.julialang.org/u/rfourquet)
#### Post date: [April 28, 2023, 10:55am UTC](https://discourse.julialang.org/t/revise-with-nested-include/97916/5 "2023-04-28T10:55:59Z")

</div>

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`.

---

<div class="post-metadata">

### Author: ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)
#### Post date: [November 15, 2024, 10:45am UTC](https://discourse.julialang.org/t/revise-with-nested-include/97916/6 "2024-11-15T10:45:18Z")

</div>

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) :

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

```

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

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

```

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

```julia
x= 3

```

If I use `includet` in `b.jl` I have `UndefVarError: \`x` not defined in `Main.Foo``but if I use just`include`in`b.jl`than I can't quickly change`x`and see its effects when calling`foo`.

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)

---

<div class="post-metadata">

### Author: ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)
#### Post date: [November 15, 2024, 1:22pm UTC](https://discourse.julialang.org/t/revise-with-nested-include/97916/7 "2024-11-15T13:22:50Z")

</div>

I tried the trick to use `push!`:

a.jl :

```julia
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…
