Can revise track local folder?

I have some project myproject, and I want to use some local package test,
so I orgnize my files like this:

myproject
├── Manifest.toml
├── Project.toml
└── src
    ├── myproject.jl
    └── test
        ├── Project.toml
        └── src
            └── test.jl

Then, in myproject folder, I do
]activate . and ]dev ./src/test so that I can use test in myproject.

So far, it works fine, but when I want to use revise to keep track of my modification to test.jl, it fails. I ran

using Revise
using test
test.greet()

and get the correct result. But changing code inside test.jl doesn’t change the output result.

I have tried ]dev Example as introduced in the homepage of Revise, and it works fine. It seem that Revise only keep track of packages that are in the dev folder.

Is there a way to make Revise also keep track of my test.jl?

I guess you mean ]dev ./src/test, the dot is important as it says relative to the current directory, otherwise /src/test would point to a directory at the root of your file system.

Anyways, I think this should just work.
In fact, when working on Makie.jl, which is a monorepo that constains the different backends as packages directly, I always do it like that, e.g.

git clone git@github.com:MakieOrg/Makie.jl.git
cd Makie.jl
julia --project
julia>]dev . # dev the cloned directory, avoids creating a copy in .julia/dev
julia>]dev ./GLMakie ./CairoMakie # etc, dev the backends (packages)

The only thing different here is that you have your test project contained within the src/ folder which is not the case with the Makie setup.
Maybe try moving it one level up and see if that works?

1 Like

You can also do Revise.track(test) after importing/using.

Thank you!
But it seems that neither Revise.track(test) or Revise.track(pathof(test)) works.

Thank you, you are right that it should be ./src/test and that I made a typo.

I have tried moving the package a level up, and the source tree now looks like:

myproject
├── Manifest.toml
├── Project.toml
└── src
│   └── myproject.jl
test
├── Manifest.toml
├── Project.toml
└── src
     └──  test.jl

However, the Revise still cannot track the change in test.jl.

I think you moved the test folder up too far, src, test should be on the same level, it should be

myproject
├── Manifest.toml
├── Project.toml
└── src
│   └── myproject.jl
└── test
    ├── Manifest.toml
    ├── Project.toml
    └── src
        └──  test.jl

Thank you for your suggestion, but the Revise still doesn’t track the change in this case.

There might be something wrong with your environment, or it is a bug in Revise.jl.

To rule out the first problem, you could do the following test that should definitely work:

Firstly, start Julia with julia --startup-file=no to avoid loading any code from you startup.jl config.

Then create a clean environment that only contains Revise.jl as well as the above project structure:

# julia --startup-file=no

(v1.8) pkg> generate mwe_revise                                                                                                                                                                                                  
  Generating  project mwe_revise:                                                                                                                                                                                                
    mwe_revise/Project.toml                                                                                                                                                                                                      
    mwe_revise/src/mwe_revise.jl 

v1.8) pkg> activate mwe_revise/                                                                                                                                                                                                 
  Activating project at `~/wd/scratch/julia/mwe_revise`

mwe_revise) pkg> add Revise                                                                                                                                                                                                     
    Updating registry at `~/.julia/registries/General.toml`                                                                                                                                                                      
   Resolving package versions...                                                                                                                                                                                                 
   Installed CodeTracking ───── v1.2.0                                                                                                                                                                                           
   Installed LoweredCodeUtils ─ v2.3.0                                                                                                                                                                                           
   Installed JuliaInterpreter ─ v0.9.20                                                                                                                                                                                          
   Installed Revise ─────────── v3.5.0                                                                                                                                                                                           
    Updating `~/wd/scratch/julia/mwe_revise/Project.toml`                                                                                                                                                                        
  [295af30f] + Revise v3.5.0                                                                                                                                                                                                     
    Updating `~/wd/scratch/julia/mwe_revise/Manifest.toml`                                                                                                                                                                       
  [da1fd8a2] + CodeTracking v1.2.0                          
...
Precompiling project...                                 
  5 dependencies successfully precompiled in 10 seconds. 5 already precompiled.

(mwe_revise) pkg> generate ./mwe_revise/test
  Generating  project test:
    ./mwe_revise/test/Project.toml
    ./mwe_revise/test/src/test.jl

(mwe_revise) pkg> dev ./mwe_revise/test/
   Resolving package versions...
    Updating `~/wd/scratch/julia/mwe_revise/Project.toml`
  [7d6a91de] + test v0.1.0 `test`
    Updating `~/wd/scratch/julia/mwe_revise/Manifest.toml`
  [7d6a91de] + test v0.1.0 `test`

You should now have a folder that looks like

mwe_revise
├── Manifest.toml
├── Project.toml
├── src
│   └── mwe_revise.jl
└── test
    ├── Project.toml
    └── src
        └── test.jl

3 directories, 5 files

and Pkg.status() should look like

(mwe_revise) pkg> st
Project mwe_revise v0.1.0
Status `~/wd/scratch/julia/mwe_revise/Project.toml`
  [295af30f] Revise v3.5.0
  [7d6a91de] test v0.1.0 `test`  # note that test is dev'ed!

Continuing with the same REPL session from above, we can now test if Revise.jl is working properly:

julia> using Revise

julia> using mwe_revise

julia> mwe_revise.greet()
Hello World!

# now go into mwe_revise/src/mwe_revise.jl and change the definition of greet()

julia> mwe_revise.greet()
Hello World from mwe_revise!

julia> using test
[ Info: Precompiling test [7d6a91de-cdc6-445d-a797-fd5862e7d54e]

julia> test.greet()
Hello World!

# now go into mwe_revise/test/src/test.jl and change the definition of greet()

julia> test.greet()
Hello World from test!

If the above does not work for you, then something is wrong with your julia installation and/or global environment. You could then try to backup and delete your ~/.julia folder and redo the test to see if that helps.

Sidenote: Naming your package test is not optimal, because the ] test command tries to run a file called test/runtests.jl by default. Not sure if that could also be a reason for the conflict, at least it did not in this small test here.

Thank you again for your detailed instruction.
Unfortunately, after doing exactly as you say, the Revise still cannot work properly.

However, I realize that this might be a problem of my WSL environment.
After trying in windows, Revise works fine.

1 Like

Unfortunately, after doing exactly as you say, the Revise still cannot work properly.

However, I realize that this might be a problem of my WSL environment.

Perhaps related (did not read the whole conversation in that issue): `JULIA_REVISE_POLL=1` needed on WSL2 · Issue #514 · timholy/Revise.jl · GitHub

export JULIA_REVISE_POLL=1 in WSL solves my problem.
Thank you again.