# MbedTLS 1.0.2 failed to load on Julia 1.5.2 (solved by downgrading to MbedTLS 0.7.0)

**URL:** <https://discourse.julialang.org/t/mbedtls-1-0-2-failed-to-load-on-julia-1-5-2-solved-by-downgrading-to-mbedtls-0-7-0/47430>\
**Category:** General Usage\
**Tags:** package\
**Created:** [September 28, 2020, 6:32pm UTC](https://discourse.julialang.org/t/mbedtls-1-0-2-failed-to-load-on-julia-1-5-2-solved-by-downgrading-to-mbedtls-0-7-0/47430 "2020-09-28T18:32:22Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![awasserman](https://avatars.discourse-cdn.com/v4/letter/a/9de0a6/32.png) [@awasserman](https://discourse.julialang.org/u/awasserman)\
**Post date:** [September 28, 2020, 6:32pm UTC](https://discourse.julialang.org/t/mbedtls-1-0-2-failed-to-load-on-julia-1-5-2-solved-by-downgrading-to-mbedtls-0-7-0/47430/1 "2020-09-28T18:32:22Z")

</div>

I had an issue with installing a few packages that ultimately depended on MbedTLS (via HTTP). Adding and building MbedTLS 1.0.2 seemed to work fine, but while precompiling it raised the following error with `undefined symbol: mbedtls_mutex_unlock`:

```julia
julia> using MbedTLS
[Info: Precompiling MbedTLS [739be429-bea8-5141-9913-cc70e7f3736d]
ERROR: LoadError: InitError: could not load library "/home/asher/.julia/artifacts/519367e9365948074c1fcc9f4365597f147a5ab7/lib/libmbedtls.so"
/usr/lib64/libmbedx509.so.0: undefined symbol: mbedtls_mutex_unlock
Stacktrace:
 [1] dlopen(::String, ::UInt32; throw_error::Bool) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/Libdl/src/Libdl.jl:109
 [2] dlopen(::String, ::UInt32) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/Libdl/src/Libdl.jl:109
 [3] __init__ () at /home/asher/.julia/packages/MbedTLS_jll/qGMUr/src/wrappers/x86_64-linux-gnu.jl:74
 [4] _include_from_serialized(::String, ::Array{Any,1}) at ./loading.jl:697
 [5] _require_search_from_serialized(::Base.PkgId, ::String) at ./loading.jl:782
 [6] _require(::Base.PkgId) at ./loading.jl:1007
 [7] require(::Base.PkgId) at ./loading.jl:928
 [8] require(::Module, ::Symbol) at ./loading.jl:923
 [9] include(::Function, ::Module, ::String) at ./Base.jl:380
 [10] include(::Module, ::String) at ./Base.jl:368
 [11] top-level scope at none:2
 [12] eval at ./boot.jl:331 [inlined]
 [13] eval(::Expr) at ./client.jl:467
 [14] top-level scope at ./none:3
during initialization of module MbedTLS_jll
in expression starting at /home/asher/.julia/packages/MbedTLS/VbsaQ/src/MbedTLS.jl:3
ERROR: Failed to precompile MbedTLS [739be429-bea8-5141-9913-cc70e7f3736d] to /home/asher/.julia/compiled/v1.5/MbedTLS/bf9T0_1dM57.ji.
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] compilecache(::Base.PkgId, ::String) at ./loading.jl:1305
 [3] _require(::Base.PkgId) at ./loading.jl:1030
 [4] require(::Base.PkgId) at ./loading.jl:928
 [5] require(::Module, ::Symbol) at ./loading.jl:923

```

Through a little trial and error, I found that manually installing MbedTLS as version 0.7.0 seemed to work out. Posting this here in case (1) anyone else is encountering this issue and (2) anyone has a good explanation for why this was happening.

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [September 29, 2020, 1:23am UTC](https://discourse.julialang.org/t/mbedtls-1-0-2-failed-to-load-on-julia-1-5-2-solved-by-downgrading-to-mbedtls-0-7-0/47430/2 "2020-09-29T01:23:39Z")

</div>

Could you please provide more information about your operating system, version of Julia, and how did you install julia in your system?

---

<div class="post-metadata">

**Author:** ![awasserman](https://avatars.discourse-cdn.com/v4/letter/a/9de0a6/32.png) [@awasserman](https://discourse.julialang.org/u/awasserman)\
**Post date:** [September 29, 2020, 5:36pm UTC](https://discourse.julialang.org/t/mbedtls-1-0-2-failed-to-load-on-julia-1-5-2-solved-by-downgrading-to-mbedtls-0-7-0/47430/3 "2020-09-29T17:36:21Z")

</div>

The system it failed on is running Fedora 32 (64 bit), and I am using Julia 1.5.2, downloaded directly from [julialang.org](http://julialang.org). MbedTLS.jl@0.7.0 is the latest version that doesn’t give me the undefined symbol error.

I’ve unsuccessfully tried replicating this on an Ubuntu 20.04 machine in the cloud, as it seemed to work fine on that machine.

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [September 30, 2020, 1:06am UTC](https://discourse.julialang.org/t/mbedtls-1-0-2-failed-to-load-on-julia-1-5-2-solved-by-downgrading-to-mbedtls-0-7-0/47430/4 "2020-09-30T01:06:15Z")

</div>

What does the command

```julia
nm -D /usr/lib64/libmbedcrypto.so | grep mbedtls_mutex_unlock

```

return for you?

---

<div class="post-metadata">

**Author:** ![awasserman](https://avatars.discourse-cdn.com/v4/letter/a/9de0a6/32.png) [@awasserman](https://discourse.julialang.org/u/awasserman)\
**Post date:** [September 30, 2020, 3:19am UTC](https://discourse.julialang.org/t/mbedtls-1-0-2-failed-to-load-on-julia-1-5-2-solved-by-downgrading-to-mbedtls-0-7-0/47430/5 "2020-09-30T03:19:37Z")

</div>

For libmbedcrypto it finds the symbol:  
`0000000000063070 D mbedtls_mutex_unlock`

For libmbed509x and libmbedtls (both under `/usr/lib64`) I get:  
` U mbedtls_mutex_unlock`

For any of the files in  
`$HOME/.julia/artifacts/519367e9365948074c1fcc9f4365597f147a5ab7/lib/*.so`  
I get no matching symbol.

---

<div class="post-metadata">

**Author:** ![bmxam](https://avatars.discourse-cdn.com/v4/letter/b/b38774/32.png) [@bmxam](https://discourse.julialang.org/u/bmxam)\
**Post date:** [October 9, 2020, 7:13pm UTC](https://discourse.julialang.org/t/mbedtls-1-0-2-failed-to-load-on-julia-1-5-2-solved-by-downgrading-to-mbedtls-0-7-0/47430/6 "2020-10-09T19:13:30Z")

</div>

I had the exact same error.

I am not an expert at all and what I did is just a temporary fix. I realized that my system `libmbed*` were older than the ones in my `$HOME/.julia/artifacts/519367e9365948074c1fcc9f4365597f147a5ab7/lib` folder.

So I removed the `libmbed*` from this julia folder and copied my system ones into the folder and it precompiled just fine (note that you might have a different version from `libmbed*` than 2.16.3):  
`cd $HOME/.julia/artifacts/519367e9365948074c1fcc9f4365597f147a5ab7/lib/`  
`rm -f limbed*`  
`cp /usr/lib/x86_64-linux-gnu/libmbedcrypto.so.2.16.3 ./libmbedcrypto.so`  
`cp /usr/lib/x86_64-linux-gnu/libmbedtls.so.2.16.3 ./libmbedtls.so`  
`cp /usr/lib/x86_64-linux-gnu/libmbedx509.so.2.16.3 ./libmbedx509.so`

Then `] precompile` worked just fine.

---

<div class="post-metadata">

**Author:** ![tbenst](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tbenst/32/3029_2.png) [@tbenst](https://discourse.julialang.org/u/tbenst)\
**Post date:** [November 27, 2020, 11:08pm UTC](https://discourse.julialang.org/t/mbedtls-1-0-2-failed-to-load-on-julia-1-5-2-solved-by-downgrading-to-mbedtls-0-7-0/47430/7 "2020-11-27T23:08:33Z")

</div>

I just ran into a similar (same?) error at [https://github.com/JuliaIO/HDF5.jl/issues/751#issue-752498568](https://github.com/JuliaIO/HDF5.jl/issues/751#issue-752498568)

---

<div class="post-metadata">

**Author:** ![awasserman](https://avatars.discourse-cdn.com/v4/letter/a/9de0a6/32.png) [@awasserman](https://discourse.julialang.org/u/awasserman)\
**Post date:** [April 15, 2021, 7:17pm UTC](https://discourse.julialang.org/t/mbedtls-1-0-2-failed-to-load-on-julia-1-5-2-solved-by-downgrading-to-mbedtls-0-7-0/47430/8 "2021-04-15T19:17:32Z")

</div>

Just in case anyone is coming across this again, I no longer encounter this problem with Julia 1.6.0
