Git for Windows/ bash does not like Julia

I am using git for windows, which installs a bash shell (MINGW64). I can start Julia 1.9.1 in this shell, but then the input gets stuck. I cannot enter anything on the Julia prompt.

Bash and Julia are working if I use it in vscode, though.

$ git --version
git version 2.40.1.windows.1

If I start Julia, it hangs, and then press <ctrl>+<c> I get:

julia> Unhandled Task ERROR: InterruptException:
Stacktrace:
  [1] poptask(W::Base.IntrusiveLinkedListSynchronized{Task})
    @ Base .\task.jl:974
  [2] wait()
    @ Base .\task.jl:983
  [3] wait(c::Base.GenericCondition{Base.Threads.SpinLock}; first::Bool)
    @ Base .\condition.jl:130
  [4] wait
    @ .\condition.jl:125 [inlined]
  [5] wait_readnb(x::Base.TTY, nb::Int64)
    @ Base .\stream.jl:416
  [6] eof(s::Base.TTY)
    @ Base .\stream.jl:106
  [7] eof(io::REPL.Terminals.TTYTerminal)
    @ Base .\io.jl:450
  [8] match_input(k::Dict{Char}, s::Union{Nothing, REPL.LineEdit.MIState}, term::Union{REPL.Terminals.AbstractTerminal, IOBuffer}, cs::Vector{Char}, keymap::Dict{Char})
    @ REPL.LineEdit C:\Users\uwefechner\.julia\juliaup\julia-1.9.1+0.x64.w64.mingw32\share\julia\stdlib\v1.9\REPL\src\LineEdit.jl:1619
  [9] match_input(k::Dict{Char}, s::Union{Nothing, REPL.LineEdit.MIState}, term::Union{REPL.Terminals.AbstractTerminal, IOBuffer}, cs::Vector{Char})
    @ REPL.LineEdit C:\Users\uwefechner\.julia\juliaup\julia-1.9.1+0.x64.w64.mingw32\share\julia\stdlib\v1.9\REPL\src\LineEdit.jl:1619
 [10] match_input(k::Dict{Char}, s::Union{Nothing, REPL.LineEdit.MIState}, term::Union{REPL.Terminals.AbstractTerminal, IOBuffer})
    @ REPL.LineEdit C:\Users\uwefechner\.julia\juliaup\julia-1.9.1+0.x64.w64.mingw32\share\julia\stdlib\v1.9\REPL\src\LineEdit.jl:1619
 [11] match_input(k::Dict{Char}, s::Union{Nothing, REPL.LineEdit.MIState})
    @ REPL.LineEdit C:\Users\uwefechner\.julia\juliaup\julia-1.9.1+0.x64.w64.mingw32\share\julia\stdlib\v1.9\REPL\src\LineEdit.jl:1619
 [12] prompt!(term::REPL.Terminals.TextTerminal, prompt::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
    @ REPL.LineEdit C:\Users\uwefechner\.julia\juliaup\julia-1.9.1+0.x64.w64.mingw32\share\julia\stdlib\v1.9\REPL\src\LineEdit.jl:2732
 [13] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
    @ REPL.LineEdit C:\Users\uwefechner\.julia\juliaup\julia-1.9.1+0.x64.w64.mingw32\share\julia\stdlib\v1.9\REPL\src\LineEdit.jl:2642
 [14] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
    @ REPL C:\Users\uwefechner\.julia\juliaup\julia-1.9.1+0.x64.w64.mingw32\share\julia\stdlib\v1.9\REPL\src\REPL.jl:1300
 [15] (::REPL.var"#62#68"{REPL.LineEditREPL, REPL.REPLBackendRef})()
    @ REPL .\task.jl:514
ERROR: TaskFailedException
Stacktrace:
  [1] try_yieldto(undo::typeof(Base.ensure_rescheduled))
    @ Base .\task.jl:920
  [2] wait()
    @ Base .\task.jl:984
  [3] wait(c::Base.GenericCondition{ReentrantLock}; first::Bool)
    @ Base .\condition.jl:130
  [4] wait
    @ .\condition.jl:125 [inlined]
  [5] take_buffered(c::Channel{Any})
    @ Base .\channels.jl:457
  [6] take!
    @ .\channels.jl:451 [inlined]
  [7] repl_backend_loop(backend::REPL.REPLBackend, get_module::Function)
    @ REPL C:\Users\uwefechner\.julia\juliaup\julia-1.9.1+0.x64.w64.mingw32\share\julia\stdlib\v1.9\REPL\src\REPL.jl:244
  [8] start_repl_backend(backend::REPL.REPLBackend, consumer::Any; get_module::Function)
    @ REPL C:\Users\uwefechner\.julia\juliaup\julia-1.9.1+0.x64.w64.mingw32\share\julia\stdlib\v1.9\REPL\src\REPL.jl:234
  [9] run_repl(repl::REPL.AbstractREPL, consumer::Any; backend_on_current_task::Bool, backend::Any)
    @ REPL C:\Users\uwefechner\.julia\juliaup\julia-1.9.1+0.x64.w64.mingw32\share\julia\stdlib\v1.9\REPL\src\REPL.jl:379
 [10] run_repl(repl::REPL.AbstractREPL, consumer::Any)
    @ REPL C:\Users\uwefechner\.julia\juliaup\julia-1.9.1+0.x64.w64.mingw32\share\julia\stdlib\v1.9\REPL\src\REPL.jl:365
 [11] (::Base.var"#1017#1019"{Bool, Bool, Bool})(REPL::Module)
    @ Base .\client.jl:421
 [12] #invokelatest#2
    @ .\essentials.jl:816 [inlined]
 [13] invokelatest
    @ .\essentials.jl:813 [inlined]
 [14] run_main_repl(interactive::Bool, quiet::Bool, banner::Bool, history_file::Bool, color_set::Bool)
    @ Base .\client.jl:405
 [15] exec_options(opts::Base.JLOptions)
    @ Base .\client.jl:322
 [16] _start()
    @ Base .\client.jl:522

    nested task error: InterruptException:
    Stacktrace:
      [1] poptask(W::Base.IntrusiveLinkedListSynchronized{Task})
        @ Base .\task.jl:974
      [2] wait()
        @ Base .\task.jl:983
      [3] wait(c::Base.GenericCondition{Base.Threads.SpinLock}; first::Bool)
        @ Base .\condition.jl:130
      [4] wait
        @ .\condition.jl:125 [inlined]
      [5] wait_readnb(x::Base.TTY, nb::Int64)
        @ Base .\stream.jl:416
      [6] eof(s::Base.TTY)
        @ Base .\stream.jl:106
      [7] eof(io::REPL.Terminals.TTYTerminal)
        @ Base .\io.jl:450
      [8] match_input(k::Dict{Char}, s::Union{Nothing, REPL.LineEdit.MIState}, term::Union{REPL.Terminals.AbstractTerminal, IOBuffer}, cs::Vector{Char}, keymap::Dict{Char})
        @ REPL.LineEdit C:\Users\uwefechner\.julia\juliaup\julia-1.9.1+0.x64.w64.mingw32\share\julia\stdlib\v1.9\REPL\src\LineEdit.jl:1619
      [9] match_input(k::Dict{Char}, s::Union{Nothing, REPL.LineEdit.MIState}, term::Union{REPL.Terminals.AbstractTerminal, IOBuffer}, cs::Vector{Char})
        @ REPL.LineEdit C:\Users\uwefechner\.julia\juliaup\julia-1.9.1+0.x64.w64.mingw32\share\julia\stdlib\v1.9\REPL\src\LineEdit.jl:1619
     [10] match_input(k::Dict{Char}, s::Union{Nothing, REPL.LineEdit.MIState}, term::Union{REPL.Terminals.AbstractTerminal, IOBuffer})
        @ REPL.LineEdit C:\Users\uwefechner\.julia\juliaup\julia-1.9.1+0.x64.w64.mingw32\share\julia\stdlib\v1.9\REPL\src\LineEdit.jl:1619
     [11] match_input(k::Dict{Char}, s::Union{Nothing, REPL.LineEdit.MIState})
        @ REPL.LineEdit C:\Users\uwefechner\.julia\juliaup\julia-1.9.1+0.x64.w64.mingw32\share\julia\stdlib\v1.9\REPL\src\LineEdit.jl:1619
     [12] prompt!(term::REPL.Terminals.TextTerminal, prompt::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
        @ REPL.LineEdit C:\Users\uwefechner\.julia\juliaup\julia-1.9.1+0.x64.w64.mingw32\share\julia\stdlib\v1.9\REPL\src\LineEdit.jl:2732
     [13] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
        @ REPL.LineEdit C:\Users\uwefechner\.julia\juliaup\julia-1.9.1+0.x64.w64.mingw32\share\julia\stdlib\v1.9\REPL\src\LineEdit.jl:2642
     [14] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
        @ REPL C:\Users\uwefechner\.julia\juliaup\julia-1.9.1+0.x64.w64.mingw32\share\julia\stdlib\v1.9\REPL\src\REPL.jl:1300
     [15] (::REPL.var"#62#68"{REPL.LineEditREPL, REPL.REPLBackendRef})()
        @ REPL .\task.jl:514
(base)
uwefechner@TUD262682 MINGW64 /

Is this a known problem? Is there a bash shell (terminal) that works together with Windows and Julia?

I do not recall having this issue.

I regularly use MSYS2’s MINGW64 environment to build Julia amd do not have any issues there. I used to use Cygwin and also did not have any issues there.

Under Windows, I often use Windows Terminal to run Julia under Powershell.

I can confirm the issue, same error.

Julia 1.9.0 (installed with juliaup)

git is a bit outdated: git version 2.39.0.windows.1

I use Cygwin inside Windows Terminal and Julia for Windows. Works well for me, but it may be more overhead than you want.

Why not use WSL? We use that for Julia and it works very well.

I can reproduce in the Git Bash shell.

Interestingly, the issue does not happen when you do it through Windows Terminal. I much prefer the Windows Terminal so perhaps that is why I haven’t encountered this. For what it’s worth, I even now prefer to use the new Powershell instead of Git Bash as my default.

1 Like

One only should use programs on the WSL side to access files then. Accessing files from both Windows programs and WSL-run programs may lead to corrupted contents due to locking:

Potential performance gain:

I use 1.9 with git bash exclusively, both on Win 10 and 11. Never any problems.

I installed cygwin to check if it works with Julia, but I get:

uwefechner@TUD262682 ~
$ julia
-bash: /cygdrive/c/Users/uwefechner/AppData/Local/Microsoft/WindowsApps/julia: Permission denied

Should the Windows version of Julia work with cygwin or do I need the Linux version?

Hmm, I’m not sure what’s happened there, I haven’t seen that before. I have Julia (Windows version) in my Windows path (currently Win11, but previously Win10), which Cygwin adopts.
I can run that Julia from Cygwin and Windows without any noticeable differences. I also run it from the Cygwin version of emacs, which is my standard development tool.
I have seen a similar problem with Python, but the Python installation does weird things with links.

That path looks a bit odd to me. I’m on my phone right now, but my recollection is that (with the standard installation) the Julia executable would be in a directory
/cygdrive/c/Users/username/AppData/Local/Microsoft/WindowsApps/julia-1.x.x/bin
Midnight here, but I’ll confirm/update in the morning.

uwefechner@TUD262682 ~/AppData/Local/Microsoft/WindowsApps
$ ls -la julia.exe
lrwxrwxrwx 1 uwefechner Domain Users 113 May  1 17:52 julia.exe -> '/cygdrive/c/Program Files/WindowsApps/JuliaComputingInc.Julia_1.8.16.0_x64__b0ra4bp6jsp6c/Julia/julialauncher.exe'

Perhaps there is some conflict with juliaup?

OK, that looks like the same kind of thing that happened for me with Python. I use the standard Julia installer from julialang.org, which puts julia.exe in the path I indicated earlier. Maybe you could adjust the Cygwin path so that the real executable takes precedence?

This one I can’t confirm.
My Julia 1.9.0 installed with juliaup runs without problems in a cygwin64 Terminal with bash:

Oli@OLISPC ~
$ julia
The latest version of Julia in the `release` channel is 1.9.1+0.x64.w64.mingw32. You currently have `1.9.0+0.x64.w64.mingw32` installed. Run:

  juliaup update

to install Julia 1.9.1+0.x64.w64.mingw32 and update the `release` channel to that version.
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.9.0 (2023-05-07)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia>

The PATH where julia is found is from:

/cygdrive/c/Users/Oli/AppData/Local/Microsoft/WindowsApps

like yours.
But those executables there are just links:

$ ls -la /cygdrive/c/Users/Oli/AppData/Local/Microsoft/WindowsApps/julia
lrwxrwxrwx 1 Oli Kein 113 May 12 20:34 /cygdrive/c/Users/Oli/AppData/Local/Microsoft/WindowsApps/julia 
-> 
/cygdrive/c/Program Files/WindowsApps/JuliaComputingInc.Julia_1.10.0.0_x64__xxp6kd97rza1c/Julia/julialauncher.exe

as you found out too.

So you have to check the access rights along this path:

/cygdrive/c/Program Files/WindowsApps/JuliaComputingInc.Julia_1.10.0.0_x64__xxp6kd97rza1c/Julia/julialauncher.exe

Of course you check your path which is a bit different from mine.

I just tried git bash.

I got the following error.

user@host-2 MINGW64 ~
$ julia
bash: /c/Users/user/AppData/Local/Microsoft/WindowsApps/julia: Permission denied

Then I went to run julia in Windows terminal to find where the real julia executable is.

julia> Base.julia_cmd()
`'C:\Users\user\.julia\juliaup\julia-1.9.1+0.x64.w64.mingw32\bin\julia.exe' ...

Then I tried to run this in git bash:

$ /c/Users/user/.julia/juliaup/julia-1.9.1+0.x64.w64.mingw32/bin/julia.exe
julia> println("Hello World")
Hello World

That works for me.

Just one word of warning: don’t mess with permissions or anything else with the files in Program Files/WindowsApps/JuliaComputingInc.Julia_1.10.0.0_x64__xxp6kd97rza1c/Julia/julialauncher.exe. That stuff is supposed to be completely managed by the MSIX engine and very much an implementation detail of that system. The way to launch things when you installed Julia from the Windows Store is to use the execution alias at AppData/Local/Microsoft/WindowsApps/julia. Note also that an execution alias is not a symbolic link. It has much more information that controls in what kind of container environment Windows launches stuff (none for us).

The original issue to me looks somehow related to the juliaup launcher, as I don’t get that behavior if I just launch the binaries from the .julia/juliaup folder. Probably best to open an issue over at GitHub - JuliaLang/juliaup: Julia installer and version multiplexer.

I think I would also suggest to just use Windows Terminal with the auto-installed Git Bash profile in it instead of the mintty terminal that ships with git for now. That seems to work for me.

The second (and probably entirely unrelated) problem seems to be the permission problem when trying to launch the julia execution alias on @ufechner7’s system from cygwin. That should ideally be a separate issue over at the Juliaup repo. I don’t have cygwin installed, so can’t repo that at the moment.

1 Like

The following works for me:

  1. uninstall juliaup and Julia using the Windows start menu: it should show the option uninstall for Julia
  2. install jill: pip install jill
  3. install Julia with jill: jill install 1.9
  4. add the following path to the PATH variable of your local user: C:\Users\uwefechner\AppData\Local\julias\bin On your machine it will be slightly different, but jill tells you the correct path to add.
  5. lauch git bash and type cd ~/AppData/Local/julias/bin
  6. create a file with the name julia and the following content:
#!/bin/bash
julia.cmd $@

Now Julia should work fine in git bash, and if you switch the Julia version with jill it will also use the correct version in git bash.

Summary: Currently Julia installed via juliaup is incompatible with git bash on Windows, if you installed Julia in a different way it just works.

2 Likes

I think technically the problem seems to be with the mintty terminal that ships with git for Windows. git bash when started in the Windows Terminal seems to work fine with juliaup on my system.

2 Likes