2018 update: be sure to check all the answers, as the answer to this question has changed several times over the years. At the time of this update, Revise.jl answer Revise.jl probably the best solution.
I have a file "/SomeAbsolutePath/ctbTestModule.jl" whose contents are:
module ctbTestModule export f1 f1(x) = x + 1 end
I run Julia in a terminal that runs "~ / .juliarc.jl". The startup code includes the line:
push!(LOAD_PATH, "/SomeAbsolutePath/")
Therefore, I can immediately type in the console Julia:
using ctbTestModule
download my module. As expected, f1(1) returns 2 . Now I suddenly decided that I want to edit f1 . I open "/SomeAbsolutePath/ctbTestModule.jl" in the editor and change the contents to:
module ctbTestModule export f1 f1(x) = x + 2 end
Now I'm trying to reload the module in my active Julia session. I'll try
using ctbTestModule
but f1(1) still returns 2 . Next I try:
reload("ctbTestModule")
as suggested here , but f1(1) still returns 2 . Finally, I try:
include("/SomeAbsolutePath/ctbTestModule.jl")
as suggested here , which is not ideal since I have to enter the full absolute path, since the current directory may not be β/ SomeAbsolutePathβ. I get a warning message Warning: replacing module ctbTestModule which sounds promising, but f1(1) still returns 2 .
If I using ctbTestModule current Julia session, start a new one and using ctbTestModule , I will get the desired behavior, i.e. f1(1) will return 3 . But obviously, I want to do this without restarting Julia.
So what am I doing wrong?
Other details: Julia v0.2 on Ubuntu 14.04.