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

Is it possible to integrate GitHub Desktop inside WSL2 #13953

Open
TonyTheFerg opened this issue Feb 20, 2022 · 18 comments
Open

Is it possible to integrate GitHub Desktop inside WSL2 #13953

TonyTheFerg opened this issue Feb 20, 2022 · 18 comments

Comments

@TonyTheFerg
Copy link

Describe the feature or problem you’d like to solve

More of a support request

Is it possible, and if so is there documentation on how to set up GitHub Desktop inside WSL2?

@tsvetilian-ty
Copy link
Member

Hello @TonyTheFerg 👋

Yes, you can 😄 There are two ways to approach the problem. You can access the subsystem fs or use your windows fs in the subsystem.

Access Subsystem FS

  1. Open Github Desktop
  2. When you choose your "Local path," the directory you peek, should look something like this \\wsl.localhost\{DISTRO}\home (If you don't see it in the explorer, click on the address bar and paste it) after that you should see the subsystem fs and pick directory from it.

image

Use Windows FS from subsystem distro

From your distro, you can access the windows fs

  1. Open your WSL distro
  2. Navigate to your system root
cd /
  1. Open mnt directory
cd mnt/
  1. You should be able to see your Windows FS (your drives)

@SharakPL
Copy link

SharakPL commented Mar 23, 2022

2. When you choose your "Local path," the directory you peek, should look something like this \\wsl.localhost\{DISTRO}\home

Actually it should be \\wsl$\{DISTRO}\.......

But cloning this way doesn't create repo in WSL properly. When you hit Open in Visual Studio Code you don't get typical linux project with WSL server installed for it, linux filesystem, linux shell and workspace path like /home/username/github/myrepo but it's opened directly in windows with eg. powershell at \\wsl$\Ubuntu\home\username\github\myrepo and you should never access wsl files directly through windows filesystem so this is bad 😱

@johannesschobel
Copy link

This does not work on Windows.
GitHub Desktop is installed on the Host System (i.e., Windows), the Git Project itself, however, is located in the WSL2 subsystem (i.e., Ubuntu 20.x).

When i try to add the Repository with the path

\\wsl$\Ubuntu-20.04\home\X\projects\Y

i can see all file changes and the commit history properly.
However, when trying to commit new files, i get the following error:

"\\wsl$\Ubuntu-20.04\home\X\projects\Y"
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported. Defaulting to Windows directory.

Mapping the \\wls$\... path to a network drive (i.e., Z:\) does not work either.. Any suggestions from your side?
All the best,
Johannes

@johannesschobel
Copy link

I have found a possible solution for this issue:
You need to manually create a new Windows registry key:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor\DisableUNCCheck

with the type DWord and set the value to 1.
This will then disable the UNC Check for paths.

The solution worked for me, as i can not execute Husky GitHooks from within GitHub Desktop.

Hope this helps,
All the best,

@dsaints2344
Copy link

dsaints2344 commented Nov 14, 2022

Hello @TonyTheFerg 👋

Yes, you can 😄 There are two ways to approach the problem. You can access the subsystem fs or use your windows fs in the subsystem.

Access Subsystem FS

  1. Open Github Desktop
  2. When you choose your "Local path," the directory you peek, should look something like this \\wsl.localhost\{DISTRO}\home (If you don't see it in the explorer, click on the address bar and paste it) after that you should see the subsystem fs and pick directory from it.

image

Use Windows FS from subsystem distro

From your distro, you can access the windows fs

  1. Open your WSL distro
  2. Navigate to your system root
cd /
  1. Open mnt directory
cd mnt/
  1. You should be able to see your Windows FS (your drives)

The first method works, but given the WSL2 implementation, whenever you have to run pre-commit script (like husky), it doesn't work through Github desktop. It works through the WSL2 terminal though

@hongda-zhu
Copy link

hongda-zhu commented Feb 22, 2023

Hello @TonyTheFerg 👋

Yes, you can 😄 There are two ways to approach the problem. You can access the subsystem fs or use your windows fs in the subsystem.

Access Subsystem FS

  1. Open Github Desktop
  2. When you choose your "Local path," the directory you peek, should look something like this \\wsl.localhost\{DISTRO}\home (If you don't see it in the explorer, click on the address bar and paste it) after that you should see the subsystem fs and pick directory from it.

image

Use Windows FS from subsystem distro

From your distro, you can access the windows fs

  1. Open your WSL distro
  2. Navigate to your system root
cd /
  1. Open mnt directory
cd mnt/
  1. You should be able to see your Windows FS (your drives)

The first method does not work for me, I can't find the directory and also when I manually add the directory , I get the error fatal: could not create leading directories of '\wsl.localhost\Ubuntu-20.04\home\XXXX\XXXX': Permission denied

Regards

@claudioantonio
Copy link

It would be awesome to have a real integration between github desktop and wsl2...

@schummar
Copy link

I want to try to make a real integration happen. The basis for this is delegating git operations to git within WSL, which should solve some of the fundamental problems that come with the cross-filesystem workaround that people have been using. See desktop/dugite#532

I am awaiting feedback at the moment, so we'll have to see what concerns and edge cases come up with that solution.

@ecwootten
Copy link

ecwootten commented May 12, 2023

Any suggestions on how to solve authentication issues using Github Desktop with WSL2? I've installed it and added repos I already had cloned locally. But any attempt to fetch, etc, hits authentication errors (logs attached).

I've set the ssh-agent running, and added my key (though no idea why it didn't find it, because it's in the default location with the default name and correct permissions). I've tried launching the github desktop .exe directly from the WSL2 terminal. I have signed out and back in again. I can fetch and so on fine from the WSL2 command line.

Ideally I'd prefer Github Desktop to prompt for my SSH password each time. But for starters I'd just like it to work at all :)

2023-05-12.desktop.production.log

@TonyTheFerg
Copy link
Author

Very cool to see movement on this! I am running DDEV now, so I have become accustomed to their git integration UX, but this would still be a great feature!

@JosephusPaye
Copy link

JosephusPaye commented May 18, 2023

It's possible to use this Linux distribution of GitHub Desktop from inside WSL2 if you have setup support for WSL GUI apps.

Here's what worked for me:

  1. First make sure you have set up WSL2 GUI support as described here: https://learn.microsoft.com/en-us/windows/wsl/tutorials/gui-apps

  2. From a WSL2 terminal, install GitHub Desktop for Linux:

    # Replace <deb_url> with latest deb download url from https://github.com/shiftkey/desktop/releases/latest
    wget <deb_url> -o github-desktop.deb
    
    # Install gdebi (a tool for installing deb files). Skip if you already have gdebi installed.
    sudo apt-get install gdebi-core 
    
    # Install the downloaded deb
    sudo gdebi github-desktop.deb
  3. After installing you can launch the app using the github-desktop command from a WSL2 terminal. I use this little snippet to launch the app in the background, and ignore all output (you can wrap this in an alias for convenience):

    nohup github-desktop > /dev/null 2>&1 &

Caveats

I wasn't able to get the sign in to work (the redirect from the browser was not getting back to the app running in WSL). I was able to skip the sign in step, and use the app without the features that require sign in.

@justinaslelys
Copy link

Any suggestions on how to solve authentication issues using Github Desktop with WSL2? I've installed it and added repos I already had cloned locally. But any attempt to fetch, etc, hits authentication errors (logs attached).

I've set the ssh-agent running, and added my key (though no idea why it didn't find it, because it's in the default location with the default name and correct permissions). I've tried launching the github desktop .exe directly from the WSL2 terminal. I have signed out and back in again. I can fetch and so on fine from the WSL2 command line.

Ideally I'd prefer Github Desktop to prompt for my SSH password each time. But for starters I'd just like it to work at all :)

2023-05-12.desktop.production.log

The following comment helped me - basically you need to have a secondary ssh key set up on your Windows machine which can be set up using Git GUI:
#15902 (comment)

@mg-coates
Copy link

Hello @TonyTheFerg 👋

Yes, you can 😄 There are two ways to approach the problem. You can access the subsystem fs or use your windows fs in the subsystem.

Access Subsystem FS

  1. Open Github Desktop
  2. When you choose your "Local path," the directory you peek, should look something like this \\wsl.localhost\{DISTRO}\home (If you don't see it in the explorer, click on the address bar and paste it) after that you should see the subsystem fs and pick directory from it.

image

Use Windows FS from subsystem distro

From your distro, you can access the windows fs

  1. Open your WSL distro
  2. Navigate to your system root
cd /
  1. Open mnt directory
cd mnt/
  1. You should be able to see your Windows FS (your drives)

Just stumbled across this post. Thanks greatly for the tip.
I just wanted to add one additional consideration for those that come after me is how line feeds are handled.
Github Desktop will on checkout convert unix linefeeds to windows with no option through the GUI to change this behaviour. This probably won't matter for a lot of projects, but for the project I'm working on resulted in '\r': command not found error in make.

If you've got git on the command line, run git config --global core.autocrlf false to stop the conversion (use input rather than false if you need files converted on checkin because you're using a windows editor).
Otherwise, edit C:\Users\USER_NAME.gitconfig & add

[core]
    autocrlf = false

@Stanzilla
Copy link

Stanzilla commented Oct 12, 2023

The thing you are going to be stuck on is the login though.

You can use wslu (GitHub) and then set xdg-settings set default-web-browser wslview.desktop so the sign-in prompt gets opened in your Windows browser but then you are stuck on the part where it has to send the response back.

@rr-todd-murchison
Copy link

You know, with WSL2, you can simply install the Linux version of GitHub Desktop in your WSL2 Linux distribution. This works well if your repositories, Git config, etc. are in WSL2. No need to worry about line endings, directory paths, etc. It's all just natively in Linux with the GUI showing up like a Windows app. :-)

https://github.com/shiftkey/desktop?tab=readme-ov-file#installation-via-package-manager

@schneckbear
Copy link

It's possible to use this Linux distribution of GitHub Desktop from inside WSL2 if you have setup support for WSL GUI apps.

Here's what worked for me:

  1. First make sure you have set up WSL2 GUI support as described here: https://learn.microsoft.com/en-us/windows/wsl/tutorials/gui-apps
  2. From a WSL2 terminal, install GitHub Desktop for Linux:
    # Replace <deb_url> with latest deb download url from https://github.com/shiftkey/desktop/releases/latest
    wget <deb_url> -o github-desktop.deb
    
    # Install gdebi (a tool for installing deb files). Skip if you already have gdebi installed.
    sudo apt-get install gdebi-core 
    
    # Install the downloaded deb
    sudo gdebi github-desktop.deb
  3. After installing you can launch the app using the github-desktop command from a WSL2 terminal. I use this little snippet to launch the app in the background, and ignore all output (you can wrap this in an alias for convenience):
    nohup github-desktop > /dev/null 2>&1 &

Caveats

I wasn't able to get the sign in to work (the redirect from the browser was not getting back to the app running in WSL). I was able to skip the sign in step, and use the app without the features that require sign in.

Thanks for recomending this. it worked for me.

I managed to sign in by installing google chrome browser in the distro as mentioned here. It won't open by default when click sign within github Desktop. So you must

  • open browser manually
  • go to github website and sign in.
  • open github desktop again and click sign in button. it will sign you in automatically.

@rr-todd-murchison
Copy link

Even though I mostly use Chrome in Windows I also installed the Chrome browser in Linux in WSL2. With Chrome installed in WSL2 as well I was able to do the normal sign in flow.

@quinn
Copy link

quinn commented Mar 29, 2024

for me, github desktop tries to convert line endings to CRLF in the diff when i try to do it like this

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

17 participants