`Revise.jl` dosn't work on `include`ed files

I am having trouble with Revise.jl. I have files setup like this:

Tvaccine.jl

module Tvaccine
    using Parameters
    using Distributions
    include("entities.jl")

    export main, world

    function main()
        println("Hello world.")
    end
end

entities.jl

function world()
    println("Hello world from included file.")    
end

Then I have the run.jl file that sets up Revise.jl

using Revise
includet("Tvaccine.jl")
using .Tvaccine

Now if I change something in main() or add a new function in the Tvaccine.jl file (the one that was included using includet, everything works as expected. Upon saving my edits, the REPL is updated with the changes.

However, if I edit anything in the entities.jl file, it seems that Revise dosn’t pick up on the changes. If I made an edit to the already exported function, it dosn’t reflect in the REPL. If I add a new function, I get a MethodError: no method matching....

Is the expectation to fully code a program in one file?


My “second” attempt: I generate a new folder, and activate . which allows me to using using mypkg. (Revise.jl is already loaded from the start). Everything works as expected except when I make a new file and include that in the main module using include. Revise dosn’t seem to bring in the functions defined in the new file.

Note that this is different if the files are already included at the using mypkg stage. I hope I make sense, seems like I am kind of rambling on here.

I would say yes. You may want to open an issue for Revise.

I think this should work fine assuming the following:

  1. Tvaccine has is a package.
  2. It is in your LOAD_PATH
  3. 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)

1 Like

You should think of using and import as the “real” ways to track code. includet is deliberately intended to be “track just this file”—it’s designed as the manual alternative to the automated smarts of using and import. You can turn Tvaccine into a package in seconds (https://github.com/invenia/PkgTemplates.jl) or use push!(LOAD_PATH, dir-of-Tvaccine.jl). Then using Tvaccine should do what you want.

The second issue is a known bug. Since that state of affairs is rather transitory (once you add the file and restart everything works going forward), it’s not really been a priority of mine. For anyone really bugged by this, there was a start on a fix that could use help getting over the line. Unfortunately, the internal architecture of Revise has changed substantially since then so I suspect it’s not a small project.

4 Likes