Hello, I’m having trouble getting Revise to track changes to my module. I have using Revise
in my startup.jl, and I’ve checked that it is indeed being loaded on startup. I then try:
(v1.1) pkg> generate MyPackage
Generating project MyPackage:
MyPackage/Project.toml
MyPackage/src/MyPackage.jl
(v1.1) pkg> dev MyPackage
[ Info: resolving package specifier `MyPackage` as a directory at `~/Desktop/MyPackage`.
Resolving package versions...
Updating `~/.julia/environments/v1.1/Project.toml`
[79904e14] + MyPackage v0.1.0 [`../../../Desktop/MyPackage`]
Updating `~/.julia/environments/v1.1/Manifest.toml`
[79904e14] + MyPackage v0.1.0 [`../../../Desktop/MyPackage`]
julia> using MyPackage
[ Info: Precompiling MyPackage [79904e14-be3a-11e9-0fa2-d3186fc9e44a]
julia> MyPackage.greet()
Hello World!
At this point, I edit MyPackage.jl to add a function foo
. Then:
julia> MyPackage.foo()
ERROR: UndefVarError: foo not defined
Stacktrace:
[1] getproperty(::Module, ::Symbol) at ./sysimg.jl:13
[2] top-level scope at none:0
julia> revise(MyPackage)
true
julia> MyPackage.foo()
ERROR: UndefVarError: foo not defined
Stacktrace:
[1] getproperty(::Module, ::Symbol) at ./sysimg.jl:13
[2] top-level scope at none:0
Most likely Revise
is not looking in ~/Desktop/MyPackage
, where you generated your package. You can push it to your LOAD_PATH
using push!(LOAD_PATH, expanduser("~/Desktop/"))
.
After reading from several sources, it seems like the recommended option is to develop in ~/.julia/dev
. This is what I have included in my ~/.julia/config/startup.jl
file, so that I can generate a package and use Revise
every time I start Julia automatically:
push!(LOAD_PATH, expanduser("~/.julia/dev/"))
atreplinit() do repl
try
@eval using Revise
@async Revise.wait_steal_repl_backend()
catch
@warn "Package Revise not found"
end
end
Hmm I tried adding push!(LOAD_PATH, expanduser("~/Desktop/"))
to startup.jl (before using Revise
, in case that matters) and it still doesn’t seem to work:
julia> LOAD_PATH
4-element Array{String,1}:
"@"
"@v#.#"
"@stdlib"
"/Users/pearl/Desktop/"
(v1.1) pkg> dev MyPackage
[ Info: resolving package specifier `MyPackage` as a directory at `~/Desktop/MyPackage`.
Resolving package versions...
Updating `~/.julia/environments/v1.1/Project.toml`
[no changes]
Updating `~/.julia/environments/v1.1/Manifest.toml`
[no changes]
julia> using MyPackage
[ Info: Recompiling stale cache file /Users/pearl/.julia/compiled/v1.1/MyPackage/zIxTC.ji for MyPackage [79904e14-be3a-11e9-0fa2-d3186fc9e44a]
julia> MyPackage.foo()
ERROR: UndefVarError: foo not defined
Stacktrace:
[1] getproperty(::Module, ::Symbol) at ./sysimg.jl:13
[2] top-level scope at none:0
Then define foo
:
julia> MyPackage.foo()
ERROR: UndefVarError: foo not defined
Stacktrace:
[1] getproperty(::Module, ::Symbol) at ./sysimg.jl:13
[2] top-level scope at none:0
There should be no need to modify LOAD_PATH
or explicitly call revise
. Load Revise first, then load your package then it should work.
1 Like
Curiously, it does work for me when I remove using Revise
from startup.jl and call it in the REPL instead. Can anyone else reproduce this problem?
Ah no, I completely missed that, thank you! Would it be possible to make the link to that page on Home · Revise.jl a little more insistent, for those of us who brashly think “I know how to add things to startup.jl”?
1 Like
I think that mentioning the possibility at the very beginning of the docs would help, since this is the configuration almost everyone uses. Perhaps open an issue, or better, make a PR at the Revise.jl repository.
1 Like
I’m not so sure about this. Personally, I like to using Revise
manually as I don’t always need it (and am kind of obsessed about startup times )
But I agree that having this more prominently placed wouldn’t hurt. I remember that I also put using Revise
in my startup.jl
at some point and wondered why it didn’t work as expected.
1 Like