diff --git a/install.ps1 b/install.ps1 index cd200b066..8993c22fb 100644 --- a/install.ps1 +++ b/install.ps1 @@ -16,7 +16,7 @@ # and Invoke-WebRequest throws on a cut transfer before the hash is read: # the site's build rewrites this line there (scripts/sitebootstrap.py). $mismatchAdvice = "The download was most likely cut short: try again. Within minutes of an update of this project the two files can come from caches of different ages. Waiting five minutes settles that." - $defaultInstallSha256 = "5bce9f0f81e4f1c7302ca78fa5242f26acc06523f8718378ee97042f2421ff78" + $defaultInstallSha256 = "ed2094adddcafccf57250f16c5e5bcf2ede1d741e0b0f94094ae9828c685431d" $maximumInstallerBytes = 2MB $installerExit = 0 $installer = if ($PSScriptRoot) { Join-Path $PSScriptRoot "install.py" } else { $null } diff --git a/install.py b/install.py index 5f372b33f..aa3c080a3 100644 --- a/install.py +++ b/install.py @@ -1324,13 +1324,22 @@ def _steam_libraries() -> list[Path]: Steam lists the others in steamapps/libraryfolders.vdf, each as a "path" line. A RetroArch installed on D:/SteamLibrary was not found - when only Program Files was searched. + when only Program Files was searched. The client's own folder is the + SteamPath value it writes under HKCU\\Software\\Valve\\Steam, read the + same way by Playnite (PlayniteExtensions 886468f6, + source/Libraries/SteamLibrary/Steam.cs:34-38): a client installed in + D:\\Steam hid every library. """ roots: list[Path] = [] + steam_path = _read_registry("HKCU\\Software\\Valve\\Steam", "SteamPath") + candidates = [_host_path(steam_path.replace("/", "\\"))] if steam_path else [] for var in ("ProgramFiles(x86)", "ProgramFiles"): base = os.environ.get(var, "") - if base and _is_dir(Path(base) / "Steam"): - roots.append(Path(base) / "Steam") + if base: + candidates.append(Path(base) / "Steam") + for candidate in candidates: + if candidate not in roots and _is_dir(candidate): + roots.append(candidate) libraries = list(roots) for root in roots: vdf = root / "steamapps" / "libraryfolders.vdf" @@ -2919,15 +2928,9 @@ def detect_platforms(os_type: str) -> list[tuple[str, Path]]: if ra_dir: found.append(("retroarch", ra_dir)) - # RetroArch from Steam: a portable install under the default library - for var in ("ProgramFiles(x86)", "ProgramFiles"): - program_files = os.environ.get(var, "") - if not program_files: - continue - steam_cfg = ( - Path(program_files) / "Steam" / "steamapps" / "common" - / "RetroArch" / "retroarch.cfg" - ) + # RetroArch from Steam: a portable install in a Steam library + for library in _steam_libraries(): + steam_cfg = library / "steamapps" / "common" / "RetroArch" / "retroarch.cfg" ra_dir = _parse_retroarch_system_dir(steam_cfg) if ra_dir and not any(name == "retroarch" for name, _ in found): found.append(("retroarch", ra_dir)) diff --git a/install.sh b/install.sh index 979021d69..10101b8d9 100755 --- a/install.sh +++ b/install.sh @@ -23,7 +23,7 @@ DEFAULT_INSTALL_URL="https://raw.githubusercontent.com/Abdess/retrobios/main/ins # curl or wget stop on a cut transfer before the hash is read: the site's # build rewrites this line there (scripts/sitebootstrap.py). MISMATCH_ADVICE="The download was most likely cut short: try again. Within minutes of an update of this project the two files can come from caches of different ages. Waiting five minutes settles that." -DEFAULT_INSTALL_SHA256="5bce9f0f81e4f1c7302ca78fa5242f26acc06523f8718378ee97042f2421ff78" +DEFAULT_INSTALL_SHA256="ed2094adddcafccf57250f16c5e5bcf2ede1d741e0b0f94094ae9828c685431d" MAX_INSTALLER_BYTES=2097152 cleanup() { diff --git a/install/launchers/index.json b/install/launchers/index.json index 4cbfbf06e..5203a4da2 100644 --- a/install/launchers/index.json +++ b/install/launchers/index.json @@ -27,8 +27,8 @@ { "dest": "roms/ports/retrobios/install.py", "repo_path": "install.py", - "size": 1117350, - "sha256": "5bce9f0f81e4f1c7302ca78fa5242f26acc06523f8718378ee97042f2421ff78", + "size": 1117672, + "sha256": "ed2094adddcafccf57250f16c5e5bcf2ede1d741e0b0f94094ae9828c685431d", "executable": false }, { @@ -71,8 +71,8 @@ "muos": { "archive": { "dest": "ARCHIVE/RetroBIOS.muxapp", - "size": 1170977, - "sha256": "cfb61e90dafef4fceadd8750412fe91a98b5d8cbf9574c819c09bddb76486e78" + "size": 1171299, + "sha256": "3329f55c1b46d953dd8745c0ff508315db8185e0530c842beb6e944d7262ac5a" }, "members": [ { @@ -92,8 +92,8 @@ { "name": "RetroBIOS/install.py", "repo_path": "install.py", - "size": 1117350, - "sha256": "5bce9f0f81e4f1c7302ca78fa5242f26acc06523f8718378ee97042f2421ff78", + "size": 1117672, + "sha256": "ed2094adddcafccf57250f16c5e5bcf2ede1d741e0b0f94094ae9828c685431d", "executable": false }, { @@ -166,8 +166,8 @@ { "dest": ".config/modules/retrobios/install.py", "repo_path": "install.py", - "size": 1117350, - "sha256": "5bce9f0f81e4f1c7302ca78fa5242f26acc06523f8718378ee97042f2421ff78", + "size": 1117672, + "sha256": "ed2094adddcafccf57250f16c5e5bcf2ede1d741e0b0f94094ae9828c685431d", "executable": false }, { diff --git a/tests/test_install.py b/tests/test_install.py index e1aa93888..bada682d6 100644 --- a/tests/test_install.py +++ b/tests/test_install.py @@ -4511,6 +4511,33 @@ class WindowsSeenFromWsl(unittest.TestCase): self.assertEqual(os.environ["ProgramFiles"], "") + def test_a_steam_client_outside_program_files_is_found(self): + """A Steam client in D:\\Steam hid every library: only Program Files + was searched, and Steam's RetroArch was not detected.""" + empty = self.root / "c" / "Program Files (x86)" + empty.mkdir(parents=True) + common = self.root / "d" / "steam" / "steamapps" / "common" / "RetroArch" + common.mkdir(parents=True) + (common / "retroarch.exe").write_bytes(b"MZ") + (common / "retroarch.cfg").write_text('system_directory = "default"\n') + home = Path(_tempdir(self)) + cleared = {name: "" for name in (*install._WINDOWS_VARIABLES, "SCOOP", "SCOOP_GLOBAL", + "ProgramData")} + asked: list = [] + + def registry(key, value): + asked.append((key, value)) + return "d:/steam" if (key, value) == ("HKCU\\Software\\Valve\\Steam", + "SteamPath") else None + + with unittest.mock.patch.dict(os.environ, {**cleared, "HOME": str(home), + "ProgramFiles(x86)": str(empty)}), \ + unittest.mock.patch.object(Path, "home", return_value=home), \ + unittest.mock.patch.object(install, "_read_registry", registry): + self.assertEqual(install._steam_libraries(), [self.root / "d" / "steam"]) + found = install.detect_platforms("wsl") + self.assertIn(("retroarch", common / "system"), found) + def test_windows_not_answering_is_said_not_taken_for_nothing(self): """cmd.exe timing out on the first variable ended the import without a word, and detection said no setup was installed.""" diff --git a/wiki/installer.md b/wiki/installer.md index 7ed1725ed..fe5050893 100644 --- a/wiki/installer.md +++ b/wiki/installer.md @@ -1181,7 +1181,7 @@ usual folders of a setup that has one on each side: RetroArch's in this Linux | `~/Library/Application Support/RetroArch/config/retroarch.cfg` | RetroArch (macOS) | `system_directory`. At default, `~/Documents/RetroArch/system` (portable, Steam build included: `Application Support/RetroArch/system`) | | `retroarch.cfg` beside `retroarch.exe` (`C:\RetroArch-Win64`, `C:\RetroArch`, `Program Files\RetroArch`) | RetroArch (Windows) | `system_directory`. At default or without a config, `system` beside the exe | | `%APPDATA%\RetroArch\retroarch.cfg` | RetroArch (Windows) | `system_directory`, read when the exe folder has no config | -| `%ProgramFiles(x86)%\Steam\steamapps\common\RetroArch\retroarch.cfg` | RetroArch (Steam) | `system_directory` | +| `steamapps\common\RetroArch\retroarch.cfg` in every Steam library: the client's folder (`SteamPath` under `HKCU\Software\Valve\Steam`, else `%ProgramFiles(x86)%\Steam`) and the libraries its `libraryfolders.vdf` lists | RetroArch (Steam) | `system_directory` | | `%LOCALAPPDATA%\Packages\1e4cf179-f3c2-404f-b9f3-cb2070a5aad8_*\LocalState` | RetroArch (UWP/MSIX package) | `system_directory` of the `retroarch.cfg` there, `~` meaning that folder. By default `LocalState\system` | | LaunchBox `Data\Emulators.xml` | RetroArch (portable) | the system directory that entry points at | | LaunchBox `Data\Emulators.xml` naming `EmuHawk.exe` | BizHawk (portable) | `Firmware` beside `EmuHawk.exe` |