# Windows: libgit2.dll not found

**URL:** <https://discourse.julialang.org/t/windows-libgit2-dll-not-found/88996>\
**Category:** New to Julia\
**Tags:** windows\
**Created:** [October 20, 2022, 7:34am UTC](https://discourse.julialang.org/t/windows-libgit2-dll-not-found/88996 "2022-10-20T07:34:16Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Johan-Gronqvist](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johan-gronqvist/32/29895_2.png) [@Johan-Gronqvist](https://discourse.julialang.org/u/Johan-Gronqvist)\
**Post date:** [October 20, 2022, 7:34am UTC](https://discourse.julialang.org/t/windows-libgit2-dll-not-found/88996/1 "2022-10-20T07:34:17Z")

</div>

I am trying the juliacall package, installed in a conda environment, and julia fails to find the libgit2 dll on windows. The problem appears when trying to install JuMP.

In `stdlib/LibGit2/src/LibGit2.jl` the problematic line seems to be ` @check ccall((:git_libgit2_init, :libgit2), Cint, ())` and I try to reproduce the problem below.

Giving it only the symbol `:libgit2`, the following python code (using juliacall with the julia installation that it has installed itself inside my conda environment) fails to find the dll.

```julia
(iqc_test) PS C:\Users\johan\IQC_Test> python
Python 3.10.6 | packaged by conda-forge | (main, Oct 7 2022, 20:14:50) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from juliacall import Main as jl
>>> jl.seval("ccall((:git_libgit2_init, :libgit2), Cint, ())")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\johan\.julia\packages\PythonCall\eU0yr\src\jlwrap\module.jl", line 25, in seval
    return self._jl_callmethod($(pyjl_methodnum(pyjlmodule_seval)), expr)
juliacall.JuliaError: could not load library "libgit2"
The specified module could not be found.
Stacktrace:
 [1] top-level scope
   @ .\none:1
 [2] eval
   @ .\boot.jl:368 [inlined]
 [3] eval
   @ .\Base.jl:65 [inlined]
 [4] pyjlmodule_seval(self::Module, expr::PythonCall.Py)
   @ PythonCall C:\Users\johan\.julia\packages\PythonCall\eU0yr\src\jlwrap\module.jl:13
 [5] _pyjl_callmethod(f::Any, self_::Ptr{PythonCall.C.PyObject}, args_::Ptr{PythonCall.C.PyObject}, nargs::Int64)
   @ PythonCall C:\Users\johan\.julia\packages\PythonCall\eU0yr\src\jlwrap\base.jl:62
 [6] _pyjl_callmethod(o::Ptr{PythonCall.C.PyObject}, args::Ptr{PythonCall.C.PyObject})
   @ PythonCall.C C:\Users\johan\.julia\packages\PythonCall\eU0yr\src\cpython\jlwrap.jl:47 

```

but giving it the full path to the dll seems to work better

```julia
(iqc_test) PS C:\Users\johan\IQC_Test> python
Python 3.10.6 | packaged by conda-forge | (main, Oct 7 2022, 20:14:50) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from juliacall import Main as jl
>>> jl.seval('ccall((:git_libgit2_init, "C:/Users/johan/.conda/envs/iqc_test/julia_env/pyjuliapkg/install/bin/libgit2.dll"), Cint, ())')
1

```

I do not understand where julia should look for `libgit2.dll` and how I could help it find it.

---

<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:** [October 20, 2022, 9:44am UTC](https://discourse.julialang.org/t/windows-libgit2-dll-not-found/88996/2 "2022-10-20T09:44:00Z")

</div>

Julia ships its own build of libgit2, as it’s needed by the package manager, it’s in the `lib/julia/` subdirectory of its installation.

---

<div class="post-metadata">

**Author:** ![Johan-Gronqvist](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johan-gronqvist/32/29895_2.png) [@Johan-Gronqvist](https://discourse.julialang.org/u/Johan-Gronqvist)\
**Post date:** [October 20, 2022, 10:07am UTC](https://discourse.julialang.org/t/windows-libgit2-dll-not-found/88996/3 "2022-10-20T10:07:48Z")

</div>

In my linux, via wsl, the libraries reside in the `lib/julia` subdirectory, and my program works.

In windows, the libraries reside instead in `bin`, and julia fails to locate them.

---

<div class="post-metadata">

**Author:** ![Johan-Gronqvist](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johan-gronqvist/32/29895_2.png) [@Johan-Gronqvist](https://discourse.julialang.org/u/Johan-Gronqvist)\
**Post date:** [October 20, 2022, 11:09am UTC](https://discourse.julialang.org/t/windows-libgit2-dll-not-found/88996/4 "2022-10-20T11:09:26Z")

</div>

When I start the julai repl in windows, using the julia binary that was installed by juliacall in the conda environment, it manages to find libgit2.dll.

The problem therefore seems to be due to juliacall starting julia in a different way.

---

<div class="post-metadata">

**Author:** ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)\
**Post date:** [October 20, 2022, 11:24am UTC](https://discourse.julialang.org/t/windows-libgit2-dll-not-found/88996/5 "2022-10-20T11:24:43Z")

</div>

@cjdoris, is this then a (known, someone already made an issue?) bug in juliacall (I’m assuming it’s used as intended)?

> [@giordano](#):
>
> Julia ships its own build of libgit2, as it’s needed by the package manager, it’s in the `lib/julia/` subdirectory of its installation.

That’s for Linux, why not the same on Windows (unless WSL2)? If there’s a good reason for the inconsistency, then never-mind, but it’s likely the reason for the juliacall Windows bug (and potentially affecting other `.dll`s too?), and a simple path solution (but I’m not on Windows, so I can’t check).

---

<div class="post-metadata">

**Author:** ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)\
**Post date:** [October 20, 2022, 12:06pm UTC](https://discourse.julialang.org/t/windows-libgit2-dll-not-found/88996/6 "2022-10-20T12:06:14Z")

</div>

You need to add the path to libgit2.dll to the PATH environment variable.  
I think for you it is

```julia
"C:/Users/johan/.conda/envs/iqc_test/julia_env/pyjuliapkg/install/bin"

```

I am not sure what’s your setting, so I use the windows \ standard for this path and I assume that you are using powershell (because I see a PS prompt).  
Add the following to your PATH environment variable, e.g.:

```julia
PS X:\> $env:Path += ';C:\Users\johan\.conda\envs\iqc_test\julia_env\pyjuliapkg\install\bin'

PS X:\> python.exe
Python 3.10.8 (tags/v3.10.8:aaaf517, Oct 11 2022, 16:50:30) [MSC v.1933 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from juliacall import Main as jl
>>> jl.seval("ccall((:git_libgit2_init, :libgit2), Cint, ())")
1

```

Of course I did another PATH for me, so it worked for me. But above should do for you.

I would say this is something worth to open up an issue (if it doesn’t exists already, didn’t check, [GitHub - cjdoris/PythonCall.jl: Python and Julia in harmony.](https://github.com/cjdoris/PythonCall.jl)).

---

<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:** [October 20, 2022, 1:00pm UTC](https://discourse.julialang.org/t/windows-libgit2-dll-not-found/88996/7 "2022-10-20T13:00:46Z")

</div>

> [@Palli](#):
>
> That’s for Linux, why not the same on Windows (unless WSL2)?

Not sure what you mean since libgit2 is shipped for all systems.

---

<div class="post-metadata">

**Author:** ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)\
**Post date:** [October 20, 2022, 1:08pm UTC](https://discourse.julialang.org/t/windows-libgit2-dll-not-found/88996/8 "2022-10-20T13:08:33Z")

</div>

I meant the inconsistency (probably unrelated to finding it, or juliacall relies on it in lib?):

> [@Johan-Gronqvist](#):
>
> In windows, the libraries reside instead in `bin`, and julia fails to locate them.

---

<div class="post-metadata">

**Author:** ![cjdoris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cjdoris/32/213133_2.png) [@cjdoris](https://discourse.julialang.org/u/cjdoris)\
**Post date:** [October 20, 2022, 6:13pm UTC](https://discourse.julialang.org/t/windows-libgit2-dll-not-found/88996/9 "2022-10-20T18:13:42Z")

</div>

Fixed! [path fix on windows · cjdoris/PythonCall.jl@e1b1670 · GitHub](https://github.com/cjdoris/PythonCall.jl/commit/e1b16707a40f0473cf0801819bbe00846661014e)

Just needed to add an entry to the PATH on Windows.

I’m making a release, try again in an hour…
