spine-tools / Spine-Toolbox

Spine Toolbox is an open source Python package to manage data, scenarios and workflows for modelling and simulation. You can have your local workflow, but work as a team through version control and SQL databases.
https://www.tools-for-energy-system-modelling.org/
GNU Lesser General Public License v3.0
73 stars 18 forks source link

SpineOpt Installation Wizard fails when Toolbox runs in a Conda environment on Windows #3002

Closed ptsavol closed 1 week ago

ptsavol commented 2 weeks ago

This is actually not a bug in Spine Toolbox because the same thing happens in a Julia REPL started in a conda prompt but I think we can deal with this in Toolbox.

Here's the traceback from SpineOpt Installation Wizard (File->Settings->Tools->Add/Update SpineOpt)

SpineOpt installation started
$ C:\Users\prokjt\AppData\Local\julias\julia-1.11\bin\julia.exe --project=spineopt -e using Pkg; pkg"registry add General [https://github.com/spine-tools/SpineJuliaRegistry.git";](https://github.com/spine-tools/SpineJuliaRegistry.git%22;) pkg"add SpineOpt"
┌ Warning: The Pkg REPL mode is intended for interactive use only, and should not be used from scripts. It is recommended to use the functional API instead.
└ @ Pkg.REPLMode C:\Users\prokjt\AppData\Local\julias\julia-1.11\share\julia\stdlib\v1.11\Pkg\src\REPLMode\REPLMode.jl:388
Added `General` registry to C:\Users\prokjt\.julia\registries
Cloning registry from "[https://github.com/spine-tools/SpineJuliaRegistry.git"](https://github.com/spine-tools/SpineJuliaRegistry.git%22)
ERROR: failed to clone from https://github.com/spine-tools/SpineJuliaRegistry.git, error: GitError(Code:ERROR, Class:SSL, Your Julia is built with a SSL/TLS engine that libgit2 doesn't know how to configure to use a file or directory of certificate authority roots, but your environment specifies one via the SSL_CERT_FILE variable. If you believe your system's root certificates are safe to use, you can `export JULIA_SSL_CA_ROOTS_PATH=""` in your environment to use those instead.)
Stacktrace:
[1] pkgerror(msg::String)
@ Pkg.Types C:\Users\prokjt\AppData\Local\julias\julia-1.11\share\julia\stdlib\v1.11\Pkg\src\Types.jl:68
[2] clone(io::IOContext{IO}, url::String, source_path::String; header::String, credentials::Nothing, kwargs::@Kwargs{})
@ Pkg.GitTools C:\Users\prokjt\AppData\Local\julias\julia-1.11\share\julia\stdlib\v1.11\Pkg\src\GitTools.jl:132
[3] (::Base.var"#106#108"{Base.var"#106#107#109"{Vector{Float64}, Pkg.Registry.var"#51#55", typeof(Pkg.GitTools.clone)}})(::IOContext{IO}, ::Vararg{Any}; kwargs::@Kwargs{header::String})
@ Base .\error.jl:300
[4] #106
@ .\error.jl:295 [inlined]
[5] (::Pkg.Registry.var"#50#54"{Pkg.Registry.RegistrySpec, Nothing, IOContext{IO}, String})(tmp::String)
@ Pkg.Registry C:\Users\prokjt\AppData\Local\julias\julia-1.11\share\julia\stdlib\v1.11\Pkg\src\Registry\Registry.jl:247
[6] mktempdir(fn::Pkg.Registry.var"#50#54"{Pkg.Registry.RegistrySpec, Nothing, IOContext{IO}, String}, parent::String; prefix::String)
@ Base.Filesystem .\file.jl:819
[7] mktempdir(fn::Function, parent::String)
@ Base.Filesystem .\file.jl:815
[8] mktempdir
@ .\file.jl:815 [inlined]
[9] (::Pkg.Registry.var"#48#52"{IOContext{IO}, Vector{Pkg.Registry.RegistrySpec}, String})()
@ Pkg.Registry C:\Users\prokjt\AppData\Local\julias\julia-1.11\share\julia\stdlib\v1.11\Pkg\src\Registry\Registry.jl:211
[10] mkpidlock(f::Pkg.Registry.var"#48#52"{IOContext{IO}, Vector{Pkg.Registry.RegistrySpec}, String}, at::String, pid::Int32; kwopts::@Kwargs{stale_age::Int64})
@ FileWatching.Pidfile C:\Users\prokjt\AppData\Local\julias\julia-1.11\share\julia\stdlib\v1.11\FileWatching\src\pidfile.jl:95

SpineOpt installation failed

As the error message says, an environment variable JULIA_SSL_CA_ROOTS_PATH must be set. However, the error message is a bit misleading because the given fix does not work on Windows. The fix is to enter ENV["JULIA_SSL_CA_ROOTS_PATH"] = "" in Julia REPL before trying to add SpineJuliaRegistry. To fix the SpineOpt install wizard, we should add ENV["JULIA_SSL_CA_ROOTS_PATH"] = "" to the list of commands it executes. I believe that this environment variable only lives in the Julia instance that is being run by the SpineOpt Installer Wizard and it will be gone when SpineOpt has been installed.