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

FileIO not loading / requiring dependency AVSfldIO properly #353

Closed
JeffFessler opened this issue Dec 4, 2021 · 2 comments
Closed

FileIO not loading / requiring dependency AVSfldIO properly #353

JeffFessler opened this issue Dec 4, 2021 · 2 comments

Comments

@JeffFessler
Copy link
Member

Attempting to read AVSfld format files is failing due (apparently) to FileIO not properly loading the required AVSfldIO package. I thought the magic of require in FileIO would take care of this automatically. I tried the suggested Pkg.instantiate() but that did not help. The only solution I have found is to explicitly add AVSfileIO and invoke it with using but I thought that FileIO was supposed to make that happen behind the scenes without user intervention. It makes me suspect that my original PR #333 for this format was somehow incomplete. Here is a MWE that writes some test data to a .fld file and then attempts to load it.

using FileIO
#using AVSfldIO # Must add this package and uncomment this line for code to work
buf = IOBuffer()
write(buf, "# AVS\n", "ndim=2\n", "dim1=3\n", "dim2=4\n",
    "nspace=2\n", "veclen=1\n", "data=float_le\n", "field=uniform\n",
    '\f', '\f', Float32.(1:12)) # test data
file = "tmp.fld"
open(file, "w") do io write(io, take!(buf)) end
load(file)

Error encountered while load File{DataFormat{:AVSfld}, String}("tmp.fld").

Fatal error:
ERROR: LoadError: ArgumentError: Package AVSfldIO [b6189060-daf9-4c28-845a-cc0984b81781] is required but does not seem to be installed:
 - Run `Pkg.instantiate()` to install all recorded dependencies.

Stacktrace:
  [1] _require(pkg::Base.PkgId)
    @ Base ./loading.jl:1089
  [2] require(uuidkey::Base.PkgId)
    @ Base ./loading.jl:1013
  [3] #34
    @ ~/.julia/packages/FileIO/FUXWu/src/loadsave.jl:203 [inlined]
  [4] lock(f::FileIO.var"#34#35"{Base.PkgId}, l::ReentrantLock)
    @ Base ./lock.jl:190
  [5] action(::Symbol, ::Vector{Union{Base.PkgId, Module}}, ::Formatted; options::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ FileIO ~/.julia/packages/FileIO/FUXWu/src/loadsave.jl:203

Originally AVSfldIO.jl was under my github site and then we moved it under JulioIO organization. Could that move have made it harder for FileIO to locate? I doubt it, but I am at a loss for why this is not working. Thanks!

@johnnychen94
Copy link
Member

To be clear, FileIO currently does not handle package installation. Thus AVSfldIO must be installed somewhere in the load path to work:

julia> LOAD_PATH
3-element Vector{String}:
 "@" # (IIUC) current project environment
 "@v#.#" # root environment; ~/.julia/environments/v1.7/Project.toml
 "@stdlib"

Pkg.instantiate only works if AVSfldIO is listed as a dependency in Project.toml; so one option is to still keep MIRTio in the Project.toml in JeffFessler/MIRT.jl#108 but does not use using MIRTio explicitly; this guarantees that any environment with MIRT installed has MIRTio available in the load path.

@JeffFessler
Copy link
Member Author

Thanks for the helpful explanation. I misunderstood how magical FileIO is...

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