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

Using JLD in a module, when it's not loaded in Main, causes issues #252

Open
mhauru opened this issue Mar 28, 2019 · 2 comments
Open

Using JLD in a module, when it's not loaded in Main, causes issues #252

mhauru opened this issue Mar 28, 2019 · 2 comments

Comments

@mhauru
Copy link

mhauru commented Mar 28, 2019

When trying write a storage module that would internally use JLD, I ran into the following weird behavior:

julia> using JLD
julia> save("d.jld", "d", Dict("a" => 1.0))

then restart Julia to clear the workspace so that JLD is no longer loaded and go

   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.1.0 (2019-01-21)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> module Mod
       using JLD
       @show typeof(load("d.jld", "d"))
       end
┌ Warning: type JLD.AssociativeWrapper{Core.String,Core.Float64,Base.Dict{Core.String,Core.Float64}} not present in workspace; reconstructing
└ @ JLD ~/.julia/packages/JLD/1BoSz/src/jld_types.jl:703
typeof(load("d.jld", "d")) = getfield(JLD, Symbol("##JLD.AssociativeWrapper{Core.String,Core.Float64,Base.Dict{Core.String,Core.Float64}}#363"))
Main.Mod

This can be fixed by just loading JLD in Main:

julia> using JLD

julia> module Mod
       using JLD
       @show typeof(load("d.jld", "d"))
       end
WARNING: replacing module Mod.
typeof(load("d.jld", "d")) = Dict{String,Float64}
Main.Mod

This seems related to #216, but I lack the understanding to judge whether it's actually a duplicate.

@bienpierre
Copy link

Hello,
Did you find a workaround?
Regards

@mhauru
Copy link
Author

mhauru commented Nov 3, 2022

It's been 3 years, I can't recall at all, sorry.

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

No branches or pull requests

2 participants