Alexander-Barth / NCDatasets.jl

Load and create NetCDF files in Julia
MIT License
146 stars 31 forks source link

Problems installing on Julia 1.8.5 #202

Closed amarux closed 1 year ago

amarux commented 1 year ago

I found problems to install NCDatasets in a fresh installation of Julia 1.8.5 on Ubuntu 22.04.

lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04 LTS
Release:    22.04
Codename:   jammy

I downloaded Julia from the official website (https://julialang.org/downloads/).

To install the package I used Pkg.add("NCDatasets") and it resulted in the following message:

Resolving package versions...
   Installed OpenSSL_jll ── v1.1.19+0
   Installed Libiconv_jll ─ v1.16.1+2
   Installed XML2_jll ───── v2.10.3+0
   Installed NetCDF_jll ─── v400.902.5+1
   Installed CFTime ─────── v0.1.2
   Installed HDF5_jll ───── v1.12.2+2
   Installed NCDatasets ─── v0.12.12
  Downloaded artifact: XML2
  Downloaded artifact: OpenSSL
  Downloaded artifact: Libiconv
  Downloaded artifact: NetCDF
  Downloaded artifact: HDF5
    Updating `~/.julia/environments/v1.8/Project.toml`
  [85f8d34a] + NCDatasets v0.12.12
    Updating `~/.julia/environments/v1.8/Manifest.toml`
  [179af706] + CFTime v0.1.2
  [85f8d34a] + NCDatasets v0.12.12
  [0234f1f7] + HDF5_jll v1.12.2+2
  [94ce4f54] + Libiconv_jll v1.16.1+2
  [7243133f] + NetCDF_jll v400.902.5+1
  [458c3c95] + OpenSSL_jll v1.1.19+0
  [02c8fc9c] + XML2_jll v2.10.3+0
Precompiling project...
  ✗ NCDatasets
  6 dependencies successfully precompiled in 5 seconds. 72 already precompiled.
  1 dependency errored. To see a full report either run `import Pkg; Pkg.precompile()` or load the package

Then, I used Pkg.precompile() as indicated above that leads to this message:

Precompiling project...
  ✗ NCDatasets
  0 dependencies successfully precompiled in 3 seconds. 78 already precompiled.

ERROR: The following 1 direct dependency failed to precompile:

NCDatasets [85f8d34a-cbdd-5861-8df4-14fed0d494ab]

Failed to precompile NCDatasets [85f8d34a-cbdd-5861-8df4-14fed0d494ab] to /home/amarquez/.julia/compiled/v1.8/NCDatasets/jl_kswU9L.
ERROR: LoadError: InitError: could not load library "/home/amarquez/.julia/artifacts/461703969206dd426cc6b4d99f69f6ffab2a9779/lib/libnetcdf.so"
/usr/lib/x86_64-linux-gnu/libcurl.so: version `CURL_4' not found (required by /home/amarquez/.julia/artifacts/461703969206dd426cc6b4d99f69f6ffab2a9779/lib/libnetcdf.so)
Stacktrace:
  [1] dlopen(s::String, flags::UInt32; throw_error::Bool)
    @ Base.Libc.Libdl ./libdl.jl:117
  [2] dlopen(s::String, flags::UInt32)
    @ Base.Libc.Libdl ./libdl.jl:116
  [3] macro expansion
    @ ~/.julia/packages/JLLWrappers/QpMQW/src/products/library_generators.jl:54 [inlined]
  [4] __init__()
    @ NetCDF_jll ~/.julia/packages/NetCDF_jll/BYHmI/src/wrappers/x86_64-linux-gnu.jl:12
  [5] _include_from_serialized(pkg::Base.PkgId, path::String, depmods::Vector{Any})
    @ Base ./loading.jl:831
  [6] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String, build_id::UInt64)
    @ Base ./loading.jl:1039
  [7] _require(pkg::Base.PkgId)
    @ Base ./loading.jl:1315
  [8] _require_prelocked(uuidkey::Base.PkgId)
    @ Base ./loading.jl:1200
  [9] macro expansion
    @ ./loading.jl:1180 [inlined]
 [10] macro expansion
    @ ./lock.jl:223 [inlined]
 [11] require(into::Module, mod::Symbol)
    @ Base ./loading.jl:1144
 [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
during initialization of module NetCDF_jll
in expression starting at /home/amarquez/.julia/packages/NCDatasets/gTGnf/src/NCDatasets.jl:1
in expression starting at stdin:1
Stacktrace:
 [1] pkgerror(msg::String)
   @ Pkg.Types /opt/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/julia-1.8.5/share/julia/stdlib/v1.8/Pkg/src/API.jl:1435
 [3] precompile
   @ /opt/julia-1.8.5/share/julia/stdlib/v1.8/Pkg/src/API.jl:1072 [inlined]
 [4] #precompile#225
   @ /opt/julia-1.8.5/share/julia/stdlib/v1.8/Pkg/src/API.jl:1071 [inlined]
 [5] precompile (repeats 2 times)
   @ /opt/julia-1.8.5/share/julia/stdlib/v1.8/Pkg/src/API.jl:1071 [inlined]
 [6] top-level scope
   @ REPL[10]:1

As the error is related to the libnetcdf library, I tried to install it using conda, but it does not solve the problem. Could you suggest me a way to fix this issue?

Thank you very much

Alexander-Barth commented 1 year ago

Have you seen this issue? https://github.com/Alexander-Barth/NCDatasets.jl/issues/191

What is the output of the shell command echo $LD_LIBRARY_PATH and echo $LD_PRELOAD. And the julia command versioninfo() ?

amarux commented 1 year ago

I took a look at #191. So, I followed your suggestions and ran the following commands in the Linux terminal:

LD_LIBRARY_PATH=
LD_PRELOAD=
julia

Then, I was able to use NCDatasets without any problem.

In my case the output of


* Julia `sessioninfo()`

Julia Version 1.8.5 Commit 17cfb8e65ea (2023-01-08 06:45 UTC) Platform Info: OS: Linux (x86_64-linux-gnu) CPU: 4 × Intel(R) Core(TM) i3-5010U CPU @ 2.10GHz WORD_SIZE: 64 LIBM: libopenlibm LLVM: libLLVM-13.0.1 (ORCJIT, broadwell) Threads: 4 on 4 virtual cores Environment: LD_LIBRARY_PATH = :/usr/lib/x86_64-linux-gnu/ JULIA_NUM_THREADS = 4



Finally, I checked my .bashrc file. I had added a line defining the LD_LIBRARY_PATH (I do not remember why).
I commented that line in my .bashrc, and now NCDatasets works perfect.

If I required LD_LIBRARY_PATH in the future I will try to found an alternative solution than to define it in the .bashrc. By now, removing it solved the issue with NCDatasets. 

Thank you so much!
Alexander-Barth commented 1 year ago

Thank you for your confirmation! Maybe someone should write a blog post "LD_LIBRARY_PATH considered hamful"... Oh actually, I just found out there is already one :-).

(I updated the "known issue" section of the documentation).