FileIO not loading / requiring dependency AVSfldIO properly
JeffFessler opened this issue · 2 comments
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!
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.
Thanks for the helpful explanation. I misunderstood how magical FileIO is...