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.
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 (GitHub - invenia/PkgTemplates.jl: Create new Julia packages, the easy way) 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.
Having a similar issue. I can’t seem to make vscode and Revise aware of my local module at the same time.
If I do as follows, vscode works as expected – i.e., I can click and go to definition of an exported function from my script and the files defining these functions are parsed correctly, etc. – but Revise dosn’t pick up on the changes:
include("module_file.jl")
using .module_name
If I include it via Revise.includet or as a package via using, Revise can pickup the changes; however, now vscode doesn’t parse the module files and doesn’t let me click&go to definition.
Is there a way to make these two things work as expected at the same time?
This might have been related to a bug with the julia-vscode-language-server I switch the Julia “insider” extension on VSCode and now everything works as expected via using MyModule – Revise picks up changes, VSCode lets me go to definition and shows the documentation.