New Updates in Windows WSL

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gatsu
    Visitor
    • Mar 2017
    • 5

    New Updates in Windows WSL

    New features deployed with the Linux subsystem for windows should now make it possible for BC4 to work with the WSL.

    https://docs.microsoft.com/en-us/win...aries-from-wsl

    It is now possible to invoke EXE's from bash. For example you can activate BC4 like so:

    Code:
    tom@ws2:~$ /mnt/c/Program\ Files/Beyond\ Compare\ 4/bcomp.exe
    Notice the escaped spaces in the above command. Simply copy and paste this and you'll see that BC4 opens.

    The opposite is now true as well:
    Code:
    C:\temp> wsl sudo apt-get update
    The above invokes the command just as if you were in bash itself.

    Do these changes warrant looking into this again?
  • Chris
    Team Scooter
    • Oct 2007
    • 5538

    #2
    To clarify earlier posts about Windows Subsystem for Linux (WSL), Scooter Software doesn't officially support running Beyond Compare for Linux in WSL. Microsoft also doesn't officially support running graphical (X-Window) applications using WSL. You might be able to make BC4 Linux work if you run an X-Window client, but it isn't a configuration we test, so we can't guarantee it will work. See the previous forum thread Installing Linux BC4 under WSL for a possible method to run BC4 Linux in WSL.

    Beyond Compare for Windows doesn't support Linux/Unix style paths, so that's the main issue with launching it from Git in WSL. I haven't had time to test the instructions yet, but the blog post WSL, git, and Beyond Compare might point you in the direction of a working Git in WSL + BC 4 Windows configuration.
    Chris K Scooter Software

    Comment

    • snutt
      Visitor
      • Aug 2008
      • 3

      #3
      The blog post above that Chris mentioned, WSL, git and Beyond Compare worked great with the exception that I had to modify the alias to execute git difftool -y --dir-diff --no-symlinks --tool=BCompare

      Comment

      • pdcoxhead
        New User
        • Jul 2018
        • 2

        #4
        I just added a comment in regards to using Beyond Compare with Windows / Bash. Basically to solve the problem I used a handy script to convert the file paths from POSIX to Windows which could then be given to Beyond Compare. I just need to tinker a little so that the /tmp/ path was converted correctly (see issue #7 on that github repo).

        https://www.scootersoftware.com/vbul...6717#post56717

        Comment

        • tumik
          Visitor
          • Dec 2019
          • 3

          #5
          Just adding my two cents here. The only blocker issue for me not to buy BC4 currently is the way it is broken with WSL.

          WSL currently supports starting Windows apps from Linux, and starting Linux apps from Windows. It also supports accessing Linux files from Windows, and accessing Windows files from Linux.

          I store my git repositories in Linux filesystem (in WSL), and regularly run git difftool or git mergetool from there, and also manually launch diff tools from there.

          In p4merge for example, or most other Windows apps, I can just give the normal linux path as an argument and everything works. Like this:
          Code:
          ~$ p4merge.exe fileA fileB
          or
          Code:
          ~$ p4merge.exe /tmp/fileA /tmp/fileB
          However for some reason the first one works but the last one does not work with BC4. The first slash breaks it, all relative paths work but using any absolute path doesn't work. This makes it difficult to launch BC4 from scripts or git.

          I know WSL isn't officially supported by BC4, but BC4 really is the only Windows app I've noticed to not work when launched from WSL with absolute path to a linux file as an argument, so this seems like a bug in BC4.

          The workaround at blog post "WSL, git, and Beyond Compare" doesn't work for me, as I don't store my git repository in Windows filesystem.

          Comment

          • Aaron
            Team Scooter
            • Oct 2007
            • 15997

            #6
            Thanks for the feedback and additional example cases. I'll add this usecase to our wishlist entry on the subject. Does the above helper script to convert paths help?
            Aaron P Scooter Software

            Comment

            • tumik
              Visitor
              • Dec 2019
              • 3

              #7
              Thanks for a quick reply. If you are referring to https://github.com/laurent22/wslpath - no, I don't think so. If I understand correctly it should convert the path if the file actually is on Windows FS but command is launched from Linux, which means this as an example:
              Actual storage of an example file:
              Code:
              C:\fileA
              Path shown in Linux:
              Code:
              /mnt/c/fileA
              Command to run in Linux:
              Code:
              BComp.exe $(wslpath /mnt/c/fileA)
              Which would translate to
              Code:
              BComp.exe C:\fileA
              So when working with Windows files from Linux, this script converts the paths to native Windows paths.

              However in my use case the files are in Linux filesystem, not in Windows. WSL natively converts those paths to Windows paths under \\wsl$\ so they shouldn't need any other conversion. \\wsl$\ is the new feature in recent Windows versions which allows Windows apps to see files under the Linux filesystem. It should show up as a kind of a network share. More info on that: https://devblogs.microsoft.com/comma...-version-1903/

              Comment

              • Aaron
                Team Scooter
                • Oct 2007
                • 15997

                #8
                Ah, thanks for the clarification and helpful resource links. I'll add these references to our tracker as well.
                Aaron P Scooter Software

                Comment

                • tumik
                  Visitor
                  • Dec 2019
                  • 3

                  #9
                  An update, I managed to get it working using the built-in wslpath command which comes with new WSL versions!

                  My git config on WSL linux side:

                  Code:
                  difftool.bc3.cmd=BComp.exe "$(wslpath -aw $LOCAL)" "$(wslpath -aw $REMOTE)"
                  mergetool.bc3.cmd=BComp.exe "$(wslpath -aw $LOCAL)" "$(wslpath -aw $REMOTE)" "$(wslpath -aw $BASE)" "$(wslpath -aw $MERGED)"
                  BComp.exe is in my $PATH. I'm using WSL2 on Windows version 2004 (build 19041), and this works both inside the WSL filesystem and also for the mounted Windows filesystem.

                  The new wslpath -aw converts the Linux paths like this:
                  Code:
                  $ wslpath -aw /home/
                  \\wsl$\Debian\home
                  And Windows paths like this:
                  Code:
                  $ wslpath -aw /mnt/c/Users/
                  C:\Users
                  This makes them both work perfectly with the Windows version of BC when launched from Linux.

                  Comment

                  • Kyle Rogers
                    New User
                    • Feb 2021
                    • 1

                    #10
                    The git config from tumik works great for me!
                    wslpath -aw makes the paths come out right.
                    Please add the WSL info to the support page.

                    - I'm using WSL1 on Windows version 20H2 (build 19042.746)
                    - I've got C:\Program Files\Beyond Compare 4 in my Windows path...
                    - ...so /mnt/c/Program Files/Beyond Compare 4 appears in my Linux path

                    After configuring the command and making bc3 the default for difftool, it launches great for me.
                    Code:
                    $ git config --global difftool.bc3.cmd 'BComp.exe "$(wslpath -aw $LOCAL)" "$(wslpath -aw $REMOTE)"'
                    $ git config --global diff.tool bc3
                    $ git difftool

                    Comment

                    • charlesroper
                      New User
                      • Mar 2021
                      • 1

                      #11
                      Tumik and Kyle's instructions work for me too in WSL 2.

                      I have not got the BC directory in my Windows path, so the [difftool "bc3"] section in my global git config looks like this:
                      Code:
                      [difftool "bc3"]
                          cmd = '/mnt/c/Program Files (x86)/Beyond Compare 4/BComp.exe' \"$(wslpath -aw $LOCAL)\" \"$(wslpath -aw $REMOTE)\"
                      (Tip: to get your global git config for WSL up in your editor, use the git config --global -e command and it will open in your configured editor)

                      Type git difftool -t bc3, and BC will fire up.

                      To make BC the default as Kyle did I used git config --global diff.tool bc3

                      Now I can type git difftool and BC will start up as the default.

                      To complete the picture, here's a screenshot to show how BC opens up the files inside WSL 2 via a network share (note, "shrop-bot-soc" is the name of my WSL distro - yours will more likely be something like "Ubuntu"):

                      Click image for larger version

Name:	Dn2WBer.png
Views:	2164
Size:	34.6 KB
ID:	85437

                      Some more background on how this magic works:

                      https://www.howtogeek.com/426749/how...in-windows-10/

                      https://www.howtogeek.com/fyi/window...o-linux-files/

                      Microsoft’s Craig Loewen explains how it works: Rather than accessing these files directly, Windows runs a Plan 9 server as part of the WSL software in the background. Windows 10 has “a Windows service and driver that acts as the client and talks to the Plan9 server.” That server translates your file operations and handles Linux metadata such as file permissions, ensuring everything works properly even when you access a file with a Windows tool. But that’s just the complicated stuff that happens in the background, and you don’t have to think about it.
                      In other words, BC works seamlessly with files inside WSL. Happy days.

                      Comment

                      • FourLegsDriveCat
                        Journeyman
                        • Jan 2017
                        • 12

                        #12
                        Thank you guys for the information.
                        Initially I've set up Windows BC4 as you described above and it worked like a charm with git but... it's inconvenient to compare arbitrary files (not tracked by git) because it requires adding "/mnt/c/Program Files/Beyond Compare 4" to the PATH environment variable and it does not work with absolute paths (I cannot just type "BComp.exe /absolute/path/file1 file2", I have to use wslpath again).
                        So I've ended up with installing BC4 for Linux, as Chris suggested, and removed all those configs and now I can just type lowercase "bcompare any_path_1 any_path_2" to compare any files on Linux. Of course, to make it work I've installed X-Server (vcxsrv) on Windows side and set DISPLAY env var accordingly on Linux side, but I had to do this anyway to be able to execute other GUI Linux apps.

                        Comment

                        • FourLegsDriveCat
                          Journeyman
                          • Jan 2017
                          • 12

                          #13
                          On the other hand, Windows BC4 looks prettier than Linux BC4 under WSL, so I will use WSL config to launch Windows BC4 with git operations.
                          And I will leave Linux BC4 installation to use it for arbitrary files comparison.
                          Last edited by FourLegsDriveCat; 14-Jun-2022, 12:10 PM.

                          Comment

                          Working...