Skip to content

Commit

Permalink
Check for incomplete Proton installation
Browse files Browse the repository at this point in the history
Incomplete Proton installations where the `dist` directory does not
exist yet cause Protontricks to crash. Check for this and instruct the
user to launch a Steam app at least once to ensure the installation is
complete.

Refs flathub/com.github.Matoking.protontricks#10
  • Loading branch information
Matoking committed Jan 25, 2022
1 parent 9007e4d commit 3e6dc84
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Fixed
- Fix Wine crash when the Steam application and Protontricks are running at the same time
- Fix Steam installation detection when both non-Flatpak and Flatpak versions of Steam are installed for the same user
- Fix Protontricks crash when Proton installation is incomplete

## [1.7.0] - 2022-01-08
### Changed
Expand Down
7 changes: 7 additions & 0 deletions src/protontricks/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,13 @@ def exit_(error):
if not proton_app:
exit_("Proton installation could not be found!")

if not proton_app.is_proton_ready:
exit_(
"Proton installation is incomplete. Have you launched a Steam app "
"using this Proton version at least once to finish the "
"installation?"
)

# If neither search or GUI are set, do a normal Winetricks command
# Find game by appid
steam_appid = int(args.appid)
Expand Down
10 changes: 10 additions & 0 deletions src/protontricks/steam.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,16 @@ def is_windows_app(self):
"""
return not self.is_proton and self.prefix_path_exists and self.appid

@property
def is_proton_ready(self):
"""
Return True if the Proton installation is ready for use.
Proton installation might be incomplete if it hasn't been launched
yet, in which case the Proton binaries don't exist yet.
"""
return bool(self.proton_dist_path)

@property
def proton_dist_path(self):
"""
Expand Down
19 changes: 19 additions & 0 deletions tests/cli/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,25 @@ def test_run_compat_tool_not_proton(
record.getMessage()
)

def test_run_command_proton_incomplete(
self, cli, steam_app_factory, default_proton):
"""
Try performing a Protontricks command using a Proton installation that
is incomplete because it hasn't been launched yet.
Regression test for
https://github.com/flathub/com.github.Matoking.protontricks/issues/10
"""
# Remove the 'dist' directory to make the Proton installation
# incomplete
shutil.rmtree(str(default_proton.install_path / "dist"))

steam_app_factory(name="Fake game", appid=10)

result = cli(["10", "winecfg"], expect_returncode=1)

assert "Proton installation is incomplete" in result

def test_run_command_runtime_incomplete(
self, cli, steam_app_factory, steam_runtime_soldier,
command, proton_factory, steam_dir):
Expand Down

0 comments on commit 3e6dc84

Please sign in to comment.