Trouble with `dev` and `Revise`

I am trying to get a workflow set up and I am struggling with Revise and deving a package.

I want to dev DataFrames so I can contribute to it.

After ] dev DataFrames, ] status give me:

(v1.2) pkg> status
    Status `~/.julia/environments/v1.2/Project.toml`
  [6e4b80f9] BenchmarkTools v0.4.3
  [ad839575] Blink v0.12.0
  [336ed68f] CSV v0.5.11
  [a93c6f00] DataFrames v0.19.3 [`~/.julia/dev/DataFrames`]
  [1313f7d8] DataFramesMeta v0.5.0
  [14b8a8f1] PkgTemplates v0.6.2
  [91a5bcdd] Plots v0.26.2
  [295af30f] Revise v2.1.10
  [1277b4bf] ShiftedArrays v0.5.0
  [40c74d1a] TableView v0.4.0

Then I do using Revise. When I do using DataFrames in the terminal, i get

julia> using DataFrames
[ Info: Recompiling stale cache file /home/peterwd/.julia/compiled/v1.2/DataFrames/AR9oZ.ji for DataFrames [a93c6f00-e57d-5684-b7b6-d8193f3e46c0]

This seems wrong, right? It shouldn’t be recompiling from .julia/compiled, it should be compiling fresh from .julia/dev.

Now I say edit(DataFrames) which should tell Revise to track DataFrames and recompile with any changes. But no changes to the code produce any re-compilation.

I am pretty sure this is exactly what I did the last time i got this set up, so it’s a mystery why it’s not working.

Any help is appreciated.

.julia/compiled is just the place where precompilation files are stored so there is nothing wrong there.

Where did you read this? The way you have Revise track a package is by first loading Revise and then the package `using Revise, DataFrames´.

3 Likes

I loaded Revise first.

I was under the impression that “edit(M::Module)” edited “src/$M.jl”. At least, when I used it the editor popped up and opened the correct file.

edit("src/Module_name.jl") does indeed work.

Yeah, sure. You can edit the files however you want.

Did you get the example at https://timholy.github.io/Revise.jl/stable/#Usage-example-1 to work?

Yes, it is all working now, thank you.

I played around with this again today and I am having trouble once again. Here is an MWE. It will be a mix of what is given in the Pkg.jl docs, in particular section 5 on creating anew package here the Workflow tips docs, here, the PkgTemplates.jl docs here, and the Revise.jl docs here.

I have a folder called Development that I want to hold all my code, rather than .julia/dev. Reading the workflow tips, this is how I start creating the project.

# Change directories into my development folder
$ cd Documents/Development
# Start julia
$ julia
# Use PkgTemplates
julia> using PkgTemplates
# Check what a default package would look like. 
# note: I want the package directory to not be in .julia/dev
julia> t = Template()
Template:
  → User: pdeffebach
  → Host: github.com
  → License: MIT (pdeffebach <p.deffebach@gmail.com> 2019)
  → Package directory: ~/.julia/dev
  → Minimum Julia version: v1.0
  → SSH remote: No
  → Add packages to main environment: Yes
  → Commit Manifest.toml: No
  → Plugins: None
# Setting dir = "." does what I want. 
julia> t = Template(dir = ".")
Template:
  → User: pdeffebach
  → Host: github.com
  → License: MIT (pdeffebach <p.deffebach@gmail.com> 2019)
  → Package directory: ~/Documents/Development/
  → Minimum Julia version: v1.0
  → SSH remote: No
  → Add packages to main environment: Yes
  → Commit Manifest.toml: No
  → Plugins: None
# Create the packag
julia> generate("HelloWorld", t)
# Get into the newly created directory
shell> cd HelloWorld
/home/peterwd/Documents/Development/HelloWorld
# Load revise to start editing
julia> using Revise
# Use the new HelloWorld package
julia> using HelloWorld
[ Info: Precompiling HelloWorld [233cd533-293a-414a-b31a-fd2ca2ae87f6]
julia> HelloWorld.greet()
Hello World!

In the docs for Revise here, it states that Revise can track " any package that you load with import or using". Given that I just did using HelloWorld and it worked, I figured Revise should be able to do it.

julia> edit("src/HelloWorld.jl")

Now I change the output of HelloWorld.greet() from "Hello, World!" to just "Hello".

julia> HelloWorld.greet()
Hello World!

It didn’t work.

But in the Revise.jl docs here it has a dev Example command in its tutorial. Given that I am creating code for the first time, I need to use develop slightly differently. I use the file-path method of develop rather than a html for git or the command for developing a registered package.

(v1.2) pkg> develop .

Editing still doesn’t work so I close out of my julia session and open up a new one.

# Check that the package exists
  [6e4b80f9] BenchmarkTools v0.4.3
  [ad839575] Blink v0.12.0
  [336ed68f] CSV v0.5.11
  [1313f7d8] DataFramesMeta v0.5.0
  [233cd533] HelloWorld v0.1.0 [`../../../Documents/Development/HelloWorld`]
  [14b8a8f1] PkgTemplates v0.6.2
  [91a5bcdd] Plots v0.26.2
  [d330b81b] PyPlot v2.8.2
  [1fd47b50] QuadGK v2.1.0
  [295af30f] Revise v2.1.10
  [1277b4bf] ShiftedArrays v0.5.0
  [40c74d1a] TableView v0.4.0
# Load Revise
julia> using Revise
# Load HelloWorld
julia> using HelloWorld
# Check that the change I made earlier is in effect, from
# "Hello, World!" to "Hello!"
julia> HelloWorld.greet()
Hello!
# Edit the file again
edit("src/HelloWorld.jl")

Once again it opens up the editor and change the file, this time to "Hello, Peter!". The change is not updated.

Finally I will try by updating the LOAD_PATH variable. I start a new julia session in the HelloWorld directory.

julia> push!(LOAD_PATH, "~/Documents/Development")
4-element Array{String,1}:
 "@"                      
 "@v#.#"                  
 "@stdlib"                
 "~/Documents/Development"
# Load Revise
julia> using Revise
# Load HelloWorld
julia> using HelloWorld
[ Info: Recompiling stale cache file /home/peterwd/.julia/compiled/v1.2/HelloWorld/C0i32.ji for HelloWorld [233cd533-293a-414a-b31a-fd2ca2ae87f6]
# See that the output is what it should be
julia> HelloWorld.greet()
Hello, Peter!
julia> edit("src/HelloWorld.jl")

Now I change it back from “Hello, Peter!” to “Hello, World!” once again. It still does not work.

Based on the documentation, these all seem like plausible methods for getting up and running. Finally, I tried not configuring the Template(dir = ".") command and instead having it appear in .julia/dev. This also did not work.

I don’t think a complete guide of creating a new package from scratch to using Revise on it exists. Hopefully with some modifications the lengthy MWE above can serve as the basis for such a guide.

Any help is appreciated.

Here is my session:

julia> t = Template(dir = ".", user="KristofferC")
Template:
  → User: KristofferC
  → Host: github.com
...

julia> generate("HelloWorld", t)
Generating project HelloWorld:
    /home/kc/Documents/JuliaTests/HelloWorld/Project.toml
    /home/kc/Documents/JuliaTests/HelloWorld/src/HelloWorld.jl
[ Info: Initialized Git repo at /home/kc/Documents/JuliaTests/HelloWorld
[ Info: Set remote origin to https://github.com/KristofferC/HelloWorld.jl

(JuliaTests) pkg> st
    Status `~/Documents/JuliaTests/Project.toml`
  [b7e086d2] HelloWorld v0.1.0 [`~/Documents/JuliaTests/HelloWorld`]

julia> using Revise, HelloWorld
[ Info: Precompiling HelloWorld [b7e086d2-bfe5-4300-a110-4bbbf57d4dec]

julia> HelloWorld.greet()
Hello World!
julia> edit("HelloWorld/src/HelloWorld.jl") # edited

julia> HelloWorld.greet()
Hello

Are you sure you edited the correct file (HelloWorld/src/HelloWorld.jl)?

I would almost never touch LOAD_PATH.

1 Like

I deleted all “HelloWorld” folders and removed the package, tried this above and it did not work.

Revise tests pass. However if I make a typo in the name, say edit("HelloWorld/src/Helloworld.jl") then it creates a new file and edits that rather than throwing an error. I think this is odd behavior and might be indicative of Revise not working correctly.

Should I file a bug? Would it go in Revise, Pkg, or somewhere else? I can re-install Julia in a few days and see if it works after that as well.

I filed an issue with Revise here.

That’s not a Revise bug, because edit is defined in InteractiveUtils.

The behavior you’re finding odd is pretty common. For example, at the linux prompt:

tim@diva:/tmp$ echo "Hello Peter!" > peter.txt
tim@diva:/tmp$ emacs petr.txt &

Neither emacs nor bash warns you that petr.txt doesn’t exist, it just opens a new blank file. Same as Julia’s edit.

1 Like