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?
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
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.
function reset!(clock::Clock)
error("test") # to check Revise.jl
clock.t = 0.0
return clock
end
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
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.
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?
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
I’m running codes on Ubuntu 18.04 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
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.
@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
EDIT: Everyone uses Revise correctly and doesn’t need to turn off and on REPL repeatedly. Feels like being an idiot. Unfair