r2modmanPlus icon indicating copy to clipboard operation
r2modmanPlus copied to clipboard

[BUG] - Linux native modding doesn't work

Open Damglador opened this issue 5 months ago • 25 comments

Describe the bug I configured EtG launch parameters with what r2modman gave me "/home/damglador/.config/r2modmanPlus-local/ETG/linux_wrapper.sh" %command%, installed BepInEx_EtG and mod the gungeon API, but when I try to launch the game from the launcher as modded or just through Steam it just instantly closes

To Reproduce Steps to reproduce the behavior:

  1. Install native EtG
  2. Launch r2modman
  3. Select EtG
  4. Copy the command it gives and paste it in Steam launch arguments for EtG
  5. Try to launch EtG from Steam or r2modman

Expected behavior You know, working

Additional context I wasted some time playing with the bepinex script and was able to fix it.

The script didn't work at all for Enter The Gungeon, but after some rewriting, though also removing MacOS code, it launches the game and can successfully switch profiles. I just need to move the script in game directory and add ./doorstop %command% in launch parameters (doorstop being the script), after that Gale and r2modman can mod the game without an issue, and it doesn't have to use linux_wrapper.sh.

My script https://gist.github.com/Damglador/8063983f424a800531699cdc7e894462

Issues

List of general and per-game issues and how users can workaround them

General

  • ~~Linux wrapper is broken https://github.com/ebkr/r2modmanPlus/pull/1843~~
  • BepInEx run scripts are broken
    • Spaces in path issue like in Linux wrapper
    • The script expects game executable to be in the same directory as itself, but placed in the profile directory
    • Script checks for SteamLaunch as the second argument, but right now it's the fourth argument
    • Script tries to re-execute itself with exec $cmd $@, but fails
    • It shifts 4 arguments on shift 4, but the Steam right now gives ~12, it also doesn't account for the case of another wrapper or an argument placed after the script and before %command%, which will likely break the script. My script just discards all arguments between itself and the game executable, which is also not ideal, but at least reliable
  • Changing game installation directory is not possible, because r2modman looks for exe files, and it gives wrong filter for file picker

Solution: use https://gist.github.com/Damglador/8063983f424a800531699cdc7e894462

Enter the Gungeon

  • BepInEx requires mono installed on the system

Workaround: install mono, on Arch sudo pacman -S mono, on Ubuntu and alike sudo apt install libmono-2.0-dev

As a small note, you also need SDL2 on the system for the game to work, on Arch it's sdl2-compat, on Ubuntu it's libsdl2-2.0-0 or libsdl2-compat (I think).

Inscryption

  • Can't run at all from r2modman, gives:
Error
An unhandled error occurred
ENOENT: no such file or directory, open '/home/Games/SteamLibrary/steamapps/compatdata/1092790/pfx/user.reg'

Workaround: move BepInEx, doorstop_libs and my doorstop.sh to the game directory and launching it from Steam with ./doorstop.sh %command%. You can symlink BepInEx directory if you don't want to copy over newly installed mods

Ultimate Chicken Horse

  • r2modman doesn't even download bepinex run script and doorstop_libs

Workaround: steal doorstop_libs a profile of another Linux-native game

Straftat

  • r2modman doesn't download bepinex run script and doorstop_libs

Damglador avatar Jul 09 '25 23:07 Damglador

https://github.com/ebkr/r2modmanPlus/pull/1843 doesn't fix this, but does at least make some progress in fixing it

Damglador avatar Jul 10 '25 00:07 Damglador

Essential issues:

First the BASEDIR line has to be replaced with

a="/$0"; a=${a%/*}; a=${a#/}; a=${a:-.}; BASEDIR=$(cd "$a" || exit; pwd -P)

Then

if [ "$4" = "SteamLaunch" ]; then
    shift 12
fi

The relaunching seems to be redundant and just breaks the thing.

Then exec has to NOT be "$BASEDIR/EtG.$arch", because BASEDIR is where the script is, and that's the profile folder, so r2modman has to either pass another variable to define the executable or path to the game folder, and only if the passed variable is missing it should default to BASEDIR.

Damglador avatar Jul 10 '25 00:07 Damglador

The script didn't work at all for Enter The Gungeon, but after some rewriting, though also removing MacOS code, it launches the game and can successfully switch profiles. I just need to move the script in game directory and add ./doorstop %command% in launch parameters (doorstop being the script), after that Gale and r2modman can mod the game without an issue, and it doesn't have to use linux_wrapper.sh.

Curious if this routine would fix things for UCH (https://github.com/ebkr/r2modmanPlus/issues/1845), could you provide the modified script you used to get EtG working? If it fixes it it'd probably be better to fold #1845 in to this one as just another effected app.

EDIT: Honestly, looking in to this further I'm rather confused how/when this even got broken.

EtG, the game you're originally reporting, is: - linux native - unity based - mods using beepinex - prompts for/requires the issue wrapper script

On the other hand, UCH, which has at least a similar issue: - windows only (uses proton) - unity based - mods using beepinex - prompts for/requires the issue wrapper script

But then there's PEAK: - windows only (uses proton)
- unity based - mods using beepinex - doesn't prompt for or use any wrapper script, and mods fine with no intervention out of the box

Maybe I'm missing something, but shouldn't these all be sharing basically the same runtime?

Edit2 : Scratch everything I said above, didn't realize it but UCH is a linux native game, thus why its got issues as well.

raku-cat avatar Jul 10 '25 05:07 raku-cat

Yeah sure, I'll fix (or rather test) UHC, I have it.

It got broken because Windows uses a completely different loading mechanism I suppose. So the Linux script isn't even needed and that's what broke

Damglador avatar Jul 10 '25 12:07 Damglador

I am having the same problem as Damglador. Can you explain to me how i can fix it like i am five?

Orlando189 avatar Jul 11 '25 01:07 Orlando189

Get doorstop.sh from https://gist.github.com/Damglador/8063983f424a800531699cdc7e894462, put it in the game directory and in Steam edit launch arguments to ./doorstop.sh %command%. Also for now you have to edit a variable called executable to match your game's executable name. Basically replace EtG.$(uname -m) with, for example, valheim.x86_64. Oh and you also have to move folder called doorstop_libs from /home/damglador/.config/r2modmanPlus-local/$GAME/profiles/$PROFILE/ to the game directory near the script.

I'll try to make it more automated later.

After that you can either launch the game from Steam and it'll try to load BepInEx in game directory or you can launch it from r2modman or Gale and it'll load the profile you're launching

Damglador avatar Jul 11 '25 20:07 Damglador

@raku-cat UCH problem is deeper. r2modman doesn't even download native doorstop libs for it, as well as the script that linux_wrapper.sh is supposed to use. Nothing unfixable though

Image

Just dropped my doorstop.sh in profile directory, yoinked doorstop_libs folder from Enter The Gungeon and placed it near the script and replaced the launch arguments with /home/damglador/.config/r2modmanPlus-local/UltimateChickenHorse/profiles/Default/doorstop.sh %command%

Profile directory should look like that:

/home/damglador/.config/r2modmanPlus-local/UltimateChickenHorse/profiles/Default
├── BepInEx
├── doorstop_config.ini
├── doorstop_libs
│   ├── libdoorstop_x64.dylib
│   ├── libdoorstop_x64.so
│   └── libdoorstop_x86.so
├── doorstop.sh
├── mods.yml
├── _state
│   └── installation_state.yml
└── winhttp.dll

After should be able to use other profiles from r2modman/Gale without any modifications, just leave in place doorstop.sh and doorstop_libs

Damglador avatar Jul 12 '25 00:07 Damglador

How do I put the doorstop.sh in the game directory?

Orlando189 avatar Jul 12 '25 00:07 Orlando189

Just create a file called doorstop.sh and copy-paste the script in it. Also make sure it's executable, either by setting a check file's properties through file manager or by doing chmod +x /path/to/doorstop.sh

In Dolphin I can make it executable with this checked

Image

Damglador avatar Jul 12 '25 01:07 Damglador

I selected launch as executable. When i click run program on doorstop.sh it opens the terminal for a split second, then the game opens and runs for a couple of seconds and then it crashes. I have the correct launch options in steam.

Orlando189 avatar Jul 12 '25 04:07 Orlando189

Yes, that's a thing if you try to launch it not from Steam if it's a Steam game.

You have to just add ./doorstop.sh %command% to launch arguments and launch it either through Steam or r2modman.

Damglador avatar Jul 12 '25 04:07 Damglador

Just need to know is steam launch options different to launch arguments? If so how do i add the command to launch arguments. Sorry to bother you i am very new to this stuff.

Orlando189 avatar Jul 12 '25 04:07 Orlando189

I added it to the launch options on steam in properties (If that's what your talking about). The game dose not launch. It plays then stops playing.

Orlando189 avatar Jul 12 '25 07:07 Orlando189

@raku-cat UCH problem is deeper. r2modman doesn't even download native doorstop libs for it, as well as the script that linux_wrapper.sh is supposed to use. Nothing unfixable though Image

Just dropped my doorstop.sh in profile directory, yoinked doorstop_libs folder from Enter The Gungeon and placed it near the script and replaced the launch arguments with /home/damglador/.config/r2modmanPlus-local/UltimateChickenHorse/profiles/Default/doorstop.sh %command%

Profile directory should look like that:

/home/damglador/.config/r2modmanPlus-local/UltimateChickenHorse/profiles/Default
├── BepInEx
├── doorstop_config.ini
├── doorstop_libs
│   ├── libdoorstop_x64.dylib
│   ├── libdoorstop_x64.so
│   └── libdoorstop_x86.so
├── doorstop.sh
├── mods.yml
├── _state
│   └── installation_state.yml
└── winhttp.dll

After should be able to use other profiles from r2modman/Gale without any modifications, just leave in place doorstop.sh and doorstop_libs

Followed this, working for me here:

Image ("More" option is from mod)

raku-cat avatar Jul 12 '25 10:07 raku-cat

I updated the script a bit, now it should be able to find the game executable by itself, so editing it shouldn't be a requirement anymore. Would also be nice to have some fallbacks for doorstop_libs, so they don't have to be near the script. I would even try making it MacOS compatible, but I don't have an environment to test it in, and since neither Gale nor r2modman target MacOS, for now that shouldn't matter.

Damglador avatar Jul 12 '25 12:07 Damglador

Still not working. Thank you for helping me.

Orlando189 avatar Jul 12 '25 12:07 Orlando189

@Orlando189 message me on Discord (or Steam), link in my profile

Damglador avatar Jul 12 '25 12:07 Damglador

Sent you a friend request on discord

Orlando189 avatar Jul 12 '25 12:07 Orlando189

Seems like BepInEx also requires mono installed on the system. This should be added to the disclaimer about Linux native modding

Damglador avatar Jul 13 '25 14:07 Damglador

What's interesting is that seems to be exclusive to Enter the Gungeon. Valheim can run BepInEx without system installed mono

Damglador avatar Jul 13 '25 16:07 Damglador

BepInEx run scripts are broken

  1. Spaces in path issue like in Linux wrapper
  2. The script expects game executable to be in the same directory as itself, but placed in the profile directory
  3. Script checks for SteamLaunch as the second argument, but right now it's the fourth argument
  4. Script tries to re-execute itself with exec $cmd $@, but fails
  5. It shifts 4 arguments on shift 4, but the Steam right now gives ~12, it also doesn't account for the case of another wrapper or an argument placed after the script and before %command%, which will likely break the script. My script just discards all arguments between itself and the game executable, which is also not ideal, but at least reliable

I fixed all of these in https://github.com/NeighTools/UnityDoorstop/pull/74. For the 2nd one it can be fixed by changing your equivalent of target_assembly="Doorstop.dll" to target_assembly="$BASEDIR/Doorstop.dll".

arrowmaster avatar Jul 24 '25 07:07 arrowmaster

For the 2nd one it can be fixed by changing your equivalent of target_assembly="Doorstop.dll" to target_assembly="$BASEDIR/Doorstop.dll".

To be more clear on this, in my changes the game executable listed in the script is never run when its launched through steam, its only used to find which argument passed by steam contains the executable and then it runs that. But when working on this I found that with doorstop 4.4.0, DOORSTOP_TARGET_ASSEMBLY needed to be an absolute path to bepinex if it was installed to an r2modman profile instead of directly into the game dir.

arrowmaster avatar Jul 24 '25 08:07 arrowmaster

The launch options still aren’t working. Is there a fix for this somewhere that I can try? Or like, an older version of something that isn’t broken?

Having to launch modded through the R2MM application sucks so much on Steam deck for a whole bunch of reasons I won’t get into.

I’m super frustrated. Every single guide (and the application itself) says to just copy those launch options into Steam and it should work, but it doesn’t. It won’t launch modded.

Please let me know if there’s like, a file I can download and put somewhere, or if I can downgrade the application or something. I’m losing it.

correii avatar Jul 29 '25 05:07 correii

Having to launch modded through the R2MM application sucks so much on Steam deck for a whole bunch of reasons I won’t get into.

I’m super frustrated. Every single guide (and the application itself) says to just copy those launch options into Steam and it should work, but it doesn’t. It won’t launch modded.

This sounds like its working exactly as its supposed to be. By default with Native Linux games when you launch them from Steam it does not launch modded, you must launch them by clicking Launch Modded in R2MM. You can add a --r2profile to the launch args in steam to change the default from ummodded to modded but you must add --r2profile PROFILENAME before the %command%. This is not documented AFAIK but it works.

arrowmaster avatar Jul 29 '25 08:07 arrowmaster

@correii assuming you have the custom script in the game directory, ./doorstop.sh %command% --doorstop-enable true --doorstop-target "/home/damglador/.config/r2modmanPlus-local/ETG/profiles/Default/BepInEx/core/BepInEx.Preloader.dll" --r2profile "Default" should work perfectly fine, everything after %command% is what r2modman gives you at the bottom of Help > General

Damglador avatar Jul 29 '25 19:07 Damglador