+32
Duplicate

Support Windows Subsystem for Linux (WSL)

carryyou1307 6 years ago updated by Syntevo Alex 1 year ago 40

I second this :)


WSL interoperability documentation:

https://docs.microsoft.com/en-us/windows/wsl/interop


Take not that full WSL interoperability needs every command to run under WSL in the current working directory for the project. What I mean is that invoking Git with "wsl git" (or bash -c "git") won't be enough for full interoperability. For instance, think about Git hooks that might run npm commands, those also need to run under WSL.


WSL/Windows paths also need to be converted from one to the other with "wsl wslpath":

https://github.com/Microsoft/WSL/issues/2715

What will be the minimum amount of requirements to get "wslgit" running with SmartGit?

I got it somehow working to commit inside smartgit using wsl. I use https://github.com/hangxingliu/wslgit to link into my WSL installation. Tree view and compare also works but as soon I want to push the content I get stuck in things like..D:\...> git.bat -c credential.helper=D:/.../SmartGit/lib/credentials.cmd push --porcelain --progress --recurse-submodules=check ...

as for sure the git inside wsl does nether know D:/... nor is able to run the credentials.cmd.

As smartgit also works with linux, there need to be some alternative commands. Might not be the biggest step to get it completely running ;)

I made some tweak to wslgit, now it is sort of working with Smartgit, check it out https://github.com/bread22/wslgit

+1

Bumping this as WSL2 + docker makes working with smartgit very slow indeed

I would love a good integration with WSL2. Since I moved from Linux to Windows+WSL2 I've been using the commandline again because of lack of WSL support for any Git GUI including SmartGit. 

Using WSLGIT works but is very slow and is also used for native Windows repos which causes problems. Could I suggest a compromise that it the git executable can be overridden on a per repo basis? Therefore WSL located repos can use WSLGIT but native Windows repos use the default git.

A workaround for the meantime could be to use 2 instances of SmartGit (using the portable bundle), one for the Windows repositories, one for the WSL repositories.

+2

Given this topic has been posted 3 years ago and there is now WSL2, which issues are still present? According to my understanding there are following possible combinations:

  • WSL1: access repository located on Windows file system
    => why would one use WSL's Git here instead of a Windows Git?
  • WSL1: access repository located on Linux system
    => is this possible at all with WSL1? If so, probably issues are similar to WSL2 (see below)
  • WSL2: access repository located on Windows file system
    => why would one use WSL's Git here instead of a Windows Git?
  • WSL2: access repository located on Linux system
    => most interesting case, but works only quite limited using \\wsl$\-paths

Configuration-specific problems:

  • line-ending related issues
    => "core.autocrlf=false" should be set for the repository
  • executable bits are not detected, but still compared
    => a workaround is to set "core.filemode=false" for the repository
  • Git executable inside WSL should be used
    => a simple batch file basically works:
    wsl git %*
  • requesting credentials does not work
    => The Git credential helper must be configured to e.g. "credential.helper=cache" and credentials must be configured in a way that Git won't have to ask for credentials (avoid command line prompt!)

SmartGit-specific problems when accessing \\wsl$\-paths:

  • slow refreshing due to timestamp precision issues
    => not too hard to fix in SmartGit code
  • symlinks can't be read (tested with Java 13):
    Caused by: java.nio.file.FileSystemException: \\wsl$\Ubuntu-20.04\home\marc\symlinks\links\link: Incorrect function.
    at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:92)
    at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103)
    at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:108)
    at java.base/sun.nio.fs.WindowsFileAttributeViews$Basic.readAttributes(WindowsFileAttributeViews.java:53)
    at java.base/sun.nio.fs.WindowsFileAttributeViews$Basic.readAttributes(WindowsFileAttributeViews.java:38)
    at java.base/sun.nio.fs.WindowsFileSystemProvider.readAttributes(WindowsFileSystemProvider.java:198)
    at java.base/java.nio.file.Files.readAttributes(Files.java:1842)

Thanks for getting back on this issue, Marc!

We're also heavily using WSL2 w/ Smartgit as well as PHPStorm (Jetbrains). Recently shifting to the latter due to this issue, by merging & commiting within PHPStorm, but pushing, stashing and Log-Viewing within Smartgit. Kind of odd, but in the end it works.

As you've already gussed, scenario #4 (Smartgit on Windows, repository within \\wsl$\) would be our case, and we'd greatly appreciate smartgit being able to communicate with WSLs git executable. I've tried both wslgit workarounds and consider them kind of hacky, running into credential helper issues all the time. Would love to see Smartgit work seamlessly together w/ WSL! :)

(Even though, as a dev. myself I do know how annoying this question might be, but is there any chance to get an ETA? :) )

> I've tried both wslgit workarounds and consider them kind of hacky, running into credential helper issues all the time.

Did you also try the workaround suggested in my previous post?


  • Git executable inside WSL should be used
    => a simple batch file basically works:
    wsl git %*
  • requesting credentials does not work
    => The Git credential helper must be configured to e.g. "credential.helper=cache" and credentials must be configured in a way that Git won't have to ask for credentials (avoid command line prompt!)

Sorry, I can't give an ETA at this unclear stage.

Within WSL, I've set  git config credential.helper 'cache'. forwarder.bat lies within C:\ . Any smartgit option I have to change, rather than git executable? Tried both Smart-git and system owned SSH client.

My repository is located at ~/github.priv3 and I'm using following git.bat file (hacked together, for testing):

wsl cd ~/github.priv3 ; git %*

To avoid the "UNC paths are not supported" error, I've mapped network drive S:\ to the root of my WSL file system and I'm opening the repository from S:\home\marc\github.priv3

In the VM, I have configured once:

git config --global credential.helper cache

and after every WSL 'boot' I ensure that Git will have cashed credentials by invoking from within WSL a

git pull

Note that:

git config --global credential.helper store

will even survive WSL reboots (but will write credentials in plain text into your WSL file system).

This basically works. SmartGit shows "git: 'credential-D:/smartgit/build/dist-templates/windows/lib/credentials.cmd' is not a git command. See 'git --help'.", but this can be ignored for now.

Hence, IMHO, we have all ingredients present and working, just the approach needs to be refined and we probably needs some SmartGit option to omit the "credential.helper".

1) As we maintain multiple repos, I'd have to either use a more flexible .bat or change .bat with fixed paths for each repo? Setting cd to our parent-folder containing all repos thorws a "not a git repository" error.

2) Even though pulling/pushing/fetching/ls-remote {url} within WSL works fine, when started from smartgit it returns "Could not update branch states (green and red arrows) due to: ls-remote failed (return code 1)". Credential helper is set to cache.

Please don't get me wrong, I'm not criticising smartgit in any way, great product & happily paying customers.  I understand that this issue is not directly linked with smartgit, but the way we, as a WSL-user, use it. Just trying to (help) getting it running w/ wsl seamlessly.

> 1) As we maintain multiple repos, I'd have to either use a more flexible .bat or change .bat with fixed paths for each repo? 

Yes, I guess the batch file must somehow manage that. SmartGit will execute the batch file with the correct Windows working directory set; but the mapping to WSL it doesn't know. For a given setup it shouldn't be too hard with some String acrobatics. Regarding a more general solution, there might be a way to figure out the full UNC patch for e.g. S:\home\marc\github.priv3 [1].


> 2) Even though pulling/pushing/fetching/ls-remote {url} within WSL works fine, when started from smartgit it returns "Could not update branch states (green and red arrows) due to: ls-remote failed (return code 1)". Credential helper is set to cache.

We can tweak SmartGit to pass any credential.helper to the Git executable which you like, but ultimately it's the Git executable in WSL which must be capable of establishing the connection.

You can see all commands which SmartGit is invoking in the Output view. What are your concrete suggestions on how these commands should be altered?

[1] https://stackoverflow.com/questions/21482825/find-unc-path-of-a-network-drive

re 1) being able to configure the git exe per repository would help

+2

Any update on this topic?

Using smartgit with WSL2 is so painfully slow...

I'm also really interested in an update (for the most widely used scenario described above: Smartgit on Windows and repositories within \\wsl$\). In this regard, I don't really understand why it is so slow since accessing files within \\wsl$\ seems to be faster in general?

What about "git status", with the Git executable being Git for Windows`?

Also, sending periodical thread dumps to investigate the slowness may be helpful: https://docs.syntevo.com/SmartGit/HowTos/Creating-Thread-Dumps.html

Thanks for your reply! I timed running Git via Windows PowerShell (since CMD does not support UNC paths) via Measure-Command { & "C:\Program Files\SmartGit\git\bin\git.exe" status | Out-Default }. For a directory within the Windows file system, it takes about 70 milliseconds, while for a directory within \\wsl$\ it takes about 500 milliseconds (for the same project with equal changes). If using SmartGit (with a separate display of index and working tree) to stage a first single hunk or to unstage all changes, it roughly takes about three seconds until the Files window is updated. However, in the meantime, I can click to stage other hunks, but the delay is irritating. Even if only switching between index and working tree versions, it roughly takes about two to three seconds until the Changes window is updated.

I'll send a thread dump later on to the mail address given on the how-to page. Presently, I'm only trying out if and how well WSL works. Since one of the comments below suggests using SmartGit inside WSLg, I'll probably give that a try in the future (since WSLg is going to be generally available alongside the upcoming release of Windows 11 according to GitHub/wslg).

+1

WSLg is available since Windows 11 21H2, not the upcoming 22H2. Information on github was just not updated, it seems. No need for hacky workarounds to get smartgit / wslg running on 22H1 / current version. 

I ended up using GitKraken installed within WSLg and it works like a charm!

You are the first one to mention "WSLg" ... so GitKraken is running as Linux process? That's something completely different than running GitKraken on Windows and accessing files from the Linux file system. Did you try to run SmartGit inside WSLg?

I failed to run SmartGit within WSLg, so I tried out GitKraken and it worked.

Anyway, that's just a workaround. A valid solution would be something like VSCode or phpstorm: installed on windows with something running in WSL to prevent any perf loss

I tried SmartGit on WSLg and it seems to work fine for me. What exactly went wrong for you?
Also, here's an article on how to set everything up: https://docs.syntevo.com/SmartGit/HowTos/Running-on-WSLg.html

+1

We're running smartgit inside WSLg, works just as expected.


There are some (X-Window?) UI bugs regarding window resizing & scrollbars, yet those issues are quite negligible. Performance is great, no trade-offs regarding functionality, we're quite happy with our solution. Keep in mind that rolling updates aren't possible, thus smartgit updates have to be applied manually using dpkg or tar bundle.

I didn't notice any resizing/scrollbars issues.
Could you please create shortcut as explained in this article (step "sudo ./smartgit/bin/add-menuitem.sh") and see if that helps?

https://docs.syntevo.com/SmartGit/HowTos/Running-on-WSLg.html

Seems like add-menuitem.sh is not available within the dpkg version of the latest preview? :-)

(Sorry for the delay - userecho mails seem to have a delay of quite some days for me..)

Please try the recommended .tar.gz instead. For me, it worked just fine.

If you mean the .deb file: this is not necessary, because installing the .deb file will create a menu item automatically.

+1

I tried SmartGit on WSLg briefly and it seems to work fine, and performance is good.

I composed an article on how to set it up:

https://docs.syntevo.com/SmartGit/HowTos/Running-on-WSLg.html

Hey Alex.

I did everything like you described in the article, but the shortcut on the windows side doesn't appear. Though it has been created in /usr/share/applications
https://i.imgur.com/YbWJrZe.png
Maybe you know why?

I will reply by email. Once we figure what went wrong, I'll update the article.

Turns out, OP only had Win10, whereas Win11 is required for WSLg. I have updated the article with additional clarifications.

+1

WSLg as of Nov 2022 became available for Win10 and this is the route I've taken. Look at topic 1409 to vote for better support for running Smartgit under WSL itself

I guess you actually mean topic 1408 which is about WSLg?

Thanks for letting know, I've tried it by myself and now it's working on my WIN 10 setup =) Though I can't configure the scaling, everything is way too small. 

Have you faced the scaling issue?

SmartGit 23.1 preview contains a fix for DPI scaling >= 200%.
See https://www.syntevo.com/smartgit/preview/