# World age error using urldownload to read a zip file

**URL:** <https://discourse.julialang.org/t/world-age-error-using-urldownload-to-read-a-zip-file/56111>\
**Category:** Data\
**Tags:** zip\
**Created:** [February 26, 2021, 6:57pm UTC](https://discourse.julialang.org/t/world-age-error-using-urldownload-to-read-a-zip-file/56111 "2021-02-26T18:57:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![brianguenter](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brianguenter/32/29519_2.png) [@brianguenter](https://discourse.julialang.org/u/brianguenter)\
**Post date:** [February 26, 2021, 6:57pm UTC](https://discourse.julialang.org/t/world-age-error-using-urldownload-to-read-a-zip-file/56111/1 "2021-02-26T18:57:51Z")

</div>

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

```julia
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

```

---

<div class="post-metadata">

**Author:** ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)\
**Post date:** [February 26, 2021, 7:27pm UTC](https://discourse.julialang.org/t/world-age-error-using-urldownload-to-read-a-zip-file/56111/2 "2021-02-26T19:27:51Z")

</div>

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:

```julia
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\

---

<div class="post-metadata">

**Author:** ![brianguenter](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brianguenter/32/29519_2.png) [@brianguenter](https://discourse.julialang.org/u/brianguenter)\
**Post date:** [February 26, 2021, 8:04pm UTC](https://discourse.julialang.org/t/world-age-error-using-urldownload-to-read-a-zip-file/56111/3 "2021-02-26T20:04:09Z")

</div>

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:

```julia
downloadcatalogs(ARGS[1])

```

---

<div class="post-metadata">

**Author:** ![Skoffer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/skoffer/32/378_2.png) [@Skoffer](https://discourse.julialang.org/u/Skoffer)\
**Post date:** [February 26, 2021, 10:32pm UTC](https://discourse.julialang.org/t/world-age-error-using-urldownload-to-read-a-zip-file/56111/4 "2021-02-26T22:32:08Z")

</div>

Thank you for this info, I have opened issue [World Age issue · Issue #33 · Arkoniak/UrlDownload.jl · GitHub](https://github.com/Arkoniak/UrlDownload.jl/issues/33).

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

```julia
module InitializeGlass
using ZipFile
using UrlDownload

```

---

<div class="post-metadata">

**Author:** ![brianguenter](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brianguenter/32/29519_2.png) [@brianguenter](https://discourse.julialang.org/u/brianguenter)\
**Post date:** [February 26, 2021, 11:12pm UTC](https://discourse.julialang.org/t/world-age-error-using-urldownload-to-read-a-zip-file/56111/5 "2021-02-26T23:12:23Z")

</div>

Thank you. Your workaround solved the problem.
