JuliaIO / JSON.jl

JSON parsing and printing
Other
313 stars 101 forks source link

parsefile: Windows unlink permission denied #347

Open AnHeuermann opened 2 years ago

AnHeuermann commented 2 years ago

Description

On Windows I get an IOError when deleting a JSON file I previously parsed with JSON.parsefile. Similar to https://github.com/JuliaIO/JSON.jl/pull/64 calling gc() solves the issue for me.

On Linux I have no such problems.

How to reproduce

using JSON

jsonFile = "test.json"
open(jsonFile, "w") do io
  write(io,
  """
  {
    "Hello": "World!"
  }
  """)
end;

infoFile = JSON.parsefile(jsonFile)
#GC.gc()    # <-- Solves issue

rm(jsonFile)
@info "Success"
ERROR: IOError: unlink("test.json"): permission denied (EACCES)     
Stacktrace:
 [1] uv_error
   @ .\libuv.jl:97 [inlined]
 [2] unlink(p::String)
   @ Base.Filesystem .\file.jl:958
 [3] rm(path::String; force::Bool, recursive::Bool)
   @ Base.Filesystem .\file.jl:276
 [4] rm(path::String)
   @ Base.Filesystem .\file.jl:267
 [5] top-level scope
   @ path\to\bug.jl:17

Versions