# How do I reload a module under development in Julia 1.6?

**URL:** <https://discourse.julialang.org/t/how-do-i-reload-a-module-under-development-in-julia-1-6/64377>\
**Category:** General Usage\
**Created:** [July 9, 2021, 7:04pm UTC](https://discourse.julialang.org/t/how-do-i-reload-a-module-under-development-in-julia-1-6/64377 "2021-07-09T19:04:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![orome](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/orome/32/26965_2.png) [@orome](https://discourse.julialang.org/u/orome)\
**Post date:** [July 9, 2021, 7:04pm UTC](https://discourse.julialang.org/t/how-do-i-reload-a-module-under-development-in-julia-1-6/64377/1 "2021-07-09T19:04:33Z")

</div>

I know this question has been asked and answered before, but none of the many answers work for me as described.

What is the procedure for reloading a module that I’m working on in Julia (1.6)?

For example, I have

```julia
module MyModule

export letters

const letters = String('A':'Z')

end

```

and I want the be able to load the module, make changes to `letters` in the module’s file, and then reload the module and have those changes reflected in subsequent uses of `letters`. This seems simple enough, but I can’t get it to work.

I’ve tried

```julia
include("src/MyModule.jl")
using .MyModule

```

but if I change the definition of `letters` in `MyModule.jl` and then

```julia
include("src/MyModule.jl")

```

`letters` doesn’t change, unless I fully qualify its use each time with `Main.MyModule.letters`: `using Main.MyModule; letters` refers, for example, to the old definition.

How do I reload a module under development so that I can refer to its definitions without fully qualifying them (and without having an unqualified shadow definition always lying around)?

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [July 9, 2021, 8:26pm UTC](https://discourse.julialang.org/t/how-do-i-reload-a-module-under-development-in-julia-1-6/64377/2 "2021-07-09T20:26:45Z")

</div>

I highly recommend looking at the Revise based workflow which will reload the file for you:  
[https://docs.julialang.org/en/v1/manual/workflow-tips/#Revise-based-workflows](https://docs.julialang.org/en/v1/manual/workflow-tips/#Revise-based-workflows)

Also the standard place to put modules in development is your .julia/dev/ folder. If you would like to use another folder, you will need to modify your [`LOAD_PATH`](https://docs.julialang.org/en/v1/base/constants/#Base.LOAD_PATH) or your [`JULIA_LOAD_PATH`](https://docs.julialang.org/en/v1/manual/environment-variables/#JULIA_LOAD_PATH) environmental variable.

You would then load your module via `using MyModule`.

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [July 9, 2021, 8:33pm UTC](https://discourse.julialang.org/t/how-do-i-reload-a-module-under-development-in-julia-1-6/64377/3 "2021-07-09T20:33:48Z")

</div>

Here’s a demonstration:

```julia
julia> pwd()
"C:\\Users\\kittisopikulm\\Documents\\Julia\\ReviseDemo"

julia> push!(LOAD_PATH, pwd())
4-element Vector{String}:
 "@"
 "@v#.#"
 "@stdlib"
 "C:\\Users\\kittisopikulm\\Documents\\Julia\\ReviseDemo"

julia> using Revise

julia> open("ReviseDemo.jl","w") do io
           write(io,
           """
           module ReviseDemo
           export letters
           const letters = String('A':'C')
           end
           """
           )
       end
69

julia> using ReviseDemo
[Info: Precompiling ReviseDemo [top-level]

julia> letters
"ABC"

julia> open("ReviseDemo.jl","w") do io
           write(io,
           """
           module ReviseDemo
           export letters
           const letters = String('A':'Z')
           end
           """
           )
       end
69

julia> letters
WARNING: redefinition of constant letters. This may fail, cause incorrect answers, or produce other errors.
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"

```

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [July 9, 2021, 8:41pm UTC](https://discourse.julialang.org/t/how-do-i-reload-a-module-under-development-in-julia-1-6/64377/4 "2021-07-09T20:41:15Z")

</div>

Here’s another demo setting the environmental variable in Windows:

```julia
PS C:\Users\kittisopikulm\Documents\Julia\ReviseDemo> $env:JULIA_LOAD_PATH="$(pwd);"
PS C:\Users\kittisopikulm\Documents\Julia\ReviseDemo> julia
               _
   _ _ _(_)_ | Documentation: https://docs.julialang.org
  (_) | (_) (_) |
   _ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` | |
  | | |_| | | | (_| | | Version 1.6.0 (2021-03-24)
 _/ |\ __'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |

julia> LOAD_PATH
4-element Vector{String}:
 "C:\\Users\\kittisopikulm\\Documents\\Julia\\ReviseDemo"
 "@"
 "@v#.#"
 "@stdlib"

julia> using Revise

julia> open("ReviseDemo.jl","w") do io
           write(io,
           """
           module ReviseDemo
           export letters
           letters = String('A':'Z')
           end
           """
           )
       end
63

julia> using ReviseDemo
[Info: Precompiling ReviseDemo [top-level]

julia> letters
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"

julia> open("ReviseDemo.jl","w") do io
           write(io,
           """
           module ReviseDemo
           export letters
           letters = String('A':'C')
           end
           """
           )
       end
63

julia> letters
"ABC"

```

Note if you are using Linux, then you will want to use a colon, `:`, rather than a semicolon `;` at the end of the `JULIA_LOAD_PATH` environmental variable.
