Revise.jl never works for me

I have been trying to configure Revise.jl on VS Code (I am new to VS Code since I found Julia to be fiddly with emacs). I enabled using Revise.jl to be executed when I start a new REPL.

I am developing a package. Essentially, I load the package by starting a new REPL Julia: Execute active file in REPL which executes my module:

module MyPkg
include("AnotherFile.jl")
f() = "helloworld"
end

and AnotherFile.jl:

# AnotherFile.jl
g() = "HelloWorld Again" # I added this later to test Revise.jl

When this is started on the REPL, I can see Revise on my workspace but this file is not among Revise.watched_files list for some reason. On the other hand, AnotherFile.jl is included in this list. My current environment is my package.

When I execute MyPkg.f(), I get the expected result. However, modifying it, saving, and doing MyPkg.f() again leads to the exact same result without my new modifications.

I try to add a g() function to AnotherFile.jl and try to execute MyPkg.g() and Julia says that this function cannot be found.

Is there a way to fix or debug this? I can never get it to work.

Welcome to the Julia discourse community :waving_hand:

Hm, this is a bit hard for me to reproduce.

One remark, however: If you execute both files in the same REPL (I would do include("YourFirstFileWithPkg.jl"); include("AnotherFile.jl"); - but evaluate in active REPL is the same)
then g is defined in the global namespace and not in your module. So that makes sense that it is not found. That is not related to Revise, but where the function g is defined.

For your f and the module you define, I am not able to follow what you do, sorry.

Hi!

Julia’s Julia: Execute active file in REPL does not load the module the same way as using MyPkg; as far as I understand, it behaves more like include("MyPkg.jl"), this way the files are not tracked correctly.

A quick fix:

  • type includet("MyPkg.jl") into your current REPL – this will track the file correctly (change "MyPkg.jl" to the correct filename)

A better workflow:

  • Activate your project environment (click {} Julia on the status bar in the bottom of the window)
  • Launch a new Julia REPL (Julia: Start REPL in the command pallette)
  • Type using MyPkg
  • Now you can freely modify your module and enjoy Revise.jl :tada:
1 Like