Skip to content

Fails to find libopenspecfun.so on NixOS on Julia 1.11.2 #482

Closed as not planned

Description

@NOTtheMessiah
libquadmath.so.0: cannot open shared object file: No such file or directory
Stacktrace:
  [1] dlopen(s::String, flags::UInt32; throw_error::Bool)
    @ Base.Libc.Libdl ./libdl.jl:120
  [2] dlopen(s::String, flags::UInt32)
    @ Base.Libc.Libdl ./libdl.jl:119
  [3] macro expansion
    @ ~/.julia/packages/JLLWrappers/GfYNv/src/products/library_generators.jl:63 [inlined]
  [4] __init__()
    @ OpenSpecFun_jll ~/.julia/packages/OpenSpecFun_jll/4QIOW/src/wrappers/x86_64-linux-gnu-libgfortran5.jl:9
  [5] run_module_init(mod::Module, i::Int64)
    @ Base ./loading.jl:1378
  [6] register_restored_modules(sv::Core.SimpleVector, pkg::Base.PkgId, path::String)
    @ Base ./loading.jl:1366
  [7] _include_from_serialized(pkg::Base.PkgId, path::String, ocachepath::String, depmods::Vector{Any}, ignore_native::Nothing; register::Bool)
    @ Base ./loading.jl:1254
  [8] _include_from_serialized (repeats 2 times)
    @ ./loading.jl:1210 [inlined]
  [9] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String, build_id::UInt128, stalecheck::Bool; reasons::Dict{String, Int64}, DEPOT_PATH::Vector{String})
    @ Base ./loading.jl:2057
 [10] _require(pkg::Base.PkgId, env::String)
    @ Base ./loading.jl:2527
 [11] __require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:2388
 [12] #invoke_in_world#3
    @ ./essentials.jl:1089 [inlined]
 [13] invoke_in_world
    @ ./essentials.jl:1086 [inlined]
 [14] _require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:2375
 [15] macro expansion
    @ ./loading.jl:2314 [inlined]
 [16] macro expansion
    @ ./lock.jl:273 [inlined]
 [17] __require(into::Module, mod::Symbol)
    @ Base ./loading.jl:2271
 [18] #invoke_in_world#3
    @ ./essentials.jl:1089 [inlined]
 [19] invoke_in_world
    @ ./essentials.jl:1086 [inlined]
 [20] require(into::Module, mod::Symbol)
    @ Base ./loading.jl:2260
 [21] include
    @ ./Base.jl:557 [inlined]
 [22] 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, UInt128}}, source::Nothing)
    @ Base ./loading.jl:2881
 [23] top-level scope
    @ stdin:6
during initialization of module OpenSpecFun_jll
in expression starting at ~/.julia/packages/SpecialFunctions/Zijv9/src/SpecialFunctions.jl:1
in expression starting at stdin:6

Current workaround is to use patchelf to point to Julia installation's provided libraries instead of the hardcoded locations

sudo patchelf --replace-needed libgfortran.so.5 $(nix path-info nixpkgs#julia)/lib/julia/libgfortran.so.5 libopenspecfun.so.2.1
sudo patchelf --replace-needed libquadmath.so.0 $(nix path-info nixpkgs#julia)/lib/julia/libquadmath.so.0 libopenspecfun.so.2.1

Activity

  1. vorboyvo commented on Mar 18, 2025

    @vorboyvo

    For this, where are the Julia provided shared objects located?

  2. NOTtheMessiah commented on May 23, 2025

    @NOTtheMessiah
    Author

    The Julia package is in the Nix Store when installed through Nix:
    $ nix path-info nixpkgs#julia returns

    /nix/store/7xn3ln7k3plnw99rqab10v9sd9z2gc24-julia-1.11.5

    The artifacts one needs to patch is spat out by the error message when julia> using SpecialFunctions

    in my case:

    ERROR: LoadError: InitError: could not load library "$HOME/.julia/artifacts/09b351e89a85e07e957194a647765403d4ee1bcb/lib/libopenspecfun.so"
    libgfortran.so.5: cannot open shared object file: No such file or directory
    

    also, my mistake, sudo is not needed to use patchelf. An environment with patchelf can be spun up using nix-shell -p patchelf

  3. dpaetzel commented on Dec 19, 2025

    @dpaetzel

    An alternative workaround (still just a workaround and not a solution imho) is to specify the dependency on SpecialFunctions via Nix (I'm using julia_111 explicitly here, haven't tested other versions—but I had this exact problem on julia_111 just now):

    julia_111.withPackages [ "SpecialFunctions" ]
    

    Presumably because the Nix-Julia connector performs above patching for you.

    Note that this does not mean that you have to manage all Julia packages via Nix, the Nix-managed packages are just “in the global environment” and the stuff installed by ] add … is merged with that as expected.

  4. ViralBShah commented on Oct 30, 2026

    @ViralBShah
    Member

    The issue either has to be addressed in the way Julia is built for NixOS or in Julia's BB infrastructure. It's not specific to this package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions