Should I turn on/off repeatedly to reflect changes of currently developing packages?

Hi, I’m developing my own packages.

While developing my packages, I have to turn off Julia REPL and turn on again to reflect changes of the packages, which takes too long time.

As in docs of Revise.jl, it looks that I have to change a package to be dev mode to make Revise.jl works automatically (without turn off/on REPL).
However, I don’t know how to change my currently developing package to be dev.
Instead of it, manually adding files like using Revise; includet("my_file.jl") works to me but it seems not for package development.

So what I need is:
Is there any way to reflect changes of my own package (can be unregistered) without turn off and on REPL?

EDIT: should my package be in ~/.julia/dev?

Your package does not need to be in ~/.julia/dev. Simple enter the path to your local package in the REPL’s Pkg mode: ]dev ~/path/to/your/package.

  1. when activated at the project (seems an incorrect way to enter dev mode)
(FymEnvs) pkg> dev .
[ Info: Resolving package identifier `.` as a directory at `~/github/julia/FymEnvs`.
Path `.` exists and looks like the correct package. Using existing path.
ERROR: package `FymEnvs [d6fd7ba0]` has the same name or UUID as the active project
  1. at default env
(@v1.5) pkg> dev .
[ Info: Resolving package identifier `.` as a directory at `~/github/julia/FymEnvs`.
Path `.` exists and looks like the correct package. Using existing path.
  Resolving package versions...
Updating `~/.julia/environments/v1.5/Project.toml`
  [d6fd7ba0] ~ FymEnvs v0.1.0 `~/.julia/dev/FymEnvs` ⇒ v0.1.0 `../../../github/julia/FymEnvs`
Updating `~/.julia/environments/v1.5/Manifest.toml`
  [d6fd7ba0] ~ FymEnvs v0.1.0 `~/.julia/dev/FymEnvs` ⇒ v0.1.0 `../../../github/julia/FymEnvs`

and running codes with changes at both the project and default envs seems not reflect the changes.

Loading Revise and FymEnvs after deving the package should work. Note that now Pkg Is tracking the path ../../../github/julia/FymEnvs, so make sure you’re editing the right code files.

  1. A part of source code
function reset!(clock::Clock)
    error("test")  # to check Revise.jl
    clock.t = 0.0
    return clock
end

  1. reset! gives an error
julia> using FymEnvs
[ Info: Precompiling FymEnvs [d6fd7ba0-2ca9-4676-ba23-5bed9e863cfb]
using
julia> clock = Clock(0.01, 1)
Clock(0.0, 0.01, 10.0, 1001, [0.0, 0.01], 1)

julia> reset!(clock)
ERROR: test
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] reset!(::Clock) at /home/jinrae/github/julia/FymEnvs/src/FymCore.jl:58
 [3] top-level scope at REPL[3]:1
  1. dev and using Revise; using FymEnvs
(@v1.5) pkg> dev .
[ Info: Resolving package identifier `.` as a directory at `~/github/julia/FymEnvs`.
Path `.` exists and looks like the correct package. Using existing path.
  Resolving package versions...
No Changes to `~/.julia/environments/v1.5/Project.toml`
No Changes to `~/.julia/environments/v1.5/Manifest.toml`

julia> using Revise

julia> using FymEnvs

julia> clock = Clock(0.01, 1)
Clock(2.0e-323, 0.01, 10.0, 1001, [0.0, 0.01], 1)

julia> reset!(clock)
ERROR: test
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] reset!(::Clock) at /home/jinrae/github/julia/FymEnvs/src/FymCore.jl:58
 [3] top-level scope at REPL[5]:1

julia> reset!(clock)  # error msg removed in script
ERROR: test
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] reset!(::Clock) at /home/jinrae/github/julia/FymEnvs/src/FymCore.jl:58
 [3] top-level scope at REPL[5]:1

Still does not work for me.

Note: of course it works after turning off/on REPL with changes.

julia> using FymEnvs
[ Info: Precompiling FymEnvs [d6fd7ba0-2ca9-4676-ba23-5bed9e863cfb]

julia> clock = Clock(0.01, 1)
Clock(3.0e-323, 0.01, 10.0, 1001, [0.0, 0.01], 1)

julia> reset!(clock)
Clock(0.0, 0.01, 10.0, 1001, [0.0, 0.01], 1)

You have to say using Revise before you say using FymEnvs. Is that what you’re doing?

Sure.
Please see 3. of this.

1 Like

Sorry about that, I jumped the gun.

This also smells to me like a path issue. When you dev a package (by name at least, I don’t know about by path) it is copied to julia/dev. Can you see if the directory you’re in has a new /dev folder in it? Or maybe one level up? Or maybe if indeed julia/dev contains a copy of FymEnvs?

My current ~/.julia/dev is empty.
It should be contain a copy of FymEnvs? If so, it seems that dev command was not properly worked.

What about ~/github/julia/ and ~/github/julia/FymEnvs? Do they have a /dev folder in them?

Umm…
It seems to me that no directory has /dev directory…

Having considered the case of registered packages, it definitely looks weird, isn’t it?

It’s normal for Pkg to directly track file path to local packages instead of cloning them into dev. Could you perhaps use @edit reset!(clock) after removing the error line to verify that the correct file is being updated?

Are you on Windows with WSL2 by any chance? There’s an issue with FileWatching in that setup which means Revise doesn’t work (unless you change an environmental variable): https://github.com/timholy/Revise.jl/issues/514

@edit shows that the script has correctly been changed, right?

julia> using Revise

julia> using FymEnvs
[ Info: Precompiling FymEnvs [d6fd7ba0-2ca9-4676-ba23-5bed9e863cfb]

julia> clock = Clock(0.01, 1)
Clock(2.2e-322, 0.01, 10.0, 1001, [0.0, 0.01], 1)

julia> reset!(clock)
ERROR: test
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] reset!(::Clock) at /home/jinrae/github/julia/FymEnvs/src/FymCore.jl:58
 [3] top-level scope at REPL[6]:1

julia> @edit reset!(clock)  # file updated

julia> reset!(clock)
ERROR: test
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] reset!(::Clock) at /home/jinrae/github/julia/FymEnvs/src/FymCore.jl:58
 [3] top-level scope at REPL[8]:1

  • Update checked using @edit:
function reset!(clock::Clock)
    # error("test")
    clock.t = 0.0
    return clock
end

I’m running codes on Ubuntu 18.04 :sweat: Does it also have a potential issue that you mentioned?

EDIT: includet command works well, so the problem occurs when tyring to revise a local package. Can it be related to that as well?
EDIT2: there’s a peculiar thing in my routine: I’m writing codes on my Mac and sending them to server using rsync. I found that some rsync options prevent immediate update of scripts in Revise but Revise.jl does not reflect changes at all after a while in this case.
EDIT3: I suspect that the reason might be rsync, but directly correcting codes on Ubuntu server does not work as well :frowning:

No, that should be fine, it is probably a different issue then. You could try setting the environmental variable anyway though to see it helps.

I didn’t get it.
Can you explain what it means?

It’s described here: Configuration · Revise.jl, if you start Julia with

JULIA_REVISE_POLL=1 julia 

Then Revise will check every few seconds to see if the files have updated instead of waiting for a notification that they’ve been updated. So if there’s an issue with those notifications then it could help.

2 Likes

Gosh, it doesn’t work as well.
There might be an error while compiling/installing Revise.
I’ll this those things after reinstalling Revise.jl.

EDIT: nothing works for me…
What’s wrong with my Revise.jl? :cry:
I don’t want spend times to turn off and on REPL everytime. So sad.

@ericphanson
@lhnguyen-vn
@tomerarnon
Guys, I thought there might be an error in my Ubuntu server so I tested above things again on my local Mac.
And it works very well.
One thing different from the case of Ubuntu was that the response of executing command dev looks different. So I suspect that there’s something wrong in my server, and I will reinstall julia and try again.

Thanks you all :slight_smile:

EDIT: Everyone uses Revise correctly and doesn’t need to turn off and on REPL repeatedly. Feels like being an idiot. Unfair :grin:

1 Like