Hi all, I’m new to Julia but “old” regarding software development.
I’m trying to add the package BlackBoxOptim for some Julia code, but I’m having problems finding a shared C library file, “libmbedtls.so”. As far as I’m aware, the BlackBoxOptim Julia package, has a set of dependencies, one of them, MBed TLS, is the source of the missing shared C library.
I’m running Julia in a new and untouched Conda environment. It is a clean box. I added BlackBoxOptim to the julia package manager (I’m new to Julia - forgive any use of incorrect terms), but on importing the package - which pre-compiles it - I see the error:
julia> import BlackBoxOptim
[ Info: Precompiling BlackBoxOptim [a134a8b2-14d6-55f6-9291-3336d3ab0209]
ERROR: LoadError: InitError: could not load library “libmbedtls.so”
libmbedx509.so.4: cannot open shared object file: No such file or directory
Stacktrace:
[1] dlopen(s::String, flags::UInt32; throw_error::Bool)
Did you install Julia via conda-forge? If so, from which channel? Is this on Linux?
If so, please raise this as an issue on the julia-feedstock. I am personally trying to maintain this but navigating the line between Julia and conda-forge is a bit tricky.
In particular we are trying to use mbedTLS from conda-forge: USE_SYSTEM_MBEDTLS=1.
I believe there is an issue with the configuration of the Julia standard library MbedTLS_jll.jl which must be done at build time.
The short term fix is to download Julia directly from julialang.org or to use juliaup.
A hacky fix is to manually locate the library and its dependencies in the the conda environment and manually load them via Libdl.dlopen in the correct order.
I see! Thanks so much for your feedback. It’s very helpful.
Yes, this is Ubuntu Linux (well, strictly, it’s WSL2), and I installed Julia using Conda via the conda-forge channel.
If I understand you correctly, the robust solution would be to delete this Conda environment, start a new one (so it’s a clean box), and use a downloaded version of Julia from the website rather than what Conda provides.
(1) Removing my old conda environment.
(2) Making a new conda (virtual environment).
(3) Installed Juliaup following the curl installation commandline.
(4) Reinitialised (exited and entered) my environment.
(5) Loaded Julia on the prompt.
(6) add BlackBoxOptim
Regarding your last question. I’m using Conda to keep environments separate as I’m working across multiple languages and various projects, each with its own dependencies.
Yes, I understand why you are using conda. However, I’m trying to communicate that Julia is not going to respect your virtual environment boundaries out of the box. Additionally, Julia has its own environment and package system.
You will notice that Julia has created a depot outside of your $CONDA_PREFIX at ~/.julia. Basically, Julia knows nothing about your conda “virtual environment”.
You can address this partially by manually installing an activate script to let Julia operate within the prefix. For an example, see the following script.
Note that the conda-forge packaging is not an official packaging by the Julia project. At the moment it is a best effort exercise by me and and ngam. Volunteers are needed to help with this effort.