Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in magic function detect_rdata #338

Closed
hendri54 opened this issue Jun 1, 2021 · 4 comments · Fixed by #343
Closed

Error in magic function detect_rdata #338

hendri54 opened this issue Jun 1, 2021 · 4 comments · Fixed by #343

Comments

@hendri54
Copy link

hendri54 commented Jun 1, 2021

Saving a file to pdf resulted in the error:

julia> using CairoMakie, Makie, FileIO
julia> fig = Figure()
julia> ax = Axis(fig)
julia> barplot!(ax, LinRange(1, 1.1, 5); dodge = 1, color = 1)
julia> barplot!(ax, LinRange(2, 2.1, 5); dodge = 2, color = 2)
julia> save("test1.pdf", fig)
┌ Error: There was an error in magic function detect_rdata.
│ Please open an issue at FileIO.jl.
│   exception =
│    EOFError: read end of file
│    Stacktrace:
│      [1] read(s::IOStream, #unused#::Type{UInt8})
│        @ Base ./iostream.jl:399
│      [2] detect_rdata(io::IOStream)
│        @ FileIO ~/.julia/packages/FileIO/3jBq2/src/registry.jl:61
│      [3] match(io::IOStream, magic::Function)
│        @ FileIO ~/.julia/packages/FileIO/3jBq2/src/query.jl:143
│      [4] querysym_all(io::IOStream)
│        @ FileIO ~/.julia/packages/FileIO/3jBq2/src/query.jl:169
│      [5] (::FileIO.var"#5#9"{Symbol})(io::IOStream)
│        @ FileIO ~/.julia/packages/FileIO/3jBq2/src/query.jl:96
│      [6] open(f::FileIO.var"#5#9"{Symbol}, args::String; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
│        @ Base ./io.jl:330
│      [7] open
│        @ ./io.jl:328 [inlined]
│      [8] querysym(filename::String; checkfile::Bool)
│        @ FileIO ~/.julia/packages/FileIO/3jBq2/src/query.jl:93
│      [9] query(filename::String; checkfile::Bool)
│        @ FileIO ~/.julia/packages/FileIO/3jBq2/src/query.jl:76
│     [10] query
│        @ ~/.julia/packages/FileIO/3jBq2/src/query.jl:75 [inlined]
│     [11] save(filename::String, fig::Figure; args::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
│        @ Makie ~/.julia/packages/Makie/Yd637/src/display.jl:221
│     [12] save(filename::String, fig::Figure)
│        @ Makie ~/.julia/packages/Makie/Yd637/src/display.jl:221
│     [13] top-level scope
│        @ REPL[12]:1
│     [14] eval
│        @ ./boot.jl:360 [inlined]
│     [15] eval_user_input(ast::Any, backend::REPL.REPLBackend)
│        @ REPL /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:139
│     [16] repl_backend_loop(backend::REPL.REPLBackend)
│        @ REPL /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:200
│     [17] start_repl_backend(backend::REPL.REPLBackend, consumer::Any)
│        @ REPL /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:185
│     [18] run_repl(repl::REPL.AbstractREPL, consumer::Any; backend_on_current_task::Bool)
│        @ REPL /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:317
│     [19] run_repl(repl::REPL.AbstractREPL, consumer::Any)
│        @ REPL /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:305
│     [20] (::Base.var"#874#876"{Bool, Bool, Bool})(REPL::Module)
│        @ Base ./client.jl:387
│     [21] #invokelatest#2
│        @ ./essentials.jl:708 [inlined]
│     [22] invokelatest
│        @ ./essentials.jl:706 [inlined]
│     [23] run_main_repl(interactive::Bool, quiet::Bool, banner::Bool, history_file::Bool, color_set::Bool)
│        @ Base ./client.jl:372
│     [24] exec_options(opts::Base.JLOptions)
│        @ Base ./client.jl:302
│     [25] _start()
│        @ Base ./client.jl:485
└ @ FileIO ~/.julia/packages/FileIO/3jBq2/src/query.jl:145
┌ Error: There was an error in magic function detect_rdata_single.
│ Please open an issue at FileIO.jl.
│   exception =
│    EOFError: read end of file
│    Stacktrace:
│      [1] read(s::IOStream, #unused#::Type{UInt8})
│        @ Base ./iostream.jl:399
│      [2] detect_rdata_single(io::IOStream)
│        @ FileIO ~/.julia/packages/FileIO/3jBq2/src/registry.jl:75
│      [3] match(io::IOStream, magic::Function)
│        @ FileIO ~/.julia/packages/FileIO/3jBq2/src/query.jl:143
│      [4] querysym_all(io::IOStream)
│        @ FileIO ~/.julia/packages/FileIO/3jBq2/src/query.jl:169
│      [5] (::FileIO.var"#5#9"{Symbol})(io::IOStream)
│        @ FileIO ~/.julia/packages/FileIO/3jBq2/src/query.jl:96
│      [6] open(f::FileIO.var"#5#9"{Symbol}, args::String; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
│        @ Base ./io.jl:330
│      [7] open
│        @ ./io.jl:328 [inlined]
│      [8] querysym(filename::String; checkfile::Bool)
│        @ FileIO ~/.julia/packages/FileIO/3jBq2/src/query.jl:93
│      [9] query(filename::String; checkfile::Bool)
│        @ FileIO ~/.julia/packages/FileIO/3jBq2/src/query.jl:76
│     [10] query
│        @ ~/.julia/packages/FileIO/3jBq2/src/query.jl:75 [inlined]
│     [11] save(filename::String, fig::Figure; args::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
│        @ Makie ~/.julia/packages/Makie/Yd637/src/display.jl:221
│     [12] save(filename::String, fig::Figure)
│        @ Makie ~/.julia/packages/Makie/Yd637/src/display.jl:221
│     [13] top-level scope
│        @ REPL[12]:1
│     [14] eval
│        @ ./boot.jl:360 [inlined]
│     [15] eval_user_input(ast::Any, backend::REPL.REPLBackend)
│        @ REPL /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:139
│     [16] repl_backend_loop(backend::REPL.REPLBackend)
│        @ REPL /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:200
│     [17] start_repl_backend(backend::REPL.REPLBackend, consumer::Any)
│        @ REPL /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:185
│     [18] run_repl(repl::REPL.AbstractREPL, consumer::Any; backend_on_current_task::Bool)
│        @ REPL /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:317
│     [19] run_repl(repl::REPL.AbstractREPL, consumer::Any)
│        @ REPL /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:305
│     [20] (::Base.var"#874#876"{Bool, Bool, Bool})(REPL::Module)
│        @ Base ./client.jl:387
│     [21] #invokelatest#2
│        @ ./essentials.jl:708 [inlined]
│     [22] invokelatest
│        @ ./essentials.jl:706 [inlined]
│     [23] run_main_repl(interactive::Bool, quiet::Bool, banner::Bool, history_file::Bool, color_set::Bool)
│        @ Base ./client.jl:372
│     [24] exec_options(opts::Base.JLOptions)
│        @ Base ./client.jl:302
│     [25] _start()
│        @ Base ./client.jl:485
└ @ FileIO ~/.julia/packages/FileIO/3jBq2/src/query.jl:145
ERROR: MethodError: no method matching format2mime(::Type{DataFormat{:UNKNOWN}})
Closest candidates are:
  format2mime(::Type{DataFormat{:PNG}}) at /Users/lutz/.julia/packages/Makie/Yd637/src/display.jl:182
  format2mime(::Type{DataFormat{:SVG}}) at /Users/lutz/.julia/packages/Makie/Yd637/src/display.jl:183
  format2mime(::Type{DataFormat{:JPEG}}) at /Users/lutz/.julia/packages/Makie/Yd637/src/display.jl:184
  ...
Stacktrace:
 [1] (::Makie.var"#901#902"{Float64, Float64, DataType, Scene})(s::IOStream)
   @ Makie ~/.julia/packages/Makie/Yd637/src/display.jl:248
 [2] open(::Makie.var"#901#902"{Float64, Float64, DataType, Scene}, ::String, ::Vararg{String, N} where N; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
   @ Base ./io.jl:330
 [3] open
   @ ./io.jl:328 [inlined]
 [4] save(file::File{DataFormat{:UNKNOWN}, String}, fig::Figure; resolution::Tuple{Int64, Int64}, pt_per_unit::Float64, px_per_unit::Float64)
   @ Makie ~/.julia/packages/Makie/Yd637/src/display.jl:242
 [5] save(file::File{DataFormat{:UNKNOWN}, String}, fig::Figure)
   @ Makie ~/.julia/packages/Makie/Yd637/src/display.jl:230
 [6] save(filename::String, fig::Figure; args::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
   @ Makie ~/.julia/packages/Makie/Yd637/src/display.jl:221
 [7] save(filename::String, fig::Figure)
   @ Makie ~/.julia/packages/Makie/Yd637/src/display.jl:221
 [8] top-level scope
julia> versioninfo()
Julia Version 1.6.1
Commit 6aaedecc44 (2021-04-23 05:59 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin18.7.0)
  CPU: Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-11.0.1 (ORCJIT, skylake)
Environment:
  JULIA_NUM_THREADS = 8
  JULIA_PKG_DEVDIR = /Users/lutz/Documents/julia
  JULIA_EDITOR = /usr/local/bin/code

(jl_0N7CBO) pkg> st
      Status `/private/var/folders/sh/h134ydrd1gzbtd4qflbl50km0000gn/T/jl_0N7CBO/Project.toml`
  [13f3f980] CairoMakie v0.5.5
  [5789e2e9] FileIO v1.9.0
  [ee78f7c6] Makie v0.13.11
@SimonDanisch
Copy link
Member

Maybe there is a corrupted file at that path?

@hendri54
Copy link
Author

hendri54 commented Jun 1, 2021

Thank you - I think that was the problem.

@hendri54 hendri54 closed this as completed Jun 1, 2021
@ericphanson
Copy link

ran into this today too and Simon pointed me to a corrupt file as well. I think this is actually a FileIO bug though, because it should just overwrite the file, not give a confusing error.

@johnnychen94
Copy link
Member

johnnychen94 commented Jun 19, 2021

I think this is actually a FileIO bug though, because it should just overwrite the file, not give a confusing error.

Right, FileIO can provide a fallback for broken files.

In the meantime, this is also a Makie issue in https://github.com/JuliaPlots/Makie.jl/blob/beb3fcd1e460b3207b933dcfa758d6df7d48db3d/src/display.jl#L218-L222

Either use FileIO.query(filename; checkfile=false) or remove the string version method could probably fix this one.

shell> touch test.png

julia> query("test.png")
┌ Error: There was an error in magic function detect_rdata.
│ Please open an issue at FileIO.jl.
│   exception =
│    EOFError: read end of file

julia> query("test.png"; checkfile=false)
File{DataFormat{:PNG}, String}("/Users/jc/Documents/Julia/FileIO.jl/test.png")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants