Getting IJulia to work inside of a mamba venv

I am having trouble installing IJulia in Julia 1.9.1 inside a mamba environment. The crux of the issue seems to be the compiler not being able to find MbedTLS even though it is installed

Looking for: ['mbedtls']

conda-forge/noarch                                  13.1MB @   4.4MB/s  3.4s
conda-forge/linux-64                                32.7MB @   4.2MB/s  8.9s

Pinned packages:
  - python 3.11.*


Transaction

  Prefix: /shares/teacher/users/student/mambaforge/envs/jenv

  All requested packages already installed
> Using Pkg
> Pkg.update()
>Pkg.add("IJulia") # this works fine
> Using IJulia # This does not

The error when running the above commands is:

MbedTLS [739be429-bea8-5141-9913-cc70e7f3736d]

Failed to precompile MbedTLS [739be429-bea8-5141-9913-cc70e7f3736d] to "/shares/teacher/users/student/mambaforge/envs/jenv/share/julia/compiled/v1.9/MbedTLS/jl_g7s41h".
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)
    @ Base.Libc.Libdl ./libdl.jl:117
  [2] dlopen
    @ ./libdl.jl:116 [inlined]
  [3] dlopen(s::String)
    @ Base.Libc.Libdl ./libdl.jl:116
  [4] __init__()
    @ MbedTLS_jll ~/mambaforge/envs/jenv/share/julia/stdlib/v1.9/MbedTLS_jll/src/MbedTLS_jll.jl:42
  [5] register_restored_modules(sv::Core.SimpleVector, pkg::Base.PkgId, path::String)
    @ Base ./loading.jl:1115
  [6] _include_from_serialized(pkg::Base.PkgId, path::String, ocachepath::String, depmods::Vector{Any})
    @ Base ./loading.jl:1061
  [7] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String, build_id::UInt128)
    @ Base ./loading.jl:1506
  [8] _require(pkg::Base.PkgId, env::String)
    @ Base ./loading.jl:1783
  [9] _require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:1660
 [10] macro expansion
    @ ./loading.jl:1648 [inlined]
 [11] macro expansion
    @ ./lock.jl:267 [inlined]
 [12] require(into::Module, mod::Symbol)
    @ Base ./loading.jl:1611
 [13] include
    @ ./Base.jl:457 [inlined]
 [14] 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:2045
 [15] top-level scope
    @ stdin:3
during initialization of module MbedTLS_jll
in expression starting at /shares/teacher/users/student/mambaforge/envs/jenv/share/julia/packages/MbedTLS/lqmet/src/MbedTLS.jl:1
in expression starting at stdin:3

IJulia [7073ff75-c697-5162-941a-fcdaad2a7d2a]

Failed to precompile IJulia [7073ff75-c697-5162-941a-fcdaad2a7d2a] to "/shares/teacher/users/student/mambaforge/envs/jenv/share/julia/compiled/v1.9/IJulia/jl_sxd2YS".
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)
    @ Base.Libc.Libdl ./libdl.jl:117
  [2] dlopen
    @ ./libdl.jl:116 [inlined]
  [3] dlopen(s::String)
    @ Base.Libc.Libdl ./libdl.jl:116
  [4] __init__()
    @ MbedTLS_jll ~/mambaforge/envs/jenv/share/julia/stdlib/v1.9/MbedTLS_jll/src/MbedTLS_jll.jl:42
  [5] register_restored_modules(sv::Core.SimpleVector, pkg::Base.PkgId, path::String)
    @ Base ./loading.jl:1115
  [6] _include_from_serialized(pkg::Base.PkgId, path::String, ocachepath::String, depmods::Vector{Any})
    @ Base ./loading.jl:1061
  [7] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String, build_id::UInt128)
    @ Base ./loading.jl:1506
  [8] _require(pkg::Base.PkgId, env::String)
    @ Base ./loading.jl:1783
  [9] _require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:1660
 [10] macro expansion
    @ ./loading.jl:1648 [inlined]
 [11] macro expansion
    @ ./lock.jl:267 [inlined]
 [12] require(into::Module, mod::Symbol)
    @ Base ./loading.jl:1611
 [13] include
    @ ./Base.jl:457 [inlined]
 [14] 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::String)
    @ Base ./loading.jl:2045
 [15] top-level scope
    @ stdin:3
during initialization of module MbedTLS_jll
in expression starting at /shares/teacher/users/student/mambaforge/envs/jenv/share/julia/packages/MbedTLS/lqmet/src/MbedTLS.jl:1
in expression starting at stdin:3
ERROR: LoadError: Failed to precompile MbedTLS [739be429-bea8-5141-9913-cc70e7f3736d] to "/shares/teacher/users/student/mambaforge/envs/jenv/share/julia/compiled/v1.9/MbedTLS/jl_TwrfV9".
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:2296
  [3] compilecache
    @ ./loading.jl:2163 [inlined]
  [4] _require(pkg::Base.PkgId, env::String)
    @ Base ./loading.jl:1805
  [5] _require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:1660
  [6] macro expansion
    @ ./loading.jl:1648 [inlined]
  [7] macro expansion
    @ ./lock.jl:267 [inlined]
  [8] require(into::Module, mod::Symbol)
    @ Base ./loading.jl:1611
  [9] include(mod::Module, _path::String)
    @ Base ./Base.jl:457
 [10] include(x::String)
    @ IJulia ~/mambaforge/envs/jenv/share/julia/packages/IJulia/Vo51o/src/IJulia.jl:33
 [11] top-level scope
    @ ~/mambaforge/envs/jenv/share/julia/packages/IJulia/Vo51o/src/IJulia.jl:309
 [12] include
    @ ./Base.jl:457 [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, UInt128}}, source::Nothing)
    @ Base ./loading.jl:2045
 [14] top-level scope
    @ stdin:3
in expression starting at /shares/teacher/users/student/mambaforge/envs/jenv/share/julia/packages/IJulia/Vo51o/src/hmac.jl:1
in expression starting at /shares/teacher/users/student/mambaforge/envs/jenv/share/julia/packages/IJulia/Vo51o/src/IJulia.jl:1
in expression starting at stdin:3

Stacktrace:
 [1] pkgerror(msg::String)
   @ Pkg.Types ~/mambaforge/envs/jenv/share/julia/stdlib/v1.9/Pkg/src/Types.jl:69
 [2] precompile(ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec}; internal_call::Bool, strict::Bool, warn_loaded::Bool, already_instantiated::Bool, timing::Bool, kwargs::Base.Pairs{Symbol, Base.TTY, Tuple{Symbol}, NamedTuple{(:io,), Tuple{Base.TTY}}})
   @ Pkg.API ~/mambaforge/envs/jenv/share/julia/stdlib/v1.9/Pkg/src/API.jl:1581
 [3] precompile(pkgs::Vector{Pkg.Types.PackageSpec}; io::Base.TTY, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
   @ Pkg.API ~/mambaforge/envs/jenv/share/julia/stdlib/v1.9/Pkg/src/API.jl:156
 [4] precompile(pkgs::Vector{Pkg.Types.PackageSpec})
   @ Pkg.API ~/mambaforge/envs/jenv/share/julia/stdlib/v1.9/Pkg/src/API.jl:145
 [5] precompile(; name::Nothing, uuid::Nothing, version::Nothing, url::Nothing, rev::Nothing, path::Nothing, mode::Pkg.Types.PackageMode, subdir::Nothing, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
   @ Pkg.API ~/mambaforge/envs/jenv/share/julia/stdlib/v1.9/Pkg/src/API.jl:171
 [6] precompile()
   @ Pkg.API ~/mambaforge/envs/jenv/share/julia/stdlib/v1.9/Pkg/src/API.jl:162
 [7] top-level scope
   @ REPL[4]:1

I had a read/write error before this and that I was able debug to the png/svg issue!!! There are some older posts that suggested among other things deleting the logo for julia solves read/write issues. As bizarre as that was, I was able to solve it but this MbedTLS issue does not seem to have a whole lot of discussions behind it. If someone is familiar, could you help me get IJulia working?

In general I would recommend not using the julia package from conda/mamba. Instead, install the official Julia binary and install packages normally.

You can still install/run Jupyter using the mamba package, and it should see the Julia kernel installed by IJulia on your machine. (You can also configure things like PyCall and PyPlot to use whatever Python you want.)

1 Like

Interesting.

The issue with that is I am working in a server where I don’t have root privileges. That is not uncommon for many researchers. Students and researchers have to work under supervised setups all the time so it is a bit surprising that Conda/mamba and Julia do not play nice with each other. Oh well!

I strictly avoid installing interpreter/compiler under heavy use in a Dev-cycle in my base env. I will try to go back a few versions and see if that helps. Thanks for chiming in!

You can install the official Julia binaries and packages without root privileges; I don’t see how that is relevant here.

Right.

  1. Specifically because I tried doing that with JuliaUp and keep running into permission denials for write access when trying to install packages. Access I cannot change,
Error building `IJulia`:
[ Info: Installing Julia kernelspec in /shares/teacher/users/student/.local/share/jupyter/kernels/julia-1.9
ERROR: LoadError: IOError: stat("/apps/python/latest/bin/jupyter"): permission denied (EACCES)

(Write permission error persist after deleting the .pngs and .svgs)

  1. Generally because I can’t customize OS level dependencies (read dependencies outside of the compiler) for Jupyter and Julia in the base env? As opposed to a virtual env/path where every dependency on path outside or inside of a language’s ecosystem can be controlled?