My code unzips a data file, loads it, and deletes the temporary file. It has worked fine in the past but now it fails on the line that deletes the file. It happens in a module I’m working on, ClimateDataIO.jl in ghg_read.jl (line 89). The recent change was switching between DataFrames.readtable
to CSV.read
.
The error can be reproduced on Windows machines by running the module tests, Pkg.test("ClimateDataIO")
.
rm(temp)
ERROR: LoadError: unlink: operation not permitted (EPERM)
Stacktrace:
[1] uv_error at .\libuv.jl:68 [inlined]
[2] unlink(::String) at .\file.jl:500
[3] #rm#7(::Bool, ::Bool, ::Function, ::String) at .\file.jl:145
[4] #ghg_read#4(::Bool, ::Function, ::String) at C:\Users\JohnDoe\.julia\v0.6\ClimateDataIO\src\ghg_read.jl:89
[5] (::ClimateDataIO.#kw##ghg_read)(::Array{Any,1}, ::ClimateDataIO.#ghg_read, ::String) at .\<missing>:0
[6] include_from_node1(::String) at .\loading.jl:569
[7] include(::String) at .\sysimg.jl:14
[8] process_options(::Base.JLOptions) at .\client.jl:305
[9] _start() at .\client.jl:371
while loading C:\Users\JohnDoe\.julia\v0.6\ClimateDataIO\test\runtests.jl, in expression starting on line 275
It’s not a problem in Linux/Mac but I’ve confirmed the problem on two different Windows machines. It runs successfully in Coveralls and Codecov.
Calling rm
on the same file in REPL works fine. My guess was that the file wasn’t closing properly until the test failed. The code looks fine, as far as I can tell I’ve closed the file every time I’ve opened it. What is wrong here?