Does Revise work with plain modules?

When making a change to a module, I thought I simply needed to save the file and then re-run the importing script (which loads Revise at the very top). But the changes are only ever respected if I not only save the module file but also re-run its source in the current Julia session.

Is this normal?

edit: using VS code.

This is very vague without code or descriptions, what do you mean by plain module and how is the (separate?) script importing it? What do you do to “re-run” something, include? Is that module a package?

Sorry, to be more precise:

module testmod
    
function func()
    print("hello")
end

end

In another file then:


using Revise
using .testmod


testmod.func()

No packages. By re-run I mean pressing Alt+Enter with the open file.

So if I make a change to the module, saving the file alone is not enough. I have to press Alt+Enter as well. Otherwise running the calling file will still lead to the old version of the module being used.

That’ll be an include. Your importing script lacks an include for the testmod file, are you running both files in order then? Otherwise if you only run the importing script, using .testmod should fail.

Revise uses includet for non-package files, and the purpose is to not re-run files manually (in fact reevaluating a module can easily make a mess out of a session).

2 Likes

In VS code? You might try includet(testmod.jl) (yes, the t at the end is intentional) - I’m not sure Revise knows how to update when it’s run from vs code, which is essentially the same as pasting it into the repl

1 Like

Related: take a look here and the entire thread.

1 Like

Thank you guys, simply changing the line using .testmod to includet("testmod.jl") worked.

1 Like