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

Error in multiple environments #205

Closed
cstjean opened this issue Oct 26, 2018 · 6 comments
Closed

Error in multiple environments #205

cstjean opened this issue Oct 26, 2018 · 6 comments

Comments

@cstjean
Copy link
Collaborator

cstjean commented Oct 26, 2018

When I have multiple terminals open in different environments, I frequently get errors of the form

ERROR: /home/cst-jean/.julia/dev/Foo/src/foo.jl is not stored in the source-text cache
Stacktrace:
 [1] error(::String, ::String) at ./error.jl:42
 [2] _read_dependency_src(::IOStream, ::String) at ./loading.jl:1308
 [3] read_dependency_src(::IOStream, ::String) at ./loading.jl:1294
 [4] read_dependency_src(::String, ::String) at ./loading.jl:1315
 [5] read_from_cache(::Revise.FileInfo, ::String) at /home/cst-jean/.julia/packages/Revise/TmjcT/src/pkgs.jl:156
 [6] maybe_parse_from_cache!(::Revise.FileInfo, ::String) at /home/cst-jean/.julia/packages/Revise/TmjcT/src/pkgs.jl:162
 [7] revise_file_now(::String) at /home/cst-jean/.julia/packages/Revise/TmjcT/src/Revise.jl:413
 [8] revise(::REPL.REPLBackend) at /home/cst-jean/.julia/packages/Revise/TmjcT/src/Revise.jl:470
 [9] run_backend(::REPL.REPLBackend) at /home/cst-jean/.julia/packages/Revise/TmjcT/src/Revise.jl:764
 [10] (::getfield(Revise, Symbol("##58#60")){REPL.REPLBackend})() at ./task.jl:259

I can reproduce this consistently, by doing:

  1. Open julia window Write a README #1. using Revise, Foo in the default environment, where Foo is deved
  2. Open julia window More fixes, tests, and polish #2. activate OtherEnv; using Foo. Foo is not deved in this environment (eg. on Foo#master)
  3. Modify Foo's source code
  4. Type anything in window Write a README #1 to trigger Revise
@timholy
Copy link
Owner

timholy commented Oct 31, 2018

Thanks for a great bug report. I'll look into it while also working on #146.

@timholy
Copy link
Owner

timholy commented Dec 30, 2018

So, it turns out this is the same as JuliaLang/julia#27418.

Until that's fixed, the perfect fix here doesn't exist. The only one that would be robust would be to run Revise in "eager-parsing" mode, meaning that for every package you use, it parses the entire cache file immediately rather than waiting until something changes. Except for race conditions between two Julia sessions, that would "free" Revise from depending on the source-text cache.

The downside of such a workaround is that Revise will be a heavier dependency, because it will do a lot more parsing. To prevent the cost from affecting everyone, I can make a switch that you can set in your startup.jl. If you want to experiment with this, try this diff:

diff --git a/src/pkgs.jl b/src/pkgs.jl
index 60c2c16..a51226b 100644
--- a/src/pkgs.jl
+++ b/src/pkgs.jl
@@ -83,6 +83,7 @@ function parse_pkg_files(id::PkgId)
                         # For precompiled packages, we can read the source later (whenever we need it)
                         # from the *.ji cachefile.
                         pkgdata.fileinfos[fname] = FileInfo(mod, path)
+                        maybe_parse_from_cache!(pkgdata, fname)
                         push!(files, fname)
                     end
                     return files

If you like it, a PR to enable it via a switch would be welcome (or I will do it if you ask), e.g., like those here.

@cstjean
Copy link
Collaborator Author

cstjean commented Dec 30, 2018

Thank you. I've changed my workflow to deal with the issue otherwise, so I don't need it at the moment.

@timholy
Copy link
Owner

timholy commented Apr 8, 2019

I'll close this since the best fix is just to fix JuliaLang/julia#27418.

@timholy timholy closed this as completed Apr 8, 2019
@yha
Copy link

yha commented Dec 19, 2019

I'm experiencing a similar issue, though under different circumstances (I haven't looked into consistently reproducing it yet, but my setup is not consistent with that described above).
I am using Julia 1.1.1. Am I correct in understanding that fixing this requires either moving to Julia 1.3 (where JuliaLang/julia#27418 is fixed) or the workaround described here? Or should I file a new issue?

@timholy
Copy link
Owner

timholy commented Dec 20, 2019

This is a won't-fix in Revise (the fix would absolutely cripple Revise for the majority of users), so you'll need to find another workaround.

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

3 participants