1

I'm running a small Julia program using PyPlot in Juliabox (IJulia Notebook) but it's errors out with an error mesg as listed below. I not sure if it's trying to use my machine's disk to write to but I have valid R+W access there. Basically I'm trying out the examples as mentioned here: https://www.juliabox.org/notebooks/tutorial/Plotting%20in%20Julia.ipynb#

LoadError: unlink: read-only file system (EROFS)

Pkg.add("PyPlot")
using PyPlot

for i = 1.0:300.0
    for j = 1.0+i:250.0, k=1.0:10
        plot(i+j, i*k/j, color="red", linewidth=1.0, linestyle="--")
        i += 0.1
        j += 0.05
        k += 0.01
    end
end

Error log:

INFO: Nothing to be done
INFO: Precompiling module PyPlot...
INFO: Recompiling stale cache file /opt/julia_packages/.julia/lib/v0.4/Compat.ji for module Compat.
ERROR: LoadError: 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
 in include at ./boot.jl:261
 in include_from_node1 at ./loading.jl:304
 [inlined code] from none:2
 in anonymous at no file:0
 in process_options at ./client.jl:257
 in _start at ./client.jl:378
while loading /home/juser/.julia/v0.4/PyCall/src/PyCall.jl, in expression starting on line 26
ERROR: LoadError: Failed to precompile PyCall to /home/juser/.julia/lib/v0.4/PyCall.ji
 in error at ./error.jl:21
 in compilecache at loading.jl:384
 in require at ./loading.jl:224
 in include at ./boot.jl:261
 in include_from_node1 at ./loading.jl:304
 [inlined code] from none:2
 in anonymous at no file:0
 in process_options at ./client.jl:257
 in _start at ./client.jl:378
while loading /home/juser/.julia/v0.4/PyPlot/src/PyPlot.jl, in expression starting on line 5

LoadError: Failed to precompile PyPlot to /home/juser/.julia/lib/v0.4/PyPlot.ji
while loading In[10], in expression starting on line 2

 in error at ./error.jl:21
 in compilecache at loading.jl:384
 in require at ./loading.jl:250

If I use 0.3.12 version (IJulia Notebook), then it compiles and shows INFO: Nothing to be done but doesn't show anything as output (some graphics plot diagram etc).

AKS
  • 16,482
  • 43
  • 166
  • 258

1 Answers1

0

Thanks to ali_m. Here's the main summary on what that post says.

The problem seems to be that JuliaBox ships some precompiled cache files in a read-only directory /opt/julia_packages/.julia/lib/v0.4. If at some point it detects that the cache is stale and tries to recompile it, it fails.

This needs to be fixed in Julia itself—it shouldn't try to delete cache files from a read-only directory when recompiling.

Issue link is https://github.com/JuliaLang/julia/issues/14368

To resolve it only in 0.4.2, one can use (this will remove the 3rd index value from Base.LOAD_CACHE_PATH array/set/tuple) to your .juliarc file on JuliaBox to remove the read-only cache directory from the search path. Or just run this manually before typing using Compat etc to rebuild the cache without using the read-only search path.

splice!(Base.LOAD_CACHE_PATH, 3)

A nice example of splice! function (PS: A function in Julia which ends with ! with its names means, that function will not only do its work but also will change its arguments data/value).

# Remove elements from an array by index with splice!
arr = [3,4,5]
splice!(arr,2) # => 4 ; arr is now [3,5]

The suggested workaround works for 0.4.2 (using echo 'splice!(Base.LOAD_CACHE_PATH, 3)' > ~/.juliarc.jl to insert the line into juliarc) but apparently LOAD_CACHE_PATH isn't defined while launching Julia 0.3.12 so this would fail there.

Adding the following line in the same file fixed this issue (adding a condition to work when version in Julia is 0.4 or above). I didn't see this issue in the 0.5 development version so we are good there.

VERSION >= v"0.4" && splice!(Base.LOAD_CACHE_PATH, 3)
AKS
  • 16,482
  • 43
  • 166
  • 258