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

precompile shouldn't try to overwrite stale read-only cache files #14368

Closed
stevengj opened this issue Dec 11, 2015 · 10 comments
Closed

precompile shouldn't try to overwrite stale read-only cache files #14368

stevengj opened this issue Dec 11, 2015 · 10 comments
Labels
bug Indicates an unexpected problem or unintended behavior compiler:precompilation Precompilation of modules

Comments

@stevengj
Copy link
Member

A lot of people are seeing failures on JuliaBox (JuliaCloud/JuliaBox#338, JuliaPy/PyPlot.jl#185, JuliaLang/IJulia.jl#159) because JuliaBox ships precompiled cache files in a read-only directory /opt/julia_packages/.julia/lib/v0.4/. If these cache files are stale, Julia tries to recompile them, but it begins by trying to delete the stale old cache file, which throws an exception, e.g.

julia> using Compat                                                                                                                                                
INFO: Recompiling stale cache file /opt/julia_packages/.julia/lib/v0.4/Compat.ji for module Compat.                                                                
ERROR: unlink: read-only file system (EROFS)                                                                                                                       
 in unlink at fs.jl:102                                                                                                                                            
 in rm at file.jl:59                                                                                                                                               
 in create_expr_cache at loading.jl:330                                                                                                                            
 in recompile_stale at loading.jl:461                                                                                                                              
 in _require_from_serialized at loading.jl:83                                                                                                                      
 in _require_from_serialized at ./loading.jl:109                                                                                                                   
 in require at ./loading.jl:219 
@stevengj stevengj added the compiler:precompilation Precompilation of modules label Dec 11, 2015
@stevengj
Copy link
Member Author

This seems to have been partially worked around in #14145 by @eschnett, but it looks like it will still try to write to the read-only location.

@stevengj stevengj changed the title precompile shouldn't try to delete stale read-only cache files precompile shouldn't try to overwrite stale read-only cache files Dec 11, 2015
@stevengj
Copy link
Member Author

Probably the recompile_stale function should call create_expr_cache(path, joinpath(Base.LOAD_CACHE_PATH[1], basename(cachefile))) so that the new cache file is always created in the default location (the head of the path), not where the old cache file was found.

@stevengj stevengj added the bug Indicates an unexpected problem or unintended behavior label Dec 11, 2015
@tanmaykm
Copy link
Member

Would it be better to just check for write permissions and skip updating the cache file if it is readonly? It seems to fall back to the default location Base.LOAD_CACHE_PATH[1] in that case.

I tried with the following change in loading.jl.

function recompile_stale(mod, cachefile)
    if ((stat(cachefile).mode & 0o222) == 0)
        warn("could not remove stale cache file $cachefile")
        return
    end
...
end

@eschnett
Copy link
Contributor

Checking file permissions isn't a reliable way to determine whether a file can be deleted. For example, in Unix you need write permissions to the directory, and on a network file system or with access control lists, it's up to the file server anyway. It is usually easier to just try to delete the file, and check the error condition afterwards.

@tanmaykm
Copy link
Member

Ah yes. So, then may be a try...catch?

@stevengj
Copy link
Member Author

Even if it is writable, I don't think we should be writing new cache files to arbitrary locations in the path. I think it is better to always write new files to Base.LOAD_CACHE_PATH[1], which will normally be in ~/.julia/lib. (See #14369.)

e.g. if someone ships me a .ji file that I stick into a directory somewhere, I don't think that Julia should overwrite it even if it is in the path — I want my files touched only if I specifically request it; it is more desirable if all of our writing is confined to .julia. Writing automatically to the filesystem should be viewed as a dangerous, undesirable activity that should be confined to as few well-defined directories as possible.

@tanmaykm
Copy link
Member

Ok, yes that sounds reasonable.

@jonasaugust
Copy link
Contributor

I'm also getting the "read-only file system" error when trying to add PyPlot to my JuliaBox instance with kernel 0.4.2. Although this issue has been closed in December... I'm guessing it hasn't been installed to the JuliaBox server yet. How/when does that happen, and how would we come to know it when it does?
(And, of course, thanks for all your work on Julia!)

@tkelman
Copy link
Contributor

tkelman commented Jan 22, 2016

#14369 was backported to 0.4.3, so juliabox should just need an upgrade to that.

@jonasaugust
Copy link
Contributor

@tkelman Thanks for making it clearer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior compiler:precompilation Precompilation of modules
Projects
None yet
Development

No branches or pull requests

5 participants