Skip to content

parsefile: Windows unlink permission denied #347

@AnHeuermann

Description

@AnHeuermann

Description

On Windows I get an IOError when deleting a JSON file I previously parsed with JSON.parsefile.
Similar to #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

  • JSON.jl: [682c06a0] JSON v0.21.3
  • Julia Version 1.7.1
    Commit ac5cc99908 (2021-12-22 19:35 UTC)
    Platform Info:
    OS: Windows (x86_64-w64-mingw32)
    CPU: Intel(R) Core(TM) i7-10700KF CPU @ 3.80GHz
    WORD_SIZE: 64
    LIBM: libopenlibm
    LLVM: libLLVM-12.0.1 (ORCJIT, skylake)
    Environment:
    JULIA_CUDA_USE_BINARYBUILDER = false
    JULIA_EDITOR = code
    JULIA_NUM_THREADS =
  • OS: Windows 10

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions