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

WSL compatibility #16378

Open
wants to merge 12 commits into
base: development
Choose a base branch
from

Conversation

schummar
Copy link

Together with desktop/dugite#532, this potentially closes

Description

Depends on desktop/dugite#532. Together this will introduce compatibility with WSL. While you can just open a repository in WSL by entering its UNC path, this never worked right for me and many others. It suffers from

  • Bad performance
  • Checking out with wrong line endings (I know, can be configured, but it doesn't just work™)
  • Wrongly detected changes
  • Git hooks don't work

My suggestion to solve all this simple: Run git within WSL wsl.exe -e git .... The most important part is contained in the Dugite pull request. Assuming that gets merged, this PR fixes a few edge cases connected to it and improves WSL compatibility in regards to external editors and shells by

  • fixing discarding files when no trash is available
  • adding an option to open WSL repositories in Vs Code Remote directly
  • adding an option to open WSL repositories in WSL shell, even if another shell is selected for other repos

There are certainly some things to be discussed and edge cases to be fixed. I'm happy to make adjustments based on your feedback and hope that you can see the advantage of taking this route.

Screenshots

image

Release notes

@niik
Copy link
Member

niik commented Apr 3, 2023

Hey @schummar, thanks for wanting to contribute! I wanted to set some expectations here that we will have to have a thorough discussion internally before we can provide any feedback here and that might take a while. GitHub Desktop ships with a specific custom built version of Git because we have to be able to rely on specific features being present, localization being turned off, and specific formats of Git output that could (and do) change between versions etc. Outsourcing that to a Git version we don't have control over would be fragile at best and poses other questions around ensuring compatible versions of Git LFS being installed etc. We would likely want to run a specific dugite version within the WSL environment.

I certainly empathize with the friction you're encountering running Desktop alongside a WSL environment and it's clear that you've done a thorough job of going through the codebase to create a comprehensive solution but I want to set reasonable expectations that we won't have a lot of time to get into reviewing and considering this work in the short term.

@schummar
Copy link
Author

schummar commented Apr 3, 2023

@niik thanks for the reply. I didn't expect this to be quick. Of course this is a big decision and will take time, no worries.

I made the Pull Request also as a POC. The existing discussions regarding WSL were mostly "use UNC paths, it's working fine" and some tweaks and workarounds to make it somewhat workable. But that approach is fundamentally flawed and another idea is needed. I wanted to show that running git withing WSL might be such an idea. WSL is such a big deal for developers using Windows, so it deserves first class support in tools. 😉

Your point about using a specific git version makes sense. I see no issue with using an embedded git version also for WSL as well. I'll try to include this in the Dugite PR.

Whenever you had time to discuss it and if you decide that the solution has potential, I'll be happy to work with you to iron out the problems and make it production ready.

@schummar
Copy link
Author

schummar commented Apr 3, 2023

Your point about using a specific git version makes sense. I see no issue with using an embedded git version also for WSL as well. I'll try to include this in the Dugite PR.

I have updated the Dugite PR

@schummar
Copy link
Author

schummar commented Apr 26, 2023

A little script for anyone who wants to try it out:

git clone https://github.com/schummar/dugite.git
git clone https://github.com/schummar/desktop.git

cd dugite
git checkout origin/feature/wslGit
yarn
yarn build
yarn link

cd ../desktop
git checkout origin/feature/wslCompatibility
yarn
cd app
yarn link dugite
cd ..
yarn build:prod

@SynthLuvr
Copy link

I can't comment on the code because I'm unfamiliar with this repository, but I've been testing this and the user experience is vastly improved. Everything is working smoothly so far.

@SynthLuvr
Copy link

SynthLuvr commented May 10, 2023

I've encountered a problem where an error is caused triggering a pre-commit hook:

resources/app/git/linux-x64/libexec/git-core/git', 'fetch', 'origin', '--tags')
return code: 128
stdout: (none)
stderr:
    git: 'remote-https' is not a git command. See 'git --help'.
    
    The most similar command is
	    remote-http

Edit: This is an edge case where GitHub Desktop errors on the first commit installing git hooks. After committing using git in the terminal, the hooks get set up properly and then GitHub Desktop works correctly for subsequent commits.

@schummar
Copy link
Author

It seems that problem has been discussed a lot already in other issues quite a bit, so it's probably not connected to the WSL integration. See #10345 (comment).

But if you can provide a repo that demonstrates the issue, I will have a look.

@spankandex
Copy link

what do we need to have this in the master branch? it's impossible to use github for desktop with a repo in WSL

@SynthLuvr
Copy link

I've been using this branch. I do not use the main branch. Getting this merged into main branch is ideal so I can continue to get regular updates.

@schummar
Copy link
Author

schummar commented Jul 8, 2023

what do we need to have this in the master branch? it's impossible to use github for desktop with a repo in WSL

I am currently waiting for feedback from the team. As @niik said, it can take some time. Maybe he can provide an update some time ;-)

Btw. I merge the latest main/development branches from time to time, but be aware that using a build from this branch might be outdated and auto update can't work either.

@thesyntaxinator
Copy link

A little script for anyone who wants to try it out:

git clone https://github.com/schummar/dugite.git
git clone https://github.com/schummar/desktop.git

cd dugite
git checkout origin/feature/wslGit
yarn
yarn build
yarn link

cd ../desktop
git checkout origin/feature/wslCompatibility
yarn
cd app
yarn link dugite
cd ..
yarn build:prod

Should this be run in WSL or windows terminal?

@schummar
Copy link
Author

In Windows Terminal.

@sarim
Copy link

sarim commented Jul 28, 2023

I haven't looked at the details of this PR, but a good implementation for similar thing is to look at vscode. Actual vscode logic remains with vscode-server, and it's can run in any remote machine. Vscode is just the UI user interacts with. Github desktop could adopt a similar architure. Though realistically its seems kinda unfeasible considering desktop's team size / target audience.

I've been using the shiftkey/desktop fork in wsl from the start of wsl2. It is my daily driver for software development. Needed some minor issue solving from time to time, but overall it just works. Especially after introduction of WSLg, using linux version of desktop just feels more realistic.

@thesyntaxinator
Copy link

In Windows Terminal.

How do I add a repository located on WSL? I'm unable to see WSL directories in the folder selector that pops up when I click "Browse".

@schummar
Copy link
Author

I haven't looked at the details of this PR, but a good implementation for similar thing is to look at vscode. Actual vscode logic remains with vscode-server, and it's can run in any remote machine. Vscode is just the UI user interacts with. Github desktop could adopt a similar architure. Though realistically its seems kinda unfeasible considering desktop's team size / target audience.

Yes, that would be a valid approach too. But a lot more effort, which is probably not needed for this use case.

I've been using the shiftkey/desktop fork in wsl from the start of wsl2. It is my daily driver for software development. Needed some minor issue solving from time to time, but overall it just works. Especially after introduction of WSLg, using linux version of desktop just feels more realistic.

That works generally, but I think the user experience is not optimal. WSLg windows are not as performant and seamless as native windows and if you work both on the Windows side and in WSL, you'd have to have the app installed twice.

@schummar
Copy link
Author

In Windows Terminal.

How do I add a repository located on WSL? I'm unable to see WSL directories in the folder selector that pops up when I click "Browse".

Showing the WSL drives in Explorer has been working occasionally for me, but it's indeed very flaky. What should always work is to put the path directly into the file picker's url. E.g. \\wsl.localhost\Ubuntu where "Ubuntu" is the name of your WSL instance.

@omzy
Copy link

omzy commented Dec 6, 2023

Is there any update on this? I'm using GitHub Desktop with a WSL mounted drive and every operation is way too slow, compared to non-WSL mounted drives.

@sarim
Copy link

sarim commented Dec 6, 2023

Is there any update on this? I'm using GitHub Desktop with a WSL mounted drive and every operation is way too slow, compared to non-WSL mounted drives.

I think this is still experimental/under development? If you need a stable daily driver, install the linux version https://github.com/shiftkey/desktop and store code inside main wsl drive.

@schummar
Copy link
Author

schummar commented Dec 7, 2023

I haven't heard anything new. To proceed I would first need feedback from the team on whether they agree with the approach and what steps would need to be taken to make it production ready.

@niik can you share any update? Or what do you think are the chance that this will be discussed?

@AlejandroAkbal
Copy link

So sad that this awesome pull request does not get any attention, I would really love this to be merged and enjoy WSL development

@SynthLuvr
Copy link

What's holding this back from being merged? I've been using this for a year without issue

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

Successfully merging this pull request may close these issues.

None yet

8 participants