2

I unzipped and copied to julia-1.6.2 to /opt/julia/

[root@srvr0 ~]# cp -a /root/Downloads/julia-1.6.2 /opt/julia/

Content of /etc/profile.d/julia.sh:

export JULIA_HOME=/opt/julia/julia-1.6.2
export JULIA_LOAD_PATH=/opt/julia/julia-1.6.2/share/julia/stdlib/v1.6
export JULIA_DEPOT_PATH=/opt/julia/julia-1.6.2/share/julia/stdlib/v1.6
export JULIA_PKG_DEVDIR=/opt/julia/julia-1.6.2/share/julia/stdlib/v1.6
export JULIA_PROJECT=/opt/julia/julia-1.6.2/share/julia/stdlib/v1.6
export JULIA_HISTORY=/opt/julia/julia-1.6.2/share/julia/stdlib/v1.6/logs/repl_history.jl

Setting Environment Variables:

[root@srvr0 ~]# source /etc/profile.d/julia.sh

Invoking julia:

[root@srvr0 ~]# julia
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.6.2 (2021-07-14)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

Version Info:

julia> versioninfo()
Julia Version 1.6.2
Commit 1b93d53fc4 (2021-07-14 15:36 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i7 CPU       M 620  @ 2.67GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-11.0.1 (ORCJIT, westmere)
Environment:
  JULIA_DEPOT_PATH = /opt/julia/julia-1.6.2/share/julia/stdlib/v1.6
  JULIA_PROJECT = /opt/julia/julia-1.6.2/share/julia/stdlib/v1.6
  JULIA_LOAD_PATH = /opt/julia/julia-1.6.2/share/julia/stdlib/v1.6
  JULIA_PKG_DEVDIR = /opt/julia/julia-1.6.2/share/julia/stdlib/v1.6
  JULIA_HOME = /opt/julia/julia-1.6.2
  JULIA_HISTORY = /opt/julia/julia-1.6.2/share/julia/stdlib/v1.6/logs/repl_history.jl

julia> import Pkg

julia> using Pkg

Adding package MbedTLS but getting errors:

(v1.6) pkg> add MbedTLS
  Installing known registries into `@stdlib/v1.6`
       Added registry `General` to `/opt/julia/julia-1.6.2/share/julia/stdlib/v1.6/registries/General`
   Resolving package versions...
   Installed MbedTLS ─ v1.0.3
    Updating `@stdlib/Project.toml`
  [739be429] + MbedTLS v1.0.3
    Updating `@stdlib/Manifest.toml`
  [739be429] + MbedTLS v1.0.3
  [56f22d72] + Artifacts
  [ade2ca70] + Dates
  [8f399da3] + Libdl
  [de0858da] + Printf
  [9a3f8284] + Random
  [9e88b42a] + Serialization
  [6462fe0b] + Sockets
  [4ec0a83e] + Unicode
  [c8ffd9c3] + MbedTLS_jll
Precompiling project...
  ✗ MbedTLS
  0 dependencies successfully precompiled in 13 seconds
  2 dependencies errored. To see a full report either run `import Pkg; Pkg.precompile()` or load the packages

julia> using Pkg
ERROR: ArgumentError: Package Pkg not found in current path:
- Run `import Pkg; Pkg.add("Pkg")` to install the Pkg package.

Stacktrace:
 [1] require(into::Module, mod::Symbol)
   @ Base ./loading.jl:893

Observation: Before adding package MbedTLS, Package Pkg was on Path but after invoking add MbedTLS, I got error Package Pkg not found in current path

Please guide me in installing MbedTLS package!

AVA
  • 2,474
  • 2
  • 26
  • 41

1 Answers1

1

I do not like your JULIA_DEPOT_PATH it should be a folder separate from your Julia installation files. Most likely this somehow caused your installation to be corrupted. Moreover, this means that any package manipulation would most likely require root rights as it points to /opt folder. Even worse, JULIA_DEPOT_PATH is also written when a package is compiled and hence in several scenarios you end up needing to run Julia as sudo.

Hence, what I would recommend is to set JULIA_DEPOT_PATH to something like: /home/user/.julia (which is the default setting) or something similar to /home/user/JuliaPkg1.6.2

Since you have installed packages to /opt/julia/julia-1.6.2/share/julia/stdlib/v1.6, I would recommend to delete /opt/julia/julia-1.6.2/ and install Julia again to that folder.

JULIA_HISTORY should point to some location within the JULIA_DEPOT_PATH again, otherwise you need to be root to work with the REPL. You do not need JULIA_PROJECT as by default the Project.toml at JULIA_DEPOT_PATH/environments/v1.6 should get loaded. Similar story with JULIA_LOAD_PATH and JULIA_PKG_DEVDIR.

In conclusion, I would consider staying only with the JULIA_HOME and JULIA_DEPOT_PATH variables and the latter needs to point to a location outside of Julia installation that does not require root rights to write.

Reference: https://docs.julialang.org/en/v1/manual/environment-variables/

Przemyslaw Szufel
  • 40,002
  • 3
  • 32
  • 62
  • When you say corrupted, what do you mean exactly? Like are some files actually edited and overwritten, or does Julia assume that only certain files will exist on the depot path (and others) and adding new files messes that up? – BatWannaBe Dec 19 '21 at 23:45
  • 1
    My experience with Julia Package Manager is that if you manipulate packages and break the process in the middle of installation than it is basically hard to recover. I have tried few times doing Pkg.add("SomePackage") and press `Ctrl+C` in the middle of the process - and it usually did not end well. Maybe 1.7.0 is more resilient - however whenever something goes wrong beyond `Pkg.instantiate()` and `Pkg.build()` than always the easiest option for me was to recreate the `DEPOT_PATH` – Przemyslaw Szufel Dec 19 '21 at 23:57