Nexus-Mods / NexusMods.App

Home of the development of the Nexus Mods App
https://nexus-mods.github.io/NexusMods.App/
GNU General Public License v3.0
933 stars 45 forks source link

v0.4 Issue - Launch button does not seem to work (Linux, Steam) #1151

Closed Slayer5934 closed 4 months ago

Slayer5934 commented 6 months ago

Bug Report

Summary

When trying to launch Stardew the Launch button does not seem to work. It says Running... then eventually turns back to Launch.

Steps to reproduce

...

What is the expected behaviour?

It launches.

Other information

It is worth noting that I installed SMAPI (and other mods) outside of the Nexus Mods App before getting it. I installed one mod, applied, then launched through steam directly and everything worked fine.

erri120 commented 6 months ago

Are you on Windows or on Linux? Also, can you attach some logs?

Windows: %LOCALAPPDATA%\NexusMods.App\Logs Linux: ~/.local/state/NexusMods.App/Logs

Slayer5934 commented 6 months ago

nexusmods.app.current.log

I do not see anything in the log that would suggest a problem... I could run a dev build or run in debug mode or something if you needed it though

erri120 commented 6 months ago

nexusmods.app.current.log

I do not see anything in the log that would suggest a problem... I could run a dev build or run in debug mode or something if you needed it though

You can try running this command manually:

xdg-open steam://rungameid/413150

On Linux, we currently only support running the game through Steam. The only thing the launch button does is run the command above.

https://github.com/Nexus-Mods/NexusMods.App/blob/5be72d23ea133fac8d5b4f114656b63c48aeb3f8/src/Abstractions/NexusMods.Abstractions.Games/RunGameTool.cs#L116-L142

Slayer5934 commented 6 months ago

xdg-open steam://rungameid/413150 works as expected Running through the mod manager doesn't seem to work, not sure why, it says running tool so perhaps its because I installed Smapi outside of the manager? Just trying to guess image

erri120 commented 6 months ago

@Slayer5934 can you try one of the latest builds at https://github.com/Nexus-Mods/NexusMods.App/actions/runs/8551545718 and check the logs afterwards?

Slayer5934 commented 6 months ago

@Slayer5934 can you try one of the latest builds at https://github.com/Nexus-Mods/NexusMods.App/actions/runs/8551545718 and check the logs afterwards?

i will see

Slayer5934 commented 6 months ago

same result, i see the launcher did try running the command, nothing happened nexusmods.app.current.log

this is me running it through konsole image

erri120 commented 6 months ago
00:00:04.422 [INFO] (NexusMods.CrossPlatform.Process.ProcessFactory) Executing command `xdg-open steam://rungameid/413150`
00:01:04.809 [INFO] (NexusMods.DataModel.ToolManager) Ingesting loadout 393DE461B37E144BB2457E56E9F2B829 from Stardew Valley 1.6.3.24087

It looks like we tried to start the process and then waited for a minute for it to start. For some reason, either steam or the reaper process didn't start within a minute.

erri120 commented 6 months ago

I've got a PR #1206 open that should improve this, or at least give us more information.

erri120 commented 6 months ago

Can you try running https://github.com/Nexus-Mods/NexusMods.App/actions/runs/8646672224

Slayer5934 commented 6 months ago

nexusmods.app.main.current.log app log ^

SystemJournal.txt system log for extra info ^

erri120 commented 6 months ago

@Slayer5934 looks like debug logging wasn't enabled. I've fixed that here: https://github.com/Nexus-Mods/NexusMods.App/actions/runs/8687979869

Can you explain what actually happens on screen? What's supposed to happen is,

1) we start xdg-open steam://rungameid/413150, 2) Steam should open and launch the game, 3) we wait for the steam process to appear, 4) we wait for the reaper process to appear, 5) we wait until the reaper process exists.

Slayer5934 commented 6 months ago

@Slayer5934 looks like debug logging wasn't enabled. I've fixed that here: https://github.com/Nexus-Mods/NexusMods.App/actions/runs/8687979869

Can you explain what actually happens on screen?

I will download and run the new one, When I press launch nothing happens, the only indicator it tried to do anything is it saying launching, steam is already open usually when I try as well

Slayer5934 commented 6 months ago

nexusmods.app.main.current.log

erri120 commented 6 months ago
00:00:07.244 [INFO] (NexusMods.Abstractions.Games.RunGameTool) Starting Run Stardew Valley
00:00:07.268 [INFO] (NexusMods.CrossPlatform.Process.ProcessFactory) Executing command `xdg-open steam://rungameid/413150`
00:00:07.272 [DEBUG] (NexusMods.Abstractions.Games.RunGameTool) Waiting for process `steam` to start within `0:05:00` second(s)
00:00:07.279 [DEBUG] (NexusMods.Abstractions.Games.RunGameTool) Waiting for process `reaper` to start within `0:05:00` second(s)
00:05:07.401 [WARN] (NexusMods.Abstractions.Games.RunGameTool) Process `reaper` failed to start within `0:05:00` second(s)

I think that xdg-open steam://rungameid/413150 might not do anything. How did you install Steam? Are you using the Steam flatpak or something else?

Just be sure, running xdg-open steam://rungameid/413150 in your terminal works just fine? It's weird if that works but this doesn't.

Slayer5934 commented 6 months ago

steam is installed from the arch repositories image image

erri120 commented 5 months ago

@Slayer5934 can you run the following commands in your terminal:

Slayer5934 commented 5 months ago

image I use this https://github.com/akinomyoga/ble.sh I tested "disown" on a background job and it seemed to work fine, though that output definitely does not match what you expected

erri120 commented 5 months ago

https://github.com/Nexus-Mods/NexusMods.App/issues/1151#issuecomment-2063447963 @l0b0 can you run these commands as well?

l0b0 commented 5 months ago

@Slayer5934 can you run the following commands in your terminal:

* `echo $SHELL` (expected: either `/usr/bin/bash` or `/usr/bin/zsh`)

* `which disown` (expected: `disown: shell built-in command`)

* `which xdg-open` (expected: `/usr/bin/xdg-open`)

* `xdg-open --version` (expected: `xdg-open 1.2.1`)

#1151 (comment) @l0b0 can you run these commands as well?

I think you meant type disown; which doesn't detect built-ins.

❯ echo $SHELL
/run/current-system/sw/bin/bash
❯ which disown
which: no disown in (/nix/store/[omitted giant PATH])
❯ type disown
disown is a shell builtin
❯ which xdg-open
/run/current-system/sw/bin/xdg-open
❯ xdg-open --version
xdg-open 1.2.1
erri120 commented 4 months ago

@l0b0 and @Slayer5934 how did you install Steam? Did you use flatpak, your system package manager, or something else? Also, can you check if links in diagnostics or in the changelog are clickable? This might either be an issue with how we use xdg-open in general or just Steam.

I'm really perplexed by this issue because xdg-open appears to be working fine if you run it in a normal terminal but fails when we spawn a process with the same command.

If there isn't anything obvious that we've somehow missed, I'll probably rework how we do this entirely.

l0b0 commented 4 months ago

[…] how did you install Steam? Did you use flatpak, your system package manager, or something else?

I basically just set programs.steam.enable = true; in my NixOS configuration and run nixos-rebuild to build the system.

Also, can you check if links in diagnostics or in the changelog are clickable? This might either be an issue with how we use xdg-open in general or just Steam.

The test process:

  1. Check out https://github.com/NixOS/nixpkgs/pull/270372
  2. Rebase onto upstream master
  3. Build with nix-build --attr pkgs.nexus-mods-app
  4. Run ./result/bin/NexusMods.App
  5. Try to run Skyrim

CLI logs:

00:03:35.903 [INFO] Executing command `/home/victor/.local/share/Steam/steamapps/common/Skyrim Special Edition/skse64_loader.exe `
00:03:35.905 [ERROR] Encountered an exception published to an object with an unobserved ThrownExceptions property|System.ComponentModel.Win32Exception (0x80004005): Failed to start a process with file path '/home/victor/.local/share/Steam/steamapps/common/Skyrim Special Edition/skse64_loader.exe'. Target file or working directory doesn't exist, or the provided credentials are invalid.
 ---> System.ComponentModel.Win32Exception (8): An error occurred trying to start process '/home/victor/.local/share/Steam/steamapps/common/Skyrim Special Edition/skse64_loader.exe' with working directory '/home/victor/.local/share/Steam/steamapps/common/Skyrim Special Edition'. Exec format error
   at System.Diagnostics.Process.ForkAndExecProcess(ProcessStartInfo startInfo, String resolvedFilename, String[] argv, String[] envp, String cwd, Boolean setCredentials, UInt32 userId, UInt32 groupId, UInt32[] groups, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean usesTerminal, Boolean throwOnNoExec)
   at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
   at CliWrap.Utils.ProcessEx.Start() in /_/CliWrap/Utils/ProcessEx.cs:line 56
   at CliWrap.Utils.ProcessEx.Start() in /_/CliWrap/Utils/ProcessEx.cs:line 68
   at CliWrap.Command.ExecuteAsync(CancellationToken forcefulCancellationToken, CancellationToken gracefulCancellationToken) in /_/CliWrap/Command.Execution.cs:line 307
   at CliWrap.Command.ExecuteAsync(CancellationToken cancellationToken) in /_/CliWrap/Command.Execution.cs:line 326
   at NexusMods.CrossPlatform.Process.ProcessFactory.ExecuteAsync(Command command, CancellationToken cancellationToken) in /build/source/src/NexusMods.CrossPlatform/Process/ProcessFactory.cs:line 26
   at NexusMods.Abstractions.Games.RunGameTool`1.RunCommand(CancellationToken cancellationToken, AbsolutePath program) in /build/source/src/Abstractions/NexusMods.Abstractions.Games/RunGameTool.cs:line 134
   at NexusMods.Abstractions.Games.RunGameTool`1.Execute(Loadout loadout, CancellationToken cancellationToken) in /build/source/src/Abstractions/NexusMods.Abstractions.Games/RunGameTool.cs:line 101
   at NexusMods.DataModel.ToolManager.RunTool(ITool tool, Loadout loadout, Nullable`1 generatedFilesMod, CancellationToken token) in /build/source/src/NexusMods.DataModel/ToolManager.cs:line 51
   at NexusMods.App.UI.LeftMenu.Items.LaunchButtonViewModel.<>c__DisplayClass19_0.<<LaunchGame>b__0>d.MoveNext() in /build/source/src/NexusMods.App.UI/LeftMenu/Items/LaunchButtonViewModel.cs:line 42
--- End of stack trace from previous location ---
   at NexusMods.App.UI.LeftMenu.Items.LaunchButtonViewModel.LaunchGame(CancellationToken token) in /build/source/src/NexusMods.App.UI/LeftMenu/Items/LaunchButtonViewModel.cs:line 40

The diagnostics panel doesn't show anything, and I can't see a changelog button anywhere. Where is it? Will check this in v0.5.

I'm really perplexed by this issue because xdg-open appears to be working fine if you run it in a normal terminal but fails when we spawn a process with the same command.

Doesn't xdg-open rely on variables such as PATH and XDG_…, to determine either which program to run, or where to find those programs? Could it be that those are changed/unset in the context of NMA?


I'll try to upgrade to v0.5 to see if that changes anything.

Sewer56 commented 4 months ago
 ---> System.ComponentModel.Win32Exception (8): An error occurred trying to start process '/home/victor/.local/share/Steam/steamapps/common/Skyrim Special Edition/skse64_loader.exe' with working directory '/home/victor/.local/share/Steam/steamapps/common/Skyrim Special Edition'. Exec format error

I'm presuming it tried to start a Windows binary as a regular Linux one, but Wine is not present or set as the default handler, i.e. sudo xdg-mime default.

More importantly, I'd guess we're probably not handling running of tools (SKSE) via a WINEPREFIX, regardless of whether we need to run it via Proton or Wine.

That's a problem yet to be resolved. Skyrim is also currently unsupported and hasn't been touched since an eternity ago.

Try Stardew Valley for the time being, see how that goes.

l0b0 commented 4 months ago

That's a problem yet to be resolved. Skyrim is also currently unsupported and hasn't been touched since an eternity ago.

Try Stardew Valley for the time being, see how that goes.

I don't have that game, so I don't think I'll be able to contribute much more to this issue.

erri120 commented 4 months ago

Doesn't xdg-open rely on variables such as PATH and XDG_…, to determine either which program to run, or where to find those programs? Could it be that those are changed/unset in the context of NMA?

@l0b0 We inherit the environment variables from the environment the App is running in. If you're starting the App from the shell, then it would inherit all environment variables that are present in the current shell session.

Greg-Nexus commented 4 months ago

nexusmods.app.main.current.log

I'm able to reproduce this on my Steam Deck, I think this is the correct log file.

erri120 commented 4 months ago

This issue might be fixed with #1533.

erri120 commented 4 months ago

Fixed with #1533, confirmed by two testers.