# Reloading by re-executing include() doesn't seem to work

**URL:** https://discourse.julialang.org/t/reloading-by-re-executing-include-doesnt-seem-to-work/45075
**Category:** General Usage
**Created:** [August 17, 2020, 4:03am UTC](https://discourse.julialang.org/t/reloading-by-re-executing-include-doesnt-seem-to-work/45075 "2020-08-17T04:03:37Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![akdor1154](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/akdor1154/32/15975_2.png) [@akdor1154](https://discourse.julialang.org/u/akdor1154)
#### Post date: [August 17, 2020, 4:03am UTC](https://discourse.julialang.org/t/reloading-by-re-executing-include-doesnt-seem-to-work/45075/1 "2020-08-17T04:03:37Z")

</div>

Hey all,  
I’m trying to run a reloading workflow just one step in complexity above the basic workflow as described in the manual. 🙂

I have a MWE which I believe fits the same pattern as given in the manual, but still does not seem to work. Can anyone tell me why?

**My workflow**

```nohighlight
julia --project=@. -i reloader.jl 
> reload()
"Hello world"
> # now edit JuliaIncludeTest to say "Goodbye world"
> reload()
WARNING: replacing module JuliaIncludeTest.
"Hello world" # wtf? it said it was replaced!

```

**Project structure** (or see [https://github.com/akdor1154/jl-include-test](https://github.com/akdor1154/jl-include-test))

```julia
+ src
  - JuliaIncludeTest.jl
- Project.toml
- reloader.jl

```

**src/JuliaIncludeTest.jl**

```nohighlight
module JuliaIncludeTest
greet() = print("Hello World!")
end # module

```

**reloader.jl**

```nohighlight
include("src/JuliaIncludeTest.jl")

function reload()
    include("src/JuliaIncludeTest.jl");
    JuliaIncludeTest.greet()
end

```

---

<div class="post-metadata">

### Author: ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)
#### Post date: [August 17, 2020, 4:40am UTC](https://discourse.julialang.org/t/reloading-by-re-executing-include-doesnt-seem-to-work/45075/2 "2020-08-17T04:40:34Z")

</div>

It sounds like you are looking for Revise.jl.  
This will automatically reload code that changes in files and packages.

---

<div class="post-metadata">

### Author: ![akdor1154](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/akdor1154/32/15975_2.png) [@akdor1154](https://discourse.julialang.org/u/akdor1154)
#### Post date: [August 17, 2020, 4:48am UTC](https://discourse.julialang.org/t/reloading-by-re-executing-include-doesnt-seem-to-work/45075/3 "2020-08-17T04:48:06Z")

</div>

Thanks for the suggestion, but I started down this track (of working back to an MWE) because Revise wasn’t working for me either (for different reasons, some weird behaviour with Requires I think). So I started down the path of “reproduce as simply as possible”. Now I’m intrigued why this method doesn’t work, as it seems to contradict the manual saying that `include()` should redefine included modules!

---

<div class="post-metadata">

### Author: ![Per](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/per/32/10387_2.png) [@Per](https://discourse.julialang.org/u/Per)
#### Post date: [August 17, 2020, 12:16pm UTC](https://discourse.julialang.org/t/reloading-by-re-executing-include-doesnt-seem-to-work/45075/4 "2020-08-17T12:16:55Z")

</div>

The reason why your `reload` function doesn’t work the way you expect it to is that it is compiled _before_ it runs. At compile-time `JuliaIncludeTest.greet()` refers to a different function, because the `include` has not happened yet.

---

<div class="post-metadata">

### Author: ![Per](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/per/32/10387_2.png) [@Per](https://discourse.julialang.org/u/Per)
#### Post date: [August 17, 2020, 12:23pm UTC](https://discourse.julialang.org/t/reloading-by-re-executing-include-doesnt-seem-to-work/45075/5 "2020-08-17T12:23:23Z")

</div>

If you’re having problems getting the right version of Revise.jl, it might the issue described in [this thread.](https://discourse.julialang.org/t/psa-pin-revise-at-2/44412)
