Skip to content

Instantly share code, notes, and snippets.

@teohhanhui
Last active December 23, 2024 09:18
Show Gist options
  • Save teohhanhui/042a395010d9946ceee14768736e3780 to your computer and use it in GitHub Desktop.
Save teohhanhui/042a395010d9946ceee14768736e3780 to your computer and use it in GitHub Desktop.
Asahi Linux - krun + FEX + Steam

Nothing to see here.

What you want is https://asahilinux.org/2024/10/aaa-gaming-on-asahi-linux/

But if you have previously followed this guide, use the following to switch:

Cleanup

rm -rf ~/.fex-emu
rm ~/.local/bin/{asahi-krun-overlay-fex-rootfs,FEXBash,krun,krun-guest,steam}
rm ~/.local/share/applications/steam.desktop
rm -rf ~/.local/share/asahi-krun
DBX_CONTAINER_MANAGER=podman distrobox rm asahi-krun

Install Steam (on the host)

sudo dnf upgrade --refresh
sudo dnf install --best --setopt=allow_vendor_change=true steam
sudo dnf remove dhcpcd

You might have to reboot the system.

@aqrln
Copy link

aqrln commented Jun 1, 2024

@dylanchapell

@aqrln Did you find a solution to not having network access in the krun?

Sorry I didn't notice you mentioned me earlier and the whole discussion above, I got it working by hardcoding Cloudflare's DNS server in /etc/resolv.conf inside the VM after the file is generated like this:

diff --git a/crates/krun-guest/src/net.rs b/crates/krun-guest/src/net.rs
index 3710bd5..27e4d37 100644
--- a/crates/krun-guest/src/net.rs
+++ b/crates/krun-guest/src/net.rs
@@ -1,4 +1,4 @@
-use std::{fs, os::unix::process::ExitStatusExt, process::Command};
+use std::{fs, io::Write, os::unix::process::ExitStatusExt, process::Command};

 use anyhow::{anyhow, Context, Result};
 use log::debug;
@@ -35,5 +35,10 @@ pub fn configure_network() -> Result<()> {
         Err(err)?;
     }

+    fs::File::options()
+        .append(true)
+        .open("/etc/resolv.conf")?
+        .write_all("nameserver 1.1.1.1\n".as_bytes())?;
+
     Ok(())
 }

See https://github.com/slp/krun/issues/17

@teohhanhui
Copy link
Author

not Rust developers right now unfortunately (although knowing it is an advantage) but we do need some TypeScript engineers if this is relevant for you by any chance!

@aqrln Well, I don't have TypeScript experience specifically, only JS, but I'm learning Angular now for a side project , so... 😂

@lacamar
Copy link

lacamar commented Jun 2, 2024

@teohhanhui

I have not experienced that, so no idea. Try to check some of the Steam logs in ~/.steam/root/logs

Here's part of the logs for the steam client: https://pastebin.com/hr7JtKai

AppImage is tricky even just in the Flatpak version of Steam. It uses FUSE which requires root or setuid on fusermount.

That's unfortunate, it would be desirable to get this working somehow. In my experience I have found that much of the Linux software from developers that refuse to budge on supporting arm64 provide their software packaged as AppImages or Flatpak. In light of this, if it's not possible to run AppImages then I fear that it would diminish one of the main reasons for having fast x86_64 Linux emulation.

I have been running into some other problems with asahi-krun.

First, I am getting broken Xwayland pipe errors on Hyprland on some games I have tested.
(EE) failed to write to Xwayland fd: Broken pipe (or similar)
This error does not occur on KDE, so I am wondering if I have the wrong configuration or if Hyprland is bugged. Here are examples of the error:
https://pastebin.com/JzY2gZ9E
https://pastebin.com/90vLqg33

Second, there is an issue with steam's client libraries being unable to be located. When launching certain games, they look in the .steam/sdk32 or .steam/sdk64 folder for steamclient.so, but these directories are empty.
https://pastebin.com/Ngv9Gfmw

Third, sometimes when I click on the settings tag in the steam client, it crashes instantly with this error:
xdg_surface@44: error 3: xdg_surface has never been configured

Fourth, all GUI clients of krun become unresponsive if my computer sleeps while it is running.

Fifth, sometimes when RAM usage is high in krun plus on the host, the computer will crash completely and shut down (this has become less common since built your memory balloon branch of krun).

Thanks for all your work so far and I will do my best to provide more logs if you would like to help debug this.

@teohhanhui
Copy link
Author

Second, there is an issue with steam's client libraries being unable to be located. When launching certain games, they look in the .steam/sdk32 or .steam/sdk64 folder for steamclient.so, but these directories are empty.

The file exists on my system. Maybe there's a way to trigger Steam to revalidate and download missing files...

@QushyQushy
Copy link

Hello! :)
I'm getting this when trying to launch steam:

Error: couldn't parse `ef-force-occlusion`:

@teohhanhui
Copy link
Author

teohhanhui commented Jun 3, 2024

@QushyQushy That's really weird. But you could remove -cef-force-occlusion option from the steam wrapper script. I wonder if that'd help.

EDIT: Oops. That doesn't help. I'll investigate for a bit.

@teohhanhui
Copy link
Author

@QushyQushy Fixed the wrapper scripts. Please see the latest revision for the changes: https://gist.github.com/teohhanhui/042a395010d9946ceee14768736e3780/revisions

@QushyQushy
Copy link

@QushyQushy Fixed the wrapper scripts. Please see the latest revision for the changes: https://gist.github.com/teohhanhui/042a395010d9946ceee14768736e3780/revisions

Yup. Works amazingly now! :) Thank you! :)

@wxllow
Copy link

wxllow commented Jun 5, 2024

I've tried several times but have been unable to get Steam working because of an error during dnf install dbus-x11 steam xdg-user-dirs installing dbus-daemon:

Error unpacking rpm package dbus-daemon-1:1.14.10-3.fc40.x86_64
  Installing       : inih-58-1.fc40.i686                                  11/17 
error: unpacking of archive failed on file /usr/libexec/dbus-1/dbus-daemon-launch-helper;6660f2b8: cpio: chown failed - Operation not permitted
error: dbus-daemon-1:1.14.10-3.fc40.x86_64: install failed

This then leads steam to not start as seen below:

[wl@fedora]$ steam
steam.sh[1069]: Running Steam on fedora 40 64-bit
steam.sh[1069]: STEAM_RUNTIME is enabled automatically
setup.sh[1145]: Updating Steam runtime environment...

(zenity:1153): Gtk-WARNING **: 19:21:01.595: Unable to acquire session bus: Error spawning command line “dbus-launch --autolaunch=20b91177072544e78f5207379cee0cfe --binary-syntax --close-stderr”: Child process exited with code 1
xdg_surface@34: error 3: xdg_surface has never been configured
(EE) failed to read Wayland events: Broken pipe

@teohhanhui
Copy link
Author

@wxllow No, Steam does not need dbus-launch. That's just a warning. But sorry, I've no idea what could cause the errors you're seeing. You'd have to investigate further on your own.

error: unpacking of archive failed on file /usr/libexec/dbus-1/dbus-daemon-launch-helper;6660f2b8: cpio: chown failed - Operation not permitted

This is really weird.

@lacamar
Copy link

lacamar commented Jun 6, 2024

@wxllow

What desktop or window manager are you using? I started getting that error with steam and I’m on Hyprland.
I also had the same problem with installing dbus where it wouldn’t go ahead because of permission issues.

I tried deleting everything and reinstalling but the unbreak chroot script errors out and doesn’t let me enter the FEX root

@wxllow
Copy link

wxllow commented Jun 6, 2024

@wxllow

What desktop or window manager are you using? I started getting that error with steam and I’m on Hyprland. I also had the same problem with installing dbus where it wouldn’t go ahead because of permission issues.

I tried deleting everything and reinstalling but the unbreak chroot script errors out and doesn’t let me enter the FEX root

I'm also on Hyprland :o

@wxllow
Copy link

wxllow commented Jun 6, 2024

@wxllow

What desktop or window manager are you using? I started getting that error with steam and I’m on Hyprland. I also had the same problem with installing dbus where it wouldn’t go ahead because of permission issues.

I tried deleting everything and reinstalling but the unbreak chroot script errors out and doesn’t let me enter the FEX root

I'm not sure what causes it to not work on Hyprland but I tried redoing everything on KDE Plasma Wayland and although dbus daemon installation error still occurs, I am able to start Steam this time :)

@Spidy123222
Copy link

Spidy123222 commented Jun 6, 2024

Is there a way to get these mesa drivers in the container for Vulkan without messing up the host? There is a 1.3 implementation that seems to have a good amount work done on it for compatibility that it’s fully compliant vm 1.3 and just needs more extensions. Probably can just build it. Source code is in the page. I don’t normally mess with drivers so just was wondering. https://rosenzweig.io/blog/vk13-on-the-m1-in-1-month.html

@teohhanhui
Copy link
Author

@Spidy123222 If you want to try that, you're on your own. I don't want to create more PR (public relations, not pull request lol) headaches for the Asahi Linux project people.

@lacamar
Copy link

lacamar commented Jun 7, 2024

@wxllow

I'm also on Hyprland :o

Okay then there is probably something broken here between the VM and Hyprland. I can run it okay in KDE or DWL.

@teohhanhui
I deleted steam's files and reinstalled everything and those missing libraries are all installed properly now.

Also I found out that if you run these commands from the guide by copying them both and running them at the same time, things will look okay but the unbreak chroot script won't run properly. You have to copy and run the lines one at a time

cd ~/.fex-emu/RootFS/Fedora_40
unshare -pfr --user --mount --kill-child /usr/bin/bash

@teohhanhui
Copy link
Author

@lacamar Haha. Yes... All the commands are intended to be run one-by-one. That's why I didn't turn them into scripts or put any -y etc.

@Spidy123222
Copy link

@Spidy123222 If you want to try that, you're on your own. I don't want to create more PR (public relations, not pull request lol) headaches for the Asahi Linux project people.

Totally get it. I was talking to Alyssa earlier about it. Thought was cool and kind of wanted to try it. I think I have an idea on what to do.

@m3957
Copy link

m3957 commented Jun 9, 2024

Can we have an uninstall guide for this?

@teohhanhui
Copy link
Author

@m3957

Can we have an uninstall guide for this?

distrobox rm asahi-krun
rm -rf ~/.fex-emu
rm -rf ~/.local/share/Steam
rm ~/.local/bin/{FEXBash,krun,krun-guest,steam}
rm ~/.local/share/applications/steam.desktop

Something like that...

@KudoLayton
Copy link

@wxllow

Okay then there is probably something broken here between the VM and Hyprland. I can run it okay in KDE or DWL.

I have the same problem even in dwl. I installed Hyprland and dwl on minimal Fedora Asahi Linux without KDE.

@ArtificialAmateur
Copy link

ArtificialAmateur commented Jun 14, 2024

running krun FEXConfig does not have any outputs.

@ghostlypi It's supposed to launch a GUI window.

Having the same issue. Is there any logging or verbosity to krun?

At first ran into asahi_dri.so not found but noticed fedora installed the main repo's version and not the copr one.

@teohhanhui
Copy link
Author

Is there any logging or verbosity to krun?

@ArtificialAmateur Try this:

RUST_LOG='krun=debug,krun_guest=debug,krun_server=debug' RUST_BACKTRACE=1 krun -e=RUST_BACKTRACE FEXConfig

@ElYaiko
Copy link

ElYaiko commented Jun 24, 2024

Isn't box64 working yet?, I get a wine error with Fedora 39 distrobox:
https://pastebin.com/raw/ckSgWs3C

@teohhanhui
Copy link
Author

teohhanhui commented Jun 24, 2024

wine: could not exec wineserver

@ElYaiko That's just a broken symlink that you need to fix up in the /x86_64 install root.

Specifically:

sudo ln -sf /x86_64/usr/bin/wineserver64 /x86_64/etc/alternatives/wineserver
sudo ln -sf /x86_64/etc/alternatives/wineserver /x86_64/usr/bin/wineserver

EDIT: Updated the guide with the full instructions for fixing the symlinks.

Update: Tested with my latest build of box64: https://copr.fedorainfracloud.org/coprs/teohhanhui/box64/build/7661747/ but unfortunately the segfault is still happening on Fedora 40: ptitSeb/box64#1517

@Vincenzo-Puzone
Copy link

I would like to run lutris if it is possible to do, but i can't figure out how to install it. Can someone explain me how to do

@teohhanhui
Copy link
Author

teohhanhui commented Jul 1, 2024

@TamasBarta
Copy link

I couldn't enter chroot either, but I figured out, that the issue for me was that I was using zshell, and not bash. I reexported $SHELL to be where bash is (which bash) before unbreak_chroot.sh, and that did the trick, then the script used bash with chroot, which in contrast to zshell, is available in the chroot.

export SHELL=$(which bash)

@teohhanhui
Copy link
Author

@TamasBarta Good find. Thank you. I'll investigate and add a workaround.

@teohhanhui
Copy link
Author

teohhanhui commented Jul 9, 2024

I can run Stardew Valley (Linux x86-64 version) through box64 (v0.3.0) now. Yay!

(But Stardew Valley was also running perfectly fine through box64 on 16K kernel anyway... Haha. But box64 was broken for Fedora 40 before this...)

For whoever interested:

#!/bin/sh
STARDEW_VALLEY="$HOME/.local/share/Steam/steamapps/common/Stardew Valley/StardewValley"

export SMAPI_USE_CURRENT_SHELL=true

export BOX64_LOG=1
export BOX64_ROLLING_LOG=1
export BOX64_DLSYM_ERROR=1
export BOX64_SHOWSEGV=1
export BOX64_SHOWBT=1
export BOX64_DYNAREC_LOG=1
export BOX64_DYNAREC_STRONGMEM=1

args_box64_env=$(awk 'END { for (name in ENVIRON) { if (name ~ /^BOX64_/) { printf " -e=%s", name; }}}' < /dev/null)

exec krun $args_box64_env -e=SMAPI_USE_CURRENT_SHELL -- box64 "$STARDEW_VALLEY" "$@"

# if [ "$(cut -d '' -f1 < /proc/1/cmdline)" = '/init.krun' ]; then
# 	exec "${STARDEW_VALLEY}" "$@"
# fi

# if [ -z "${DBX_CONTAINER_MANAGER}" ]; then
# 	export DBX_CONTAINER_MANAGER=podman
# fi

# if [ -n "${CONTAINER_ID}" ]; then
# 	container_name="${CONTAINER_ID}"
# # if the variable is not set, let's fall back to some tricks.
# elif [ -e /.dockerenv ]; then
# 	# we're in docker, let's use this trick
# 	container_name=$(grep "memory:/" < /proc/self/cgroup | sed 's|.*/||')
# elif [ -e /run/.containerenv ]; then
# 	# we're in podman or lilipod, use this other trick
# 	container_name=$(grep "name=" /run/.containerenv | cut -d'=' -f2- | tr -d '"')
# fi

# if [ -z "${container_name}" ]; then
# 	exec "/usr/bin/distrobox-enter" -n asahi-krun -- krun -e=SMAPI_USE_CURRENT_SHELL -- "${STARDEW_VALLEY}" "$@"
# elif [ -n "${container_name}" ] && [ "${container_name}" != "asahi-krun" ]; then
# 	exec distrobox-host-exec "$HOME/.local/bin/stardew-valley" "$@"
# else
# 	exec krun -e=SMAPI_USE_CURRENT_SHELL -- "${STARDEW_VALLEY}" "$@"
# fi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment