World age error using urldownload to read a zip file

I am getting a world age error when using urldownload (from package UrlDownload). Does anybody know why this might happen?

Here’s the error message:

‘’’
Info: tmp
ERROR: LoadError: MethodError: no method matching eof(::ZipFile.ReadableFile)
The applicable method may be too new: running in world age 27826, while current world is 27828.
Closest candidates are:
eof(::ZipFile.ReadableFile) at /home/brian/.julia/packages/ZipFile/fdYkP/src/ZipFile.jl:533 (method too new to be called from this world context.)
eof(::Base64.Base64DecodePipe) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/Base64/src/decode.jl:126
eof(::IOStream) at iostream.jl:223

Stacktrace:
[1] readbytes!(::ZipFile.ReadableFile, ::Array{UInt8,1}, ::Int64) at ./io.jl:917
[2] read at ./io.jl:941 [inlined]
[3] read at ./io.jl:940 [inlined]
[4] read(::ZipFile.ReadableFile, ::Type{String}) at ./io.jl:945
[5] downloadcatalogs(::String) at /home/brian/repos/Raytracer/GlassCat/src/InitializeGlass.jl:24
[6] top-level scope at /home/brian/repos/Raytracer/GlassCat/src/InitializeGlass.jl:34
[7] include(::Function, ::Module, ::String) at ./Base.jl:380
[8] include(::Module, ::String) at ./Base.jl:368
[9] exec_options(::Base.JLOptions) at ./client.jl:296
[10] _start() at ./client.jl:506
in expression starting at /home/brian/repos/Raytracer/GlassCat/src/InitializeGlass.jl:34
‘’’

and here’s the function

module InitializeGlass
using UrlDownload

function downloadcatalogs(glassdirectory::String)
    catalogs = ("https://www.nikon.com/products/optical-glass/assets/pdf/nikon_zemax_data.zip", 
    "https://www.oharacorp.com/xls/OHARA_201130_CATALOG.zip", 
    "https://hoyaoptics.com/wp-content/uploads/2019/10/HOYA20170401.zip")

    getzip(url)  = urldownload(url,compress = :zip, parser = identity)

    @info glassdirectory

    for url in catalogs
        # try
            zipcat = getzip(url)
            filename = replace(zipcat.name, r"""[ ,.:;?!()&-]""" => "_")
            filename = replace(filename, "_agf" => ".agf")
            filename = replace(filename, "_AGF" => ".agf")
            temp = read(zipcat,String)
            catname = joinpath(glassdirectory,filename)
            @info "writing $catname"
            write(joinpath(glassdirectory,filename),temp)
        # catch err
        #     continue #if download fails for any reason continue to the next catalog
        # end     
    end
end

downloadcatalogs(ARGS[1])

end #module

I wasn’t able to reproduce the error. I guess because you have some private package or perhaps a Julia file, where this function is defined. This may be something important for this error to come.

What I did and what worked well, is copy&pasting the following code into a clean REPL. I replicate your code her for others because of the broken formating in your post:

using UrlDownload
using ZipFile

function downloadcatalogs(glassdirectory::String)
	catalogs = ("https://www.nikon.com/products/optical-glass/assets/pdf/nikon_zemax_data.zip",
	"https://www.oharacorp.com/xls/OHARA_201130_CATALOG.zip",
	"https://hoyaoptics.com/wp-content/uploads/2019/10/HOYA20170401.zip")
	
	getzip(url)  = urldownload(url,compress = :zip, parser = identity)
	
	for url in catalogs
		# try
			zipcat = getzip(url)
			filename = replace(zipcat.name, r"""[ ,.:;?!()&-]""" => "_")
			filename = replace(filename, "_agf" => ".agf")
			filename = replace(filename, "_AGF" => ".agf")
			temp = read(zipcat,String)
			catname = joinpath(glassdirectory,filename)
			@info "writing $catname"
			write(joinpath(glassdirectory,filename),temp)
		# catch err
		#     continue #if download fails for any reason continue to the next catalog
		# end     
	end
end

cd("c:\\Temp")
downloadcatalogs(".")

This brought me 3 new files in my Windows (10) folder under C:\Temp\

Sorry about the formatting error. I edited the original to correct this.

I intended this file to be used as a command line script that I would call like this:

julia “src/InitializeGlass.jl” “directory to put glass files”

This is what gives me the world age error. The error occurs when executing the final line in the file:

downloadcatalogs(ARGS[1])

Thank you for this info, I have opened issue World Age issue · Issue #33 · Arkoniak/UrlDownload.jl · GitHub.

Currently, as a workaround, you can just add using ZipFile at the beginning of the file, i.e. it should start with

module InitializeGlass
using ZipFile
using UrlDownload

2 Likes

Thank you. Your workaround solved the problem.

1 Like