fork-dev / Tracker

Bug and issue tracker for Fork for Mac
506 stars 12 forks source link

Run Fork with Wine #2033

Open DanPristupov opened 9 months ago

DanPristupov commented 9 months ago

Let's continue the Wine-related discussion (https://github.com/fork-dev/Tracker/issues/153) here.


Some info which could be useful:

DanPristupov commented 9 months ago

I copy @Baardi's post (https://github.com/fork-dev/Tracker/issues/153#issuecomment-1854458776) here:

I think I was a bit too optimistic. The initial results seemed good. I was able to open a local git repository, see file changes, etc, but when I dragged it into a different monitor, other than the main one, it immediately froze. It would also launch next time in the same broken state. The only way I found to fix it was to delete the settings.json file. Screenshot from 2023-12-13 18-33-35

Next I tried creating a new branch. sh.exe crashed. But the branch was succesfully created. Screenshot from 2023-12-13 18-32-38

I then tried commit a change to that branch. That worked fine, no errors. I then tried pushing the changes. It didn't work, as libcurl-4.dll was missing. Screenshot from 2023-12-13 18-24-39

So it's safe to say I have a few issues to sort out.

EDIT: So I don't spam you all. The dll load failure was due to a missing dll in system32/syswow64: Wldap32.dll. I copied the dlls from my windows 11 installation, which seemed to work. Authentication is still a problem though, at least for github (Neither https or ssh worked for me).

DanPristupov commented 9 months ago

Next I tried creating a new branch. sh.exe crashed. But the branch was succesfully created.

Try to disable 'Update submodules automatically on checkout' in Fork preferences (File -> Preferences or UpdateSubmodulesOnCheckout in %localappdata%\Fork\settings.json)

The dll load failure was due to a missing dll in system32/syswow64: Wldap32.dll. I copied the dlls from my windows 11 installation, which seemed to work.

Do you mean, by copying Wldap32.dll you solved problem with missing libcurl-4.dll on fetch?

julaudo commented 9 months ago

I personnaly found 2 occurences of libcurl-4.dll:

./drive_c/users/XXX/AppData/Local/Fork/gitInstance/2.42.0.2/mingw64/libexec/git-core/libcurl-4.dll
./drive_c/users/XXX/AppData/Local/Fork/gitInstance/2.42.0.2/mingw64/bin/libcurl-4.dll

Are you missing these?

julaudo commented 9 months ago

One strange thing I observed is that sometime, text is blurry image For example here "Quick launch" and "Fetch" are pretty clear but "Pull" and "Push" are blurry

This is probably not related to Fork and just a Wine "issue"

Baardi commented 9 months ago

I personnaly found 2 occurences of libcurl-4.dll:

./drive_c/users/XXX/AppData/Local/Fork/gitInstance/2.42.0.2/mingw64/libexec/git-core/libcurl-4.dll
./drive_c/users/XXX/AppData/Local/Fork/gitInstance/2.42.0.2/mingw64/bin/libcurl-4.dll

Are you missing these?

I had libcurl-4.dll, but libcurl-4.dll itself was calling Wldap32.dll which it didn't find

julaudo commented 9 months ago

I personnaly found 2 occurences of libcurl-4.dll:

./drive_c/users/XXX/AppData/Local/Fork/gitInstance/2.42.0.2/mingw64/libexec/git-core/libcurl-4.dll
./drive_c/users/XXX/AppData/Local/Fork/gitInstance/2.42.0.2/mingw64/bin/libcurl-4.dll

Are you missing these?

I had libcurl-4.dll, but libcurl-4.dll itself was calling Wldap32.dll which it didn't find

I have these files, but I don't know how they came up here:

./drive_c/windows/syswow64/wldap32.dll
./drive_c/windows/system32/wldap32.dll
Baardi commented 9 months ago

Next I tried creating a new branch. sh.exe crashed. But the branch was succesfully created.

Try to disable 'Update submodules automatically on checkout' in Fork preferences (File -> Preferences or UpdateSubmodulesOnCheckout in %localappdata%\Fork\settings.json)

The dll load failure was due to a missing dll in system32/syswow64: Wldap32.dll. I copied the dlls from my windows 11 installation, which seemed to work.

Do you mean, by copying Wldap32.dll you solved problem with missing libcurl-4.dll on fetch?

Yes. Turns out libcurl-4.dll wasn't missing. It was just the call to it that failed, since there was no Wldap32.dll included with my wine-installation.

Baardi commented 9 months ago

rive_c/windows/system32/wldap32.dll

What version of wine are you running? Currently I'm on Found wine-8.19

julaudo commented 9 months ago

wine-8.0.2

Baardi commented 9 months ago

Are you able to authenticate to github and push commits?

julaudo commented 9 months ago

Yes I'm using both gitlab and github repositories (using ssh keys, did not try https)

Baardi commented 9 months ago

This is what happens both when I try to generate a ssh key. The exact same thing happens when I try to authenticate using https.
bilde How did you install wine (repo/package manager)?

julaudo commented 9 months ago

This error happens when you generate a ssh key? What I do is generating my keys under linux then copy them into wine user .ssh folder (actually I copied my already existing keys)

I installed wine using apt install --install-recommends winehq-stable

Baardi commented 9 months ago

This error happens when you generate a ssh key?

Yes, but reinstalling wine now, as it probably wasn't a good idea to mess around with system32/syswow64. Are you using 32bit or 64bit prefix?

julaudo commented 9 months ago

I'm using 64bit prefix I did not try to generate keys using wine, why don't you generate them under your host OS?

DanPristupov commented 9 months ago

@Baardi does fetch (or clone) work for public GitHub repos? Normally they should not ask for authentication.

quadbyte commented 9 months ago

Really looking forward to this!

Baardi commented 9 months ago

@Baardi does fetch (or clone) work for public GitHub repos? Normally they should not ask for authentication.

Yes, that works fine

Baardi commented 9 months ago

I'm using 64bit prefix I did not try to generate keys using wine, why don't you generate them under your host OS?

I can, but I'd still have to find a way to import the key to Fork.

julaudo commented 9 months ago

You just ned to copy it in the user .ssh folder

DanPristupov commented 9 months ago

I just checked the source code. Looking for the .ssh directory first Fork checks if %HOME%/.ssh exists, then falls back to %userprofile%/.ssh.

P.S. I'm not sure why Fork prioritizes %HOME%/.ssh but probably historically there was some reason for that.

NitroHxC commented 9 months ago

Hi guys, a bunch of updates from my side.

First of all, thanks for bringing this topic up again, and thanks Dan for being open to support this cause :)

# Download Fork from the website,
# put it in a folder named "Fork" and extract it in place with 7zip
7z x Fork-1.92.0.exe

# extract the nupkg in place
7z x Fork-1.92.0-full.nupkg

# the Fork exe is now in the folder Fork/lib/net45/
# this folder content should be actually copied in a folder named "app-x.y.z"
# for example, app-1.92.0
# so copy the contents of "net45" there and you would end up with the executable path Fork/app-1.92.0/Fork.exe

# Prepare a fresh wine environment
WINEPREFIX=~/.winefork wineboot # creates the environment
WINEPREFIX=~/.winefork winetricks -q dotnet462
WINEPREFIX=~/.winefork winetricks -q corefonts
WINEPREFIX=~/.winefork wineboot # this simulates a clean reboot of the system, why not

# copy the folder "Fork" into
# ~/.winefork/drive_c/users/YOUR_NAME_HERE/AppData/Local/

# so your executable now lives at
# ~/.winefork/drive_c/users/YOUR_NAME_HERE/AppData/Local/Fork/app-1.92.0/Fork.exe

# either cd and run from there
cd ~/.winefork/drive_c/users/YOUR_NAME_HERE/AppData/Local/Fork/app-1.92.0
WINEPREFIX=~/.winefork wine Fork.exe
# OR, directly
WINEPREFIX=~/.winefork wine ~/.winefork/drive_c/users/YOUR_NAME_HERE/AppData/Local/Fork/app-1.92.0/Fork.exe
julaudo commented 9 months ago

Point 1 : I've got this warning too, seems to be harmless. This is an issue related to bash.exe present in the Fork gitInstance package. Point 2 : git you try to run git command from windows prompt.

DanPristupov commented 9 months ago

@NitroHxC

Point 2: Trying to log into Github hangs in Waiting for a response, but in the terminal I can see

Are you trying to log in to GitHub using File -> Accounts -> + -> GitHub -> OAuth?

There are many ways to authenticate and OAuth is probably the most complicated one to get an authentication token. Fork creates a local HTTP server on a particular port, then opens browser with GitHub log-in page which will check the credentials and eventually redirect user and pass the authentication token to the page which is handled by the Fork's HTTP server.

However, there is an easier way to authenticate using personal access token. Create a PAT in your GH account (https://github.com/settings/tokens/new?description=Fork&scopes=repo,user,notifications,workflow) and use it in File -> Accounts -> + -> GitHub -> Personal Access Token. You can also use that token instead of password in basic HTTP (login/password) authentication.

Point 3: I ... summarized the steps ... here so anyone reading this can catch up too.

Awesome!

  1. BTW, the .nupkg file can be downloaded directly:
# download the latest Fork package
curl https://fork.dev/update/win/Fork-1.92.0-full.nupkg --output fork-full.nupkg

# extract the .nupkg in place
7z x fork-full.nupkg
...
  1. May be some bash-rocket-scientist can get the latest .nupkg file name right from the last line in https://fork.dev/update/win/RELEASES file :)
NitroHxC commented 9 months ago

Thanks for your answers!

Well... actually now that I think about it, I guess that I don't need to log into Github after all, I always used SSH anyway :D I was just trying out a bunch of stuff and I reported it hehe! Thanks for the clarification :)

@julaudo yeah I get the same warning even if I try to open the cmd prompt and it's indeed the "bash.exe" . The thing is... I'm happy it's harmless, but it's not working either, not even waiting for 1 hour :( Is it actually working for you?!

I work 99% with private repos, both at my job and at home, so I'm really willing to solve this

Also, I elaborated my notes and wrapped all up to some scripts today: https://gist.github.com/NitroHxC/ff579d57b15f7ba5dcd1429eac13468f

As @DanPristupov suggested, this script setup_fork.sh gets the latest nupkg from the RELEASES file and extract it into the user/AppData/Local/Fork folder in a brand new wine environment , by default called winefork but customizable with flag -p <wine_prefix>. Then ./run_fork.sh -p <wine_prefix>

The script worked out of the box on fresh install of EndeavourOS on a VM, just by installing p7zip, wine-staging and winetricks.

I couldn't make it work with a Ubuntu 22.04 VM but didn't investigate much (it's likely that the version of wine-staging matters) .

julaudo commented 9 months ago

@julaudo yeah I get the same warning even if I try to open the cmd prompt and it's indeed the "bash.exe" . The thing is... I'm happy it's harmless, but it's not working either, not even waiting for 1 hour :( Is it actually working for you?!

Yes this is working. The strange thing is

I believe that initially git commands from fork were hanging too but I can't remember what I've done to solve it.

What Fork/git version are you using? Can you identify running processes by running a ps command on host while fork is stuck?

NitroHxC commented 9 months ago

Good catch... Indeed I tried to ps -aux | grep git and found these processes open since more than an hour ago, even long after I closed Fork.

nitrohxc   204483  0.0  0.0  79348 23800 ?        Ss   22:11   0:00 C:\users\nitrohxc\AppData\Local\Fork\gitInstance\2.42.0.2\bin\git.exe fetch --prune origin --verbose --progress
nitrohxc   204490  0.0  0.0 104512 17516 ?        S    22:11   0:00 git.exe fetch --prune origin --verbose --progress
nitrohxc   204495  0.0  0.0 9133896 23260 ?       Sl   22:11   0:00 sh -c ssh -i 'C:/users/nitrohxc/.ssh/id_ed25519' -F '/dev/null' "$@" ssh -i 'C:/users/nitrohxc/.ssh/id_ed25519' -F '/dev/null' -o SendEnv=GIT_PROTOCOL git@github.com git-upload-pack 'NitroHxC/archon.git'
nitrohxc   204509 45.5  0.0 9118080 22136 ?       Sl   22:11  45:20 C:\users\nitrohxc\AppData\Local\Fork\gitInstance\2.42.0.2\usr\bin\ssh.exe -i C:/users/nitrohxc/.ssh/id_ed25519 -F /dev/null -o SendEnv=GIT_PROTOCOL git@github.com git-upload-pack 'NitroHxC/archon.git'
nitrohxc   204674 46.1  0.0 9187648 22584 ?       Sl   22:11  45:46 sh -c ssh -i 'C:/users/nitrohxc/.ssh/id_ed25519' -F '/dev/null' "$@" ssh -i 'C:/users/nitrohxc/.ssh/id_ed25519' -F '/dev/null' git@github.com git-receive-pack 'NitroHxC/archon.git'
nitrohxc   204677  122  0.0 9183624 23284 ?       Rl   22:11 121:30 C:\users\nitrohxc\AppData\Local\Fork\gitInstance\2.42.0.2\usr\bin\ssh.exe -i C:/users/nitrohxc/.ssh/id_ed25519 -F /dev/null git@github.com git-receive-pack 'NitroHxC/archon.git'
nitrohxc   248566 34.4  0.0 9187656 32276 ?       Sl   23:36   4:53 sh -c ssh -i 'C:/users/nitrohxc/.ssh/id_ed25519' -F '/dev/null' "$@" ssh -i 'C:/users/nitrohxc/.ssh/id_ed25519' -F '/dev/null' -o SendEnv=GIT_PROTOCOL git@github.com git-upload-pack 'NitroHxC/archon.git'
nitrohxc   248569 89.0  0.0 9183624 27180 ?       Rl   23:36  12:38 C:\users\nitrohxc\AppData\Local\Fork\gitInstance\2.42.0.2\usr\bin\ssh.exe -i C:/users/nitrohxc/.ssh/id_ed25519 -F /dev/null -o SendEnv=GIT_PROTOCOL git@github.com git-upload-pack 'NitroHxC/archon.git'
nitrohxc   259169  0.0  0.0   6552  2428 pts/1    S+   23:50   0:00 grep git

I'm not a Wine expert at all so I'm wondering if we are totally bound to use those .exe or there is some Wine sorcery to use the host git, bash and ssh !? And what about installing the latest Git for Windows in the wine env , does it change anything ?

NitroHxC commented 9 months ago

I made it!

So by investigating further on those commands, there was actually a problem with ssh.exe waiting for user input (yes/no/fingerprint) because it couldn't find Github.com into the known_hosts ... so by running just the command with -vvv option I found out that it didn't find the known_hosts at all. It was actually looking for /home/username/.ssh/known_hosts or in /etc/ssh/ssh_known_hosts , but probably as a relative path to the whole gitInstance path.

So I solved creating a symlink to that file in the /etc/ssh subfolder of the git instance

cd ~/.winefork/drive_c/users/nitrohxc/AppData/Local/Fork/gitInstance/2.42.0.2/etc/ssh
sudo ln -s ~/.ssh/known_hosts ssh_known_hosts

I was sooo amazed by being able to fetch and push to my private repo from Fork on Linux! :)

@julaudo is this the same solution you found out before?

julaudo commented 9 months ago

Nice! I guess I also copied my existing known hosts, that's why I did not have this issue.

NitroHxC commented 9 months ago

Nice! I guess I also copied my existing known hosts, that's why I did not have this issue.

That's exactly what I did at first, I copied the whole .ssh folder with the keys and the known_hosts file inside it. But for some reason ssh.exe it's not able to access C:/users/USERNAME/.ssh/known_hosts , this is quite strange!

gamedevsam commented 9 months ago

Can we keep track of install steps on some unified document somewhere? I'm interested in trying this, but have little to no experience with how Wine emulates applications and how to setup fork on Ubuntu.

liamjones commented 9 months ago

Can we keep track of install steps on some unified document somewhere?

@DanPristupov what do you think about enabling the wiki for this repo so Fork via Wine could be documented there?

nedsociety commented 8 months ago

IMO a better packaging strategy would be to create a containerized setup (docker, docker-compose, flatpak or whatever) on a separate repo. That would make things much easier and consistent to setup across distributions.

andgeno commented 6 months ago

Thanks for your answers!

Well... actually now that I think about it, I guess that I don't need to log into Github after all, I always used SSH anyway :D I was just trying out a bunch of stuff and I reported it hehe! Thanks for the clarification :)

@julaudo yeah I get the same warning even if I try to open the cmd prompt and it's indeed the "bash.exe" . The thing is... I'm happy it's harmless, but it's not working either, not even waiting for 1 hour :( Is it actually working for you?!

I work 99% with private repos, both at my job and at home, so I'm really willing to solve this

Also, I elaborated my notes and wrapped all up to some scripts today: https://gist.github.com/NitroHxC/ff579d57b15f7ba5dcd1429eac13468f

As @DanPristupov suggested, this script setup_fork.sh gets the latest nupkg from the RELEASES file and extract it into the user/AppData/Local/Fork folder in a brand new wine environment , by default called winefork but customizable with flag -p <wine_prefix>. Then ./run_fork.sh -p <wine_prefix>

The script worked out of the box on fresh install of EndeavourOS on a VM, just by installing p7zip, wine-staging and winetricks.

I couldn't make it work with a Ubuntu 22.04 VM but didn't investigate much (it's likely that the version of wine-staging matters) .

Thank you so much for putting the scripts together. I decided to set up an ArchLinux VM and it was really plug & play. :)

There's one little tweak I needed to apply to stop Fork from flickering like crazy. What helped in my case was this:

WINEPREFIX="$HOME/.winefork" winetricks renderer=gdi
neogeographica commented 6 months ago

I appreciate the work folks are going to in trying to figure this out. I've followed the steps in the linked gist, with the exception of specifically using wine-9.0 (as the wine version in wine-staging didn't work) -- FWIW I'm on Pop!_OS 22.04, based on Ubuntu.

Linking my existing .ssh directory into the user home folder under the wineprefix seems to work fine w.r.t. authentication.

Unfortunately the font rendering is quite weird, especially the kerning. Setting the winecfg DPI correctly and installing more fonts doesn't help... I also tried setting renderer=gdi just for the heck of it.

kerning-1 kerning-2

In some of the other screenshots posted upthread here I see some kerning issues but not apparently as bad as this. So... not sure what's going on. It's kind of a deal-killer for a text-heavy app.

As an experiment I tried installing Fork using Bottles with various runners other than "plain" Wine. Most didn't work at all, in various ways, and I spent way too much ultimately unsuccessful time trying to fix those. Curiously, if I used the Proton-GE runner (which is really only meant for Steam games) the font rendering and the rest of the Fork UI was perfect, but it had other crash issues and at first glance didn't seem to be able to do git ops.

Anyway! If any Wine expert here happens to know of a common fixable issue with fonts rendering/kerning in Wine apps, I'd love to hear about it.

edit: Also could be interesting to know exactly what fonts are in use...

Good luck to all. :-)

NickHeap2 commented 3 months ago

After following the gist from @NitroHxC as a start I've managed to get GitHub auth working on my Ubuntu 24 WSL.

I think these are all the steps I needed to do.

Then from within a repo I did WINEPREFIX=~/.winefork wine git.exe fetch --prune origin it prompts me to login to GitHub which I did using the device code method.

When I run fork now it has my GitHub auth.