Revise.jl
Revise.jl copied to clipboard
Can't seem to get Revise to work in vscode
I'm probably doing something wrong here, but I'm not sure what it is. Hard to do a traditional MWE in this case, but I'll write down the simplest procedure I can think of.
First do the following in some random directory:
] generate mwe
] activate .
Edit mwe.jl in the src directory to read:
module mwe
function func()
println("hello")
end
end # module
At this point, open vscode if it is not already open. Then in the root directory (using vscode), create a file called mwescripts.jl with the following:
using Revise, Pkg
if !isdefined(Main, :FIRST_RUN)
Pkg.activate(pwd())
FIRST_RUN = false
end
using mwe
mwe.func()
Running mwescripts.jl in a new repl gives:
hello
So far, so good. Then make the following change to the mwe.jl file
module mwe
function func()
println("hello again")
end
end # module
running mwescripts.jl again gives:
hello
Of course, re-starting the Repl gives the correct answer.
Running Windows 10, Julia 1.1.1. Revise passed tests.
I suspect this is a user error rather then a bug, but any help would be appreciated.
EDIT: I should add that I tried using PkgTemplates and various methods for loading the modules in mwescripts.jl but nothing has worked.
Also for good measure, here are the results after following the debugging instructions:
Revise.LogRecord(Debug, DeleteMethod, Action, Revise_4ac0f476, "C:\Users\Clinton\.julia\packages\Revise\agmgx\src\Revise.jl", 226, (time=1.564013467903e9, deltainfo=(Tuple{typeof(mwe.func)}, MethodSummary(:func, :mwe, Symbol("C:\\Users\\Clinton\\Dropbox\\Projects\\mwe\\src\\mwe.jl"), 4, Tuple{typeof(mwe.func)}))))
Revise.LogRecord(Debug, Eval, Action, Revise_9147188b, "C:\Users\Clinton\.julia\packages\Revise\agmgx\src\Revise.jl", 276, (time=1.56401346808e9, deltainfo=(mwe, :(function func()
#= C:\Users\Clinton\Dropbox\Projects\mwe\src\mwe.jl:4 =#
println("hello again")
end))))
I love VSCode but haven't used it much since the interpreter/debugger started working in Juno, so perhaps I'm not doing this the same way you are. So here's a screenshot:
If you have more info about how you're running that script, I'm happy to look further.
If you haven't seen this page, might it help?
I use Juno mostly now too, but I love the code outline features of VSCode, so I periodically try to get it going.
I tried it the way you ran it and got the same result as you. I think the issue is the f5 - Start Debugging command in VSCode. When running the files straight using include statements, it seems to work. Here is how I have it set up after I hit f5 the first time:
And then again after modifying the second file:
I could but wrong, but I don't think I need to touch startup.jl since I am using Revise explicitly.
I can replicate this. The way Revise works is to take over the REPL and call revise
before executing each statement. With IJulia and Atom we have hooks:
- https://github.com/timholy/Revise.jl/blob/26a55b75aeebb374908e7cfddc8f4436bf37e98e/src/Revise.jl#L1043-L1044
- https://github.com/timholy/Revise.jl/blob/26a55b75aeebb374908e7cfddc8f4436bf37e98e/src/Revise.jl#L1088-L1098
Is there something similar for VSCode we can do?