Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REPL auto mode not working #42

Closed
getzdan opened this issue Sep 12, 2017 · 11 comments
Closed

REPL auto mode not working #42

getzdan opened this issue Sep 12, 2017 · 11 comments

Comments

@getzdan
Copy link

getzdan commented Sep 12, 2017

Can't get automatic revise() calls from the REPL to work.

The following is a M(not)WE:

test_revise.jl

using Revise

include("./test_module.jl")
using ReviseTestModule

Revise.track(ReviseTestModule, joinpath(dirname(Base.source_path()),"test_module.jl"))

test_module.jl

module ReviseTestModule
export testfunc
testfunc(x) = x^2 + 1
end

And the REPL session (with version info embedded)

               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: https://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.7.0-DEV.1257 (2017-08-06 00:04 UTC)
 _/ |\__'_|_|_|\__'_|  |  Commit ae17198720* (37 days old master)
|__/                   |  x86_64-linux-gnu

julia> include("test_revise.jl")

julia> testfunc(0)
1
####### changing test_module.jl here to have `testfunc(x) = x^2 + 2`
julia> testfunc(0)    ## should recompile and return 2
1

The Package tests run fine. But, admittedly, it is hard to automatically test an interactive REPL. And as evolutionary bugology dictates this is where bugs will hide. Seems steal_repl_backend() is running alright, but there is both Base.active_repl and Base.active_repl_backend which left me confused. Anybody else seeing this? Is it reproducing? Which versions are afflicted?

@timholy
Copy link
Owner

timholy commented Sep 13, 2017

Works for me. If I take Revise temporarily out of my .juliarc.jl file I can show you:

julia> using Revise

julia> push!(LOAD_PATH, pwd())
3-element Array{Any,1}:
 "/home/tim/src/julia-1.0/usr/local/share/julia/site/v0.7"
 "/home/tim/src/julia-1.0/usr/share/julia/site/v0.7"      
 "/tmp"                                                   

julia> using ReviseTestModule

julia> testfunc(2)
5

# Now go edit ReviseTestModule.jl and save it
julia> testfunc(2)
6

Might the problem be that you didn't name the file according to your module name? I saved your file as ReviseTestModule.jl and it all worked without trouble. I didn't try the alternative, so if this matters to you perhaps you can isolate the problem further?

@getzdan
Copy link
Author

getzdan commented Sep 13, 2017

Changed the name to ReviseTestModule, and used push!(LOADPATH,pwd()) and it still doesn't work automatically. When manually running revise() the function gets redefined as needed. Adding the full versioninfo():

Julia Version 0.7.0-DEV.1257
Commit ae17198720* (2017-08-06 00:04 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: Intel(R) Core(TM) i7-5500U CPU @ 2.40GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.9.1 (ORCJIT, broadwell)

@timholy
Copy link
Owner

timholy commented Sep 13, 2017

Weird. OK, before you say using Revise, is anything else loaded? Can you insert some debugging statements here (e.g., @show dirname latestfiles wf) and see whether anything gets triggered?

@getzdan
Copy link
Author

getzdan commented Sep 13, 2017

Since revise() does get the right files, and I've verified they are watched and detected (by looking at the globals in Revise), my guess is the only problem is the REPL not calling revise() on every input. What version of Julia/Revise is working on your side?

Pkg.status("Revise") is 0.0.8 here.

@getzdan
Copy link
Author

getzdan commented Sep 13, 2017

It started working. Possibly the module filename was the necessary change. I will try reproducing, but if the bug doesn't reproduce, the issue can be closed.

@getzdan
Copy link
Author

getzdan commented Sep 13, 2017

The problem inducing change was the addition of a @show backend.backend_task debug print before and after the assignment to backend_task in steal_repl_backend I added at some point. Link to location: here .

But the issue can be closed, I suppose.

@timholy
Copy link
Owner

timholy commented Sep 13, 2017

OK, thanks for tracking it down!

@timholy timholy closed this as completed Sep 13, 2017
@getzdan
Copy link
Author

getzdan commented Sep 14, 2017

Closed too early. The problem reappeared. I've narrowed it to a simple single line change which causes it.
Again, consider the following files.
TestModule.jl

module TestModule

export testfunc
function testfunc(;param = 20)
  @show param
end

end

and test_revise.jl

using Revise

include("./TestModule.jl")

using TestModule
Revise.track(TestModule, joinpath(dirname(Base.source_path()),"TestModule.jl"))

testfunc()

They produce the problem but only when testfunc() line at the end of test_revise.jl is run. Commenting out this line and the REPL recompilation works as needed. With it, there is no automatic recompilation, but revise() from REPL captures and recompiles the changes.

@getzdan
Copy link
Author

getzdan commented Sep 14, 2017

Update: It isn't related to running the tracked function. Any printout to screen, makes the REPL stealing mechanism fail. In the above example testfunc() at the end of test_revise.jl can be replaced with println("hello") and the problem is still reproduced.

@timholy
Copy link
Owner

timholy commented Sep 15, 2017

@getzdan, thanks so much for persisting with this and coming up with a much clearer picture of what's happening.

There's only one problem: your nicely-reduced test case doesn't behave for me the way it does for you---everything works properly for me. So I can't easily fix this.

I am running 0.6 because DataStructures doesn't build on current 0.7. Can you also reproduce this on 0.6? I see that you provided versioninfo above, here is mine:

julia> versioninfo()
Julia Version 0.6.1-pre.0                                                                                                                                                                                                                    
Commit dcf39a1 (2017-06-19 13:06 UTC)                                                                                                                                                                                                        
Platform Info:                                                                                                                                                                                                                               
  OS: Linux (x86_64-linux-gnu)                                                                                                                                                                                                               
  CPU: Intel(R) Core(TM) i7-5500U CPU @ 2.40GHz                                                                                                                                                                                              
  WORD_SIZE: 64                                                                                                                                                                                                                              
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.9.1 (ORCJIT, broadwell)

Specifically I am running (K)ubuntu 16.04. To me this seems likely to be a libuv bug on your platform, but not sure. Can anyone else reproduce this?

@timholy
Copy link
Owner

timholy commented Oct 8, 2017

I should have thought of this earlier: see #54.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants