qojulia/QuantumOptics.jl

Precompiling fails on Julia 1.8.5

mcasanova1445 opened this issue · 5 comments

julia> versioninfo()
Julia Version 1.8.5
Commit 17cfb8e65e* (2023-01-08 06:45 UTC)
Platform Info:
  OS: macOS (arm64-apple-darwin22.1.0)
  CPU: 8 × Apple M1
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-13.0.1 (ORCJIT, apple-m1)
  Threads: 1 on 4 virtual cores

julia> import Pkg; Pkg.precompile()
Precompiling project...
  ✗ LinearSolve
  ✗ NonlinearSolve
  ✗ OrdinaryDiffEq
  ✗ StochasticDiffEq
  ✗ QuantumOptics
  0 dependencies successfully precompiled in 91 seconds. 154 already precompiled.

ERROR: The following 1 direct dependency failed to precompile:

QuantumOptics [6e0679c1-51ea-5a7c-ac74-d61b76210b0c]

Failed to precompile QuantumOptics [6e0679c1-51ea-5a7c-ac74-d61b76210b0c] to /Users/mc/.julia/compiled/v1.8/QuantumOptics/jl_yTLP8b.
ERROR: LoadError: MethodError: convert(::Type{Union{}}, ::SparseArrays.SparseMatrixCSC{Float64, Int64}) is ambiguous. Candidates:
  convert(T::Type{<:LinearAlgebra.Bidiagonal}, m::AbstractMatrix) in LinearAlgebra at /opt/homebrew/Cellar/julia/1.8.5/share/julia/stdlib/v1.8/LinearAlgebra/src/bidiag.jl:203
  convert(T::Type{<:SparseArrays.AbstractSparseMatrixCSC}, m::AbstractMatrix) in SparseArrays at /opt/homebrew/Cellar/julia/1.8.5/share/julia/stdlib/v1.8/SparseArrays/src/sparsematrix.jl:745
  convert(T::Type{<:LinearAlgebra.SymTridiagonal}, m::SparseArrays.AbstractSparseMatrixCSC) in SparseArrays at /opt/homebrew/Cellar/julia/1.8.5/share/julia/stdlib/v1.8/SparseArrays/src/sparsematrix.jl:749
  convert(T::Type{<:LinearAlgebra.LowerTriangular}, m::SparseArrays.AbstractSparseMatrixCSC) in SparseArrays at /opt/homebrew/Cellar/julia/1.8.5/share/julia/stdlib/v1.8/SparseArrays/src/sparsematrix.jl:753
  convert(T::Type{<:SparseArrays.SparseVector}, m::SparseArrays.AbstractSparseMatrixCSC) in SparseArrays at /opt/homebrew/Cellar/julia/1.8.5/share/julia/stdlib/v1.8/SparseArrays/src/sparsevector.jl:466
  convert(T::Type{<:LinearAlgebra.Tridiagonal}, m::SparseArrays.AbstractSparseMatrixCSC) in SparseArrays at /opt/homebrew/Cellar/julia/1.8.5/share/julia/stdlib/v1.8/SparseArrays/src/sparsematrix.jl:751
  convert(T::Type{<:LinearAlgebra.UpperTriangular}, m::SparseArrays.AbstractSparseMatrixCSC) in SparseArrays at /opt/homebrew/Cellar/julia/1.8.5/share/julia/stdlib/v1.8/SparseArrays/src/sparsematrix.jl:755
  convert(T::Type{<:LinearAlgebra.Diagonal}, m::SparseArrays.AbstractSparseMatrixCSC) in SparseArrays at /opt/homebrew/Cellar/julia/1.8.5/share/julia/stdlib/v1.8/SparseArrays/src/sparsematrix.jl:747
  convert(::Type{Union{}}, a::AbstractArray) in Base at array.jl:618
  convert(::Type{SA}, a::AbstractArray) where SA<:StaticArraysCore.StaticArray in StaticArrays at /Users/mc/.julia/packages/StaticArrays/jA1zK/src/convert.jl:194
  convert(::Type{T}, M::AbstractArray) where T<:OffsetArrays.OffsetArray in OffsetArrays at /Users/mc/.julia/packages/OffsetArrays/TcCEq/src/OffsetArrays.jl:256
  convert(::Type{T}, a::AbstractArray) where T<:Array in Base at array.jl:617
  convert(T::Type{<:BitArray}, a::AbstractArray) in Base at bitarray.jl:580
  convert(::Type{Union{}}, x) in Base at essentials.jl:213
  convert(::Type{T}, obj) where T<:FunctionWrappers.FunctionWrapper in FunctionWrappers at /Users/mc/.julia/packages/FunctionWrappers/Q5cBx/src/FunctionWrappers.jl:113
  convert(::Type{T}, arg) where T<:VecElement in Base at baseext.jl:19
Possible fix, define
  convert(::Type{Union{}}, ::SparseArrays.AbstractSparseMatrixCSC)
Stacktrace:
  [1] Sparspak.SpkSparseSolver.SparseSolver{Int64, Float64}(p::SparseArrays.SparseMatrixCSC{Float64, Int64}, slvr::Sparspak.SpkSparseBase._SparseBase{Int64, Float64}, n::Int64, ma::Int64, na::Int64, mc::Int64, nc::Int64, _inmatrixdone::Bool, _orderdone::Bool, _symbolicdone::Bool, _factordone::Bool, _trisolvedone::Bool, _refinedone::Bool, _condestdone::Bool) (repeats 2 times)
    @ Sparspak.SpkSparseSolver ~/.julia/packages/Sparspak/oqBYl/src/SparseMethod/SpkSparseSolver.jl:18
  [2] Sparspak.SpkSparseSolver.SparseSolver(m::SparseArrays.SparseMatrixCSC{Float64, Int64})
    @ Sparspak.SparseCSCInterface ~/.julia/packages/Sparspak/oqBYl/src/SparseCSCInterface/SparseCSCInterface.jl:189
  [3] sparspaklu(m::SparseArrays.SparseMatrixCSC{Float64, Int64}; factorize::Bool)
    @ Sparspak.SparseCSCInterface ~/.julia/packages/Sparspak/oqBYl/src/SparseCSCInterface/SparseCSCInterface.jl:219
  [4] init_cacheval(#unused#::LinearSolve.SparspakFactorization, A::SparseArrays.SparseMatrixCSC{Float64, Int64}, b::Vector{Float64}, u::Vector{Float64}, Pl::SciMLOperators.IdentityOperator{4}, Pr::SciMLOperators.IdentityOperator{4}, maxiters::Int64, abstol::Float64, reltol::Float64, verbose::Bool, assumptions::LinearSolve.OperatorAssumptions{true})
    @ LinearSolve ~/.julia/packages/LinearSolve/fBayl/src/factorization.jl:514
  [5] init(::SciMLBase.LinearProblem{Nothing, true, SparseArrays.SparseMatrixCSC{Float64, Int64}, Vector{Float64}, SciMLBase.NullParameters, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}}, ::LinearSolve.SparspakFactorization; alias_A::Bool, alias_b::Bool, abstol::Float64, reltol::Float64, maxiters::Int64, verbose::Bool, Pl::SciMLOperators.IdentityOperator{4}, Pr::SciMLOperators.IdentityOperator{4}, assumptions::LinearSolve.OperatorAssumptions{true}, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ LinearSolve ~/.julia/packages/LinearSolve/fBayl/src/common.jl:117
  [6] init(::SciMLBase.LinearProblem{Nothing, true, SparseArrays.SparseMatrixCSC{Float64, Int64}, Vector{Float64}, SciMLBase.NullParameters, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}}, ::LinearSolve.SparspakFactorization)
    @ LinearSolve ~/.julia/packages/LinearSolve/fBayl/src/common.jl:88
  [7] solve(::SciMLBase.LinearProblem{Nothing, true, SparseArrays.SparseMatrixCSC{Float64, Int64}, Vector{Float64}, SciMLBase.NullParameters, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}}, ::LinearSolve.SparspakFactorization; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ LinearSolve ~/.julia/packages/LinearSolve/fBayl/src/common.jl:157
  [8] solve(::SciMLBase.LinearProblem{Nothing, true, SparseArrays.SparseMatrixCSC{Float64, Int64}, Vector{Float64}, SciMLBase.NullParameters, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}}, ::LinearSolve.SparspakFactorization)
    @ LinearSolve ~/.julia/packages/LinearSolve/fBayl/src/common.jl:154
  [9] macro expansion
    @ ~/.julia/packages/LinearSolve/fBayl/src/LinearSolve.jl:102 [inlined]
 [10] top-level scope
    @ ~/.julia/packages/SnoopPrecompile/1XXT1/src/SnoopPrecompile.jl:62
 [11] include
    @ ./Base.jl:419 [inlined]
 [12] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::String)
    @ Base ./loading.jl:1554
 [13] top-level scope
    @ stdin:1
in expression starting at /Users/mc/.julia/packages/LinearSolve/fBayl/src/LinearSolve.jl:1
in expression starting at stdin:1
ERROR: LoadError: Failed to precompile LinearSolve [7ed4a6bd-45f5-4d41-b270-4a48e9bafcae] to /Users/mc/.julia/compiled/v1.8/LinearSolve/jl_PF5UNR.
Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:35
  [2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IO, internal_stdout::IO, keep_loaded_modules::Bool)
    @ Base ./loading.jl:1707
  [3] compilecache
    @ ./loading.jl:1651 [inlined]
  [4] _require(pkg::Base.PkgId)
    @ Base ./loading.jl:1337
  [5] _require_prelocked(uuidkey::Base.PkgId)
    @ Base ./loading.jl:1200
  [6] macro expansion
    @ ./loading.jl:1180 [inlined]
  [7] macro expansion
    @ ./lock.jl:223 [inlined]
  [8] require(into::Module, mod::Symbol)
    @ Base ./loading.jl:1144
  [9] include
    @ ./Base.jl:419 [inlined]
 [10] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::String)
    @ Base ./loading.jl:1554
 [11] top-level scope
    @ stdin:1
in expression starting at /Users/mc/.julia/packages/OrdinaryDiffEq/thWwa/src/OrdinaryDiffEq.jl:1
in expression starting at stdin:1
ERROR: LoadError: Failed to precompile OrdinaryDiffEq [1dea7af3-3e70-54e6-95c3-0bf5283fa5ed] to /Users/mc/.julia/compiled/v1.8/OrdinaryDiffEq/jl_I80rDg.
Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:35
  [2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IO, internal_stdout::IO, keep_loaded_modules::Bool)
    @ Base ./loading.jl:1707
  [3] compilecache
    @ ./loading.jl:1651 [inlined]
  [4] _require(pkg::Base.PkgId)
    @ Base ./loading.jl:1337
  [5] _require_prelocked(uuidkey::Base.PkgId)
    @ Base ./loading.jl:1200
  [6] macro expansion
    @ ./loading.jl:1180 [inlined]
  [7] macro expansion
    @ ./lock.jl:223 [inlined]
  [8] require(into::Module, mod::Symbol)
    @ Base ./loading.jl:1144
  [9] include(mod::Module, _path::String)
    @ Base ./Base.jl:419
 [10] include(x::String)
    @ QuantumOptics.timeevolution ~/.julia/packages/QuantumOptics/eon5P/src/QuantumOptics.jl:18
 [11] top-level scope
    @ ~/.julia/packages/QuantumOptics/eon5P/src/QuantumOptics.jl:21
 [12] include
    @ ./Base.jl:419 [inlined]
 [13] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::Nothing)
    @ Base ./loading.jl:1554
 [14] top-level scope
    @ stdin:1
in expression starting at /Users/mc/.julia/packages/QuantumOptics/eon5P/src/timeevolution_base.jl:4
in expression starting at /Users/mc/.julia/packages/QuantumOptics/eon5P/src/QuantumOptics.jl:1
in expression starting at stdin:1
Stacktrace:
 [1] pkgerror(msg::String)
   @ Pkg.Types /opt/homebrew/Cellar/julia/1.8.5/share/julia/stdlib/v1.8/Pkg/src/Types.jl:67
 [2] precompile(ctx::Pkg.Types.Context, pkgs::Vector{String}; internal_call::Bool, strict::Bool, warn_loaded::Bool, already_instantiated::Bool, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
   @ Pkg.API /opt/homebrew/Cellar/julia/1.8.5/share/julia/stdlib/v1.8/Pkg/src/API.jl:1435
 [3] precompile
   @ /opt/homebrew/Cellar/julia/1.8.5/share/julia/stdlib/v1.8/Pkg/src/API.jl:1072 [inlined]
 [4] #precompile#225
   @ /opt/homebrew/Cellar/julia/1.8.5/share/julia/stdlib/v1.8/Pkg/src/API.jl:1071 [inlined]
 [5] precompile (repeats 2 times)
   @ /opt/homebrew/Cellar/julia/1.8.5/share/julia/stdlib/v1.8/Pkg/src/API.jl:1071 [inlined]
 [6] top-level scope
   @ REPL[4]:1

I could not reproduce it on

julia> versioninfo()
Julia Version 1.8.5
Commit 17cfb8e65ea (2023-01-08 06:45 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 16 × AMD Ryzen 7 1700 Eight-Core Processor
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-13.0.1 (ORCJIT, znver1)
  Threads: 16 on 16 virtual cores

Could you put your code and backtraces in triple backquotes ```, it makes them much easier to read.

It seems you are running on an ARM processor (Apple M1). Could you check if the problem is with a lower level package that QuantumOptics depends on. You can make a new project environment, e.g. in a temporary folder with julia --project=(mktemp -d), add one of the packages that seem to be failing and see whether there is any useful information.

Trying this out on the 1.9 beta could be helpful as well.

Also, are you running this through Rosetta or are you running a native ARM version of julia?

I am running a native ARM version. I tried precompiling LinearSolve in a temporary directory and failed as well. From what they say here SciML/LinearSolve.jl#271 it seems to be a problem of the Julia build. I will try installing Julia with juliaup instead of brew to check if it works.

Did the version from juliaup work ok? If this is a packaging problem with homebrew, I think it would make sense to close this issue. Of course, with enough dev resources we should try to tackle downstream packaging issues, but given the limited workforce we have, it would be best to let the homebrew team figure this one out.

Yes, using the build from juliaup it worked ok! I will now close the issue.