fix: read retroarch.cfg for cores in a --dest run

A run given --dest, as every interface run is, never read the config
naming libretro_directory, so only installed cores found none where line
mode found them. core_dirs now asks _retroarch_config_for, as the save
directory does, and the advice to drop --dest goes.
This commit is contained in:
Abdessamad Derraz committed 2026-10-23 22:12:49 +02:00
1 parent b26ce7cbdc
commit 76da554da9
3 files changed
+50 -16

No files matched your search

+12 -13
View File
@@ -2302,11 +2302,12 @@ def core_dirs(plat: str, bios_path: Path) -> list[Path]:
"""The directories the RetroArch writing to bios_path loads cores from.
The config detection read for this system directory names them in
libretro_directory. Without one, a retroarch.cfg beside the system
libretro_directory, read here when the run was given --dest, as the
interface's runs all are. Without one, a retroarch.cfg beside the system
directory is the portable layout. Unset, the setting is cores/ under
RetroArch's own directory.
"""
found = _RETROARCH_CONFIGS.get(bios_path)
found = _retroarch_config_for(bios_path)
if found is None and (bios_path.parent / "retroarch.cfg").is_file():
found = (bios_path.parent / "retroarch.cfg", bios_path.parent)
dirs: list[Path] = []
@@ -3979,9 +3980,10 @@ def _retroarch_config_for(bios_path: Path) -> tuple[Path, Path] | None:
folder ':' expands to there.
A run given --dest detects nothing, so the configs are read here, once
and silently, the first time a save directory is asked for: the
interface names every folder with --dest, and its runs sent Azahar's
keys.txt to a guessed folder where line mode read savefile_directory.
and silently, the first time a save directory or the cores folder is
asked for: the interface names every folder with --dest, and its runs
sent Azahar's keys.txt to a guessed folder where line mode read
savefile_directory, and found no core where line mode found them.
"""
found = _RETROARCH_CONFIGS.get(bios_path)
if found is not None or _CONFIGS_READ:
@@ -8713,12 +8715,12 @@ def _missing_dest(dest: Path, ask: bool, named: str = "named with --dest") -> No
sys.exit(2)
def _no_core_found(plat: str, bios_path: Path, searched: list[Path], dest_given: bool) -> None:
def _no_core_found(plat: str, bios_path: Path, searched: list[Path]) -> None:
"""Refuse --installed-cores with no core, and say how to point at them.
With --dest, detection does not run, and without a retroarch.cfg beside
the folder nothing names the cores folder: the run stopped on "no known
directory" with no way forward.
With no retroarch.cfg naming the folder as its system_directory, and
none beside it, nothing names the cores folder: the run stopped on "no
known directory" with no way forward.
"""
where = (f"none in {', '.join(map(str, searched))}" if searched
else f"no retroarch.cfg was found for {bios_path} to name their folder")
@@ -8728,9 +8730,6 @@ def _no_core_found(plat: str, bios_path: Path, searched: list[Path], dest_given:
"retroarch.cfg, cores/ beside RetroArch by default):", file=sys.stderr)
command = _INVOCATION.command(plat, bios_path, without=("--installed-cores", "--cores-dir"))
print(f" {command} --cores-dir <cores folder>", file=sys.stderr)
if dest_given:
print(" Or run it without --dest: detection reads retroarch.cfg, which names "
"that folder.", file=sys.stderr)
print(" Or run it without --installed-cores to install every file.", file=sys.stderr)
sys.exit(1)
@@ -9156,7 +9155,7 @@ def _install(args: argparse.Namespace, real_stdout: TextIO) -> None:
)
sys.exit(1)
if args.installed_cores and not cores_found[(plat_name, bios_path)]:
_no_core_found(plat_name, bios_path, searched, bool(args.dest))
_no_core_found(plat_name, bios_path, searched)
for plat_name, bios_path in platforms:
if bios_path not in installed_paths:
+34
View File
@@ -488,5 +488,39 @@ class TheOneLinerReadsInstalledCores(unittest.TestCase):
self.assertEqual(repo.installed(), ["gba_bios.bin", "mgba/extra.bin"])
class TheInterfaceFindsTheCoresLineModeFinds(unittest.TestCase):
"""The interface names the BIOS folder with --dest, so its runs never
read retroarch.cfg: "only installed cores" found none where line mode,
detecting the same config, found them (macOS, Flatpak, any custom
system_directory)."""
def test_a_config_away_from_the_bios_folder(self):
with _CoreRepository() as repo:
(repo.root / "retroarch.cfg").unlink()
home = repo.root / "home"
config = home / ".config" / "retroarch"
config.mkdir(parents=True)
cores = repo.root / "elsewhere" / "my cores"
cores.mkdir(parents=True)
(cores / "mgba_libretro.so").write_bytes(b"")
(config / "retroarch.cfg").write_text(
f'system_directory = "{repo.dest}"\n'
f'libretro_directory = "{cores}"\n')
env = {**repo.env(), "HOME": str(home), "RETROBIOS_OS": "linux",
"XDG_CONFIG_HOME": str(home / ".config")}
repo.dest.mkdir()
found = []
for given in ((), ("--dest", str(repo.dest))):
command = [sys.executable, str(REPO_ROOT / "install.py"), "--platform",
"retroarch", *given, "--installed-cores", "--check"]
proc = subprocess.run(command, env=env, capture_output=True, text=True,
timeout=60, check=False, stdin=subprocess.DEVNULL)
self.assertNotIn("no installed core found", proc.stderr)
found.append([line for line in proc.stdout.splitlines()
if "core installed" in line or "Narrowed" in line])
self.assertEqual(found[0], found[1])
self.assertIn(" 1 core installed", found[1])
if __name__ == "__main__":
unittest.main()
+4 -3
View File
@@ -628,9 +628,10 @@ rather than read as having no game data.
`--installed-cores` reads the cores a RetroArch already has and installs what
they need. The cores are the `<name>_libretro.so` (`.dll`, `.dylib`,
`_libretro_android.so`) files in the `libretro_directory` of the
`retroarch.cfg` detection found, `cores/` beside RetroArch when the setting is
unset, a `retroarch.cfg` next to the system directory for a portable install
given with `--dest`, and the folders RetroPie (`/opt/retropie/libretrocores`)
`retroarch.cfg` whose `system_directory` is the BIOS folder, found the same
way with `--dest` or without, `cores/` beside RetroArch when the setting is
unset, a `retroarch.cfg` next to the system directory for a portable install,
and the folders RetroPie (`/opt/retropie/libretrocores`)
and Lakka (`/usr/lib/libretro`, `/storage/cores`) install into. A core file
is named the buildbot's way (`mednafen_psx`), and the manifest maps each name to
the profile its files are filed under (`beetle_psx`).