modrinth / code

The Modrinth monorepo containing all code which powers Modrinth!
https://modrinth.com
Other
989 stars 187 forks source link

Can't stack multiple wrapper commands #1035

Open GeorgeRNG opened 9 months ago

GeorgeRNG commented 9 months ago

Describe the bug

Stacking multiple wrapper commands doesn't work, instead it throws this error:

An error occurred I/O error: No such file or directory (os error 2)

Steps to reproduce

  1. Click settings, scroll down to HooksWrapper
  2. Insert something like gamemoderun prime-run, or stack something else of your choice
  3. Run your instance

Expected behavior

Minecraft runs with both feral gamemode and the nvidia gpu, which can be checked respectively with gamemoded -s; and checking for java in nvidia-smi or checking F3. It works like this in prism, and steam takes a separate route of working like this: gamemoderun prime-run if that's at all relevent

System information

OS: EndeavourOS Linux x86_64 Kernel: 6.6.13-1-lts CPU: AMD Ryzen 5 5600H with Radeon Graphics (12) @ 4.280GHz GPU: NVIDIA GeForce RTX 3060 Mobile / Max-Q GPU: AMD ATI Radeon Vega Series / Radeon Vega Mobile Series

Additional context

This could probably be worked around by using a script file which runs them both. My guess it's attempting to run a file called "gamemoderun prime-run" instead of running "gamemoderun" which then runs prime-run, which runs minecaft. Using any of them individually works, just not both. this is my first use of the launcher, I've written quite a bit whilst multitasking tell me if I've gone insane.

LunaticWyrm467 commented 8 months ago

I can verify this and I am on Archlinux x86_64. This is not great as it is preventing me from running the game on my dedicated graphics card.

hollowshiroyuki commented 7 months ago

One workaround is to wrap your launchers in a single "executable". For instance to put my laptop in performance mode and enable direct opengl capture when launching the game : I have a file at $HOME/.local/bin/perfcapture with execution bit set

#! /usr/bin/env bash
powerprofilesctl launch obs-gamecapture $@

And then in the "Wrapper command" I use perfcapture (or the full path /home/<username>/.local/bin/perfcapture if for some reason $HOME/.local/bin/ is not in the PATH passed to your launcher)

Minenash commented 2 months ago

Insert something like gamemoderun prime-run, or stack something else of your choice

I don't think this would work, as many commands has additional arguments and there's now way to tell when something is an argument or another command

GeorgeRNG commented 2 months ago

when using gamemoderun prime-run, prime-run is an argument of gamemoderun. it just happens the gamemoderun runs it's arguments as a command. there are no other commands, it's all argument. prismlauncher supports this, and steam makes you write gamemoderun prime-run %COMMAND% iirc. prism use a custom splitargs function, the command is just the first arg.

this repo instead uses Command::new, just passing in the whole wrapper as the command. correctly, we need to split it and feed it in with the .args (or .arg) method on the command.

or that is what I understand, from referring to experience and prism. I also don't code in C++ or rust, so there could be a better way. tldr: split by space and the first one is the command, the rest are args. account for escapes and qoutes maybe