Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WSLGit doesn't work #33

Closed
nicholasio opened this issue Apr 26, 2018 · 16 comments
Closed

WSLGit doesn't work #33

nicholasio opened this issue Apr 26, 2018 · 16 comments

Comments

@nicholasio
Copy link

Hi, I'm not sure if I'm missing something but the .exe doesn't work at all, I have downloaded it and placed in my PATH and I can't execute git from Powershell nor VSCode, no matter what command I pass to wsl it just doesn't output anything.

I'm running WIndows 10 Pro 1709. Using the new WSL enviroment (Ubuntu Distribution)

@nicholasio
Copy link
Author

So I eventually figured out what was going on, for some reason I couldn't get bash.exe to load bash directly and I had to pass an sort of id to it eg: bash.exe"{12345678-1234-5678-0123-456789abcdef}"
I was able to fix this behavior by running: wslconfig.exe /s Legacy. However I couldn't get wslgit v6 to work properly when I run wslgit (v6) it just loads bash instead of running git, it only worked for me using v5.

@andy-5
Copy link
Owner

andy-5 commented Apr 27, 2018

Good that you got it working with version 0.5.0 at least. However, I wonder why it doesn't work with the latest release.

It seems that you have the legacy WSL environment installed (i.e. not installed from the Store), and wslconfig.exe /s Legacy activated that as default.
Version 0.6.0 of wslgit switched to wsl.exe for calling into WSL, previously bash.exe was used, but that is deprecated. Maybe wsl.exe does not support the legacy environment - I'm not sure.

Could you migrate to a WSL distro installed from the Microsoft Store? After you installed it from the Store, you should see it with wslconfig.exe /l. You can then switch the default with e.g. wslconfig.exe /s Ubuntu. See here for more documentation on wslconfig.exe.

@sshrshnv
Copy link

I have an installed Debian from the Store, but wslgit 0.6.0 doesn't work too.

@andy-5
Copy link
Owner

andy-5 commented Apr 27, 2018

@sh-a-v Do you have multiple distributions installed, or just Debian? Can you show the output of wslconfig.exe /l?

What exactly does doesn't work mean? Is there any error? What is the output if you run wslgit.exe --version from the command line?

Also, does manually running the following commands work?

wsl.exe bash -ic "git --version"
wsl.exe git --version

@sshrshnv
Copy link

  1. just Debian
wslconfig.exe /l

Windows Subsystem for Linux Distributions:
Debian (Default)
  1. "There are no active source control providers" in vscode, but I have git repo
wslgit.exe --version

git version 2.11.0
wsl.exe bash -ic "git --version"

git version 2.11.0
wsl.exe git --version

git version 2.11.0

@andy-5
Copy link
Owner

andy-5 commented Apr 27, 2018

@sh-a-v Ok, so it works just fine from the command line for you (which seems different from the original issue).

What is the output in VS Code in the "Output" panel for "Git"? The first few lines should tell the git binary used, the git version and the repository. Are there any errors?

Did you paste the output in your answer unmodified? Because there is an empty line between the command and the output, which shouldn't be there. Did you make any modifications to .bashrc or similar files? Note that there should be no additional output from the shell, otherwise VS Code cannot parse the output of git.

@sshrshnv
Copy link

  1. Output:
Looking for git in: C:\Users\Alexander\.vscode\wslgit.exe
Using git 2.11.0 from C:\Users\Alexander\.vscode\wslgit.exe
> git rev-parse --show-toplevel
> git config --get commit.template
Open repository: \c\Users\Alexander\Projects\alfa-mortgage
> git status -z -u
> git rev-parse --show-toplevel
> git config --get commit.template
Open repository: \c\Users\Alexander\Projects\alfa-mortgage
> git status -z -u
> git rev-parse --show-toplevel
> git rev-parse --show-toplevel
> git config --get commit.template
Open repository: \c\Users\Alexander\Projects\alfa-mortgage
> git status -z -u
> git rev-parse --show-toplevel
> git rev-parse --show-toplevel
> git rev-parse --show-toplevel
> git rev-parse --show-toplevel
> git rev-parse --show-toplevel
> git config --get commit.template
Open repository: \c\Users\Alexander\Projects\alfa-mortgage
> git status -z -u
> git rev-parse --show-toplevel
> git rev-parse --show-toplevel
> git config --get commit.template
Open repository: \c\Users\Alexander\Projects\alfa-mortgage
> git status -z -u
> git rev-parse --show-toplevel
> git rev-parse --show-toplevel
> git rev-parse --show-toplevel
> git rev-parse --show-toplevel
> git config --get commit.template
Open repository: \c\Users\Alexander\Projects\alfa-mortgage
> git status -z -u
> git rev-parse --show-toplevel
> git rev-parse --show-toplevel
> git rev-parse --show-toplevel
> git config --get commit.template
Open repository: \c\Users\Alexander\Projects\alfa-mortgage
> git status -z -u
> git rev-parse --show-toplevel
> git rev-parse --show-toplevel
> git rev-parse --show-toplevel
> git rev-parse --show-toplevel
> git rev-parse --show-toplevel
> git config --get commit.template
Open repository: \c\Users\Alexander\Projects\alfa-mortgage
> git status -z -u
> git rev-parse --show-toplevel

There aren't any errors.

  1. I added empty lines there in form. Yes, I made modifications to .bashrc
# ~/.bashrc: executed by bash(1) for non-login shells.                                                                            
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)                                                        
# for examples                                                                                                                    
                                                                                                                                  
# If not running interactively, don't do anything                                                                                 
case $- in                                                                                                                        
    *i*) ;;                                                                                                                       
      *) return;;                                                                                                                 
esac                                                                                                                              
                                                                                                                                  
# don't put duplicate lines or lines starting with space in the history.                                                          
# See bash(1) for more options                                                                                                    
HISTCONTROL=ignoreboth                                                                                                            
                                                                                                                                  
# append to the history file, don't overwrite it                                                                                  
shopt -s histappend                                                                                                               
                                                                                                                                  
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)                                                             
HISTSIZE=1000                                                                                                                     
HISTFILESIZE=2000                                                                                                                 
                                                                                                                                  
# check the window size after each command and, if necessary,                                                                     
# update the values of LINES and COLUMNS.                                                                                         
shopt -s checkwinsize                                                                                                             
                                                                                                                                  
# If set, the pattern "**" used in a pathname expansion context will                                                              
# match all files and zero or more directories and subdirectories.                                                                
#shopt -s globstar                                                                                                                
                                                                                                                                  
# make less more friendly for non-text input files, see lesspipe(1)                                                               
#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"                                                                     
                                                                                                                                  
# set variable identifying the chroot you work in (used in the prompt below)                                                      
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then                                                                 
    debian_chroot=$(cat /etc/debian_chroot)                                                                                       
fi                                                                                                                                
                                                                                                                                  
# set a fancy prompt (non-color, unless we know we "want" color)                                                                  
case "$TERM" in                                                                                                                   
    xterm-color|*-256color) color_prompt=yes;;                                                                                    
esac                                                                                                                              
                                                                                                                                  
# uncomment for a colored prompt, if the terminal has the capability; turned                                                      
# off by default to not distract the user: the focus in a terminal window                                                         
# should be on the output of commands, not on the prompt                                                                          
#force_color_prompt=yes                                                                                                           
                                                                                                                                  
if [ -n "$force_color_prompt" ]; then                                                                                             
    if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then                                                                     
        # We have color support; assume it's compliant with Ecma-48                                                               
        # (ISO/IEC-6429). (Lack of such support is extremely rare, and such                                                       
        # a case would tend to support setf rather than setaf.)                                                                   
        color_prompt=yes                                                                                                          
    else                                                                                                                          
        color_prompt=                                                                                                             
    fi                                                                                                                            
fi                                                                                                                                
                                                                                                                                                                                                                                                                                                                                                               
source ~/.git-prompt.sh                                                                                                           
PS1='[${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]${PWD#/c/Users/Alexander/}\[\033[00m\]$(__git_ps1 " (%s)")]\$ '
unset color_prompt force_color_prompt                                                                                             
                                                                                                                                  
# If this is an xterm set the title to user@host:dir                                                                              
case "$TERM" in                                                                                                                   
xterm*|rxvt*)                                                                                                                     
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"                                                              
    ;;                                                                                                                            
*)                                                                                                                                
    ;;                                                                                                                            
esac                                                                                                                              
                                                                                                                                  
# enable color support of ls and also add handy aliases                                                                           
if [ -x /usr/bin/dircolors ]; then                                                                                                
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"                                         
    alias ls='ls --color=auto'                                                                                                    
    #alias dir='dir --color=auto'                                                                                                 
    #alias vdir='vdir --color=auto'                                                                                               
                                                                                                                                  
    #alias grep='grep --color=auto'                                                                                               
    #alias fgrep='fgrep --color=auto'                                                                                             
    #alias egrep='egrep --color=auto'                                                                                             
fi                                                                                                                                
                                                                                                                                  
# colored GCC warnings and errors                                                                                                 
#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'                                           
                                                                                                                                  
# some more ls aliases                                                                                                            
#alias ll='ls -l'                                                                                                                 
#alias la='ls -A'                                                                                                                 
#alias l='ls -CF'                                                                                                                 
                                                                                                                                  
# Alias definitions.                                                                                                              
# You may want to put all your additions into a separate file like                                                                
# ~/.bash_aliases, instead of adding them here directly.                                                                          
# See /usr/share/doc/bash-doc/examples in the bash-doc package.                                                                   
                                                                                                                                  
if [ -f ~/.bash_aliases ]; then                                                                                                   
    . ~/.bash_aliases                                                                                                             
fi                                                                                                                                
                                                                                                                                  
# enable programmable completion features (you don't need to enable                                                               
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile                                                              
# sources /etc/bash.bashrc).                                                                                                      
if ! shopt -oq posix; then                                                                                                        
  if [ -f /usr/share/bash-completion/bash_completion ]; then                                                                      
    . /usr/share/bash-completion/bash_completion                                                                                  
  elif [ -f /etc/bash_completion ]; then                                                                                          
    . /etc/bash_completion                                                                                                        
  fi                                                                                                                              
fi                                                                                                                                
                                                                                                                                  
export NVM_DIR="$HOME/.nvm"                                                                                                       
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm                                                                
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion                              
                                                                                                                                  
export DOCKER_HOST=tcp://0.0.0.0:2375                                                                                             
sudo mount --bind /mnt/c /c                                                                                                       
                                                                                                                                  
export PATH=~/.local/bin:$PATH                                                                                                    
                                                                                                                                  
export SERVICES=api                                                                                                                                                                                                                       

@andy-5
Copy link
Owner

andy-5 commented Apr 27, 2018

Looks good, except for the path of the repository \c\Users\... which should be c:\Users\....

I think the problem is the bind mount in .bashrc. This was already discussed in #10 (comment) (see other answers for solutions).

Another solution could be to set the new environment variable WSLGIT_USE_INTERACTIVE_SHELL to false, see the Readme for more information.

@nicholasio
Copy link
Author

nicholasio commented Apr 27, 2018

@andy-5 Thanks. It's weird because I did installed Ubuntu from the store and in fact I see Ubuntu in the list of distributions however bash only works with Legacy distribution.

One thing to note though: wsl does work fine when I call it directly from powershell, I'm able to run linux commands from powershell just fine with it, the issue seems to be living around the fact that wslgit.exe is not passing the arguments to wsl and thus just launching bash (which is exactly what happens if I just type wsl).

@andy-5
Copy link
Owner

andy-5 commented Apr 30, 2018

@nicholasio That's weird, maybe it helps to uninstall both Ubuntu and the Legacy distribution (if you don't need it anymore), and reinstall Ubuntu afterwards. There seem to be some problems if both are installed at the same time, e.g. microsoft/WSL#2590

Otherwise, what happens when you run the following two commands manually (from cmd or powershell)?

wsl.exe bash -ic "git --version"
wsl.exe git --version

Did you make any modifications to .bashrc or similar bash startup files?

@nicholasio
Copy link
Author

nicholasio commented Apr 30, 2018

Only the second command outputs the git version, The first command actually loads my zsh shell. I'm using Oh-My-ZSH and I'm loading zsh from .bashrc. maybe that is the problem. But unsure why it works fine with v5.

@andy-5
Copy link
Owner

andy-5 commented Apr 30, 2018

Yes, that could be the problem. But I'm also not sure why it works with the older version.

But if the second command works, you can try setting the environment variable WSLGIT_USE_INTERACTIVE_SHELL to false (see Readme). Whis this setting, the latest version of wslgit executes the second variant of the command (without invoking an interactive Bash shell).

@nicholasio
Copy link
Author

Setting WSLGIT_USE_INTERACTIVE_SHELL to false did the trick! Thank you!

@andy-5
Copy link
Owner

andy-5 commented May 2, 2018

Great to hear that it works now!

@mheisig
Copy link

mheisig commented Aug 13, 2018

I'm having the exact same problem, but setting WSLGIT_USE_INTERACTIVE_SHELL to false is having no effect. I'm in a git repo in VS Code with modified files but the VS Code Source Control panel just says There are no active source control providers

This is the output from VS Code:

Looking for git in: C:\Users\Matt\bin\wslgit.exe
Using git 2.17.0 from C:\Users\Matt\bin\wslgit.exe
> git rev-parse --show-toplevel
> git config --get commit.template
Open repository: \c\Users\Matt\dev\<removed>
> git status -z -u
> git rev-parse --show-toplevel
> git config --get commit.template
Open repository: \c\Users\Matt\dev\<removed>
> git status -z -u
> git rev-parse --show-toplevel
> git rev-parse --show-toplevel
> git rev-parse --show-toplevel
> git config --get commit.template
Open repository: \c\Users\Matt\dev\<removed>
> git status -z -u
> git rev-parse --show-toplevel
> git config --get commit.template
Open repository: \c\Users\Matt\dev\<removed>
> git status -z -u
> git rev-parse --show-toplevel
> git config --get commit.template
Open repository: \c\Users\Matt\dev\<removed>
> git status -z -u
> git rev-parse --show-toplevel
> git config --get commit.template
Open repository: \c\Users\Matt\dev\<removed>
> git status -z -u
> git rev-parse --show-toplevel
> git rev-parse --show-toplevel
> git rev-parse --show-toplevel
> git config --get commit.template
Open repository: \c\Users\Matt\dev\<removed>
> git status -z -u
> git rev-parse --show-toplevel
> git config --get commit.template
Open repository: \c\Users\Matt\dev\<removed>
> git status -z -u
> git rev-parse --show-toplevel
> git rev-parse --show-toplevel
> git rev-parse --show-toplevel
> git rev-parse --show-toplevel
> git rev-parse --show-toplevel
> git rev-parse --show-toplevel
> git rev-parse --show-toplevel
> git rev-parse --show-toplevel
> git rev-parse --show-toplevel
> git rev-parse --show-toplevel
> git config --get commit.template
Open repository: \c\Users\Matt\dev\<removed>
> git status -z -u
> git rev-parse --show-toplevel
> git config --get commit.template
Open repository: \c\Users\Matt\dev\<removed>
> git status -z -u
> git rev-parse --show-toplevel
> git config --get commit.template
Open repository: \c\Users\Matt\dev\<removed>
> git status -z -u

Executing wsl.exe bash -ic "git --version" from Powershell reports the git version as 2.17.0.

My .bashrc is the default with the exception of setting an environment variable for the DOCKER_HOST.

I have created an /etc/wsl.conf file with the following contents (which I presume is the reason for the different paths):

[automount]
root = /
options = "metadata"

I set the WSLGIT_USE_INTERACTIVE_SHELL to false and in Powershell if I run Get-ChildItem Env: it's showing that env var as set to false

Any ideas?

@andy-5
Copy link
Owner

andy-5 commented Aug 14, 2018

@mheisig The problem is the customized wsl.conf. Support for a user defined root is currently not implemented in wslgit, it always assumes drives are mounted in /mnt. There is some discussion in #12 on how to add support for that, but currently there is no implementation.

The original report above used sudo mount --bind /mnt/c /c to create the paths expected by docker. This sort of works if you start VS Code before starting a WSL shell, as noted in #34 (comment) .
Maybe you can use this as a workaround until proper support for a custom root is implemented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants