Suggestion of Steam issue solution
Mortasen opened this issue · 5 comments
When I try to launch mapshot to render a map for my save, this window appears:
and the program says: "Error: factorio exited early" even if I press OK.
Here is the log:
$ ./mapshot-linux render test --factorio_binary factorio_link/bin/x64/factorio --alsologtostderr --factorio_verbose
I1112 16:06:52.085064 28920 factorio.go:275] Path /opt/factorio does not exists, skipped
I1112 16:06:52.086357 28920 factorio.go:282] Found factorio data dir: /home/namerif/.factorio
I1112 16:06:52.086409 28920 factorio.go:275] Path /home/namerif/factorio does not exists, skipped
I1112 16:06:52.086433 28920 factorio.go:275] Path /home/namerif/Library/Application Support/factorio does not exists, skipped
I1112 16:06:52.086453 28920 factorio.go:289] Using Factorio data dir: /home/namerif/.factorio
I1112 16:06:52.086469 28920 factorio.go:275] Path /opt/factorio does not exists, skipped
I1112 16:06:52.086484 28920 factorio.go:282] Found factorio data dir: /home/namerif/.factorio
I1112 16:06:52.086497 28920 factorio.go:275] Path /home/namerif/factorio does not exists, skipped
I1112 16:06:52.086511 28920 factorio.go:275] Path /home/namerif/Library/Application Support/factorio does not exists, skipped
I1112 16:06:52.086520 28920 factorio.go:289] Using Factorio data dir: /home/namerif/.factorio
I1112 16:06:52.087334 28920 factorio.go:355] Factorio binary found: factorio_link/bin/x64/factorio
I1112 16:06:52.087355 28920 factorio.go:362] Using Factorio binary: factorio_link/bin/x64/factorio
I1112 16:06:52.087379 28920 render.go:105] runid: b7f357c9-88c2-4ca7-8a67-20b1b48000e5
I1112 16:06:52.087486 28920 root.go:30] temp dir: /tmp/mapshot3663988854
I1112 16:06:52.087517 28920 factorio.go:116] Looking for save "test"; test does not exists.
I1112 16:06:52.087534 28920 factorio.go:116] Looking for save "test"; test.zip does not exists.
I1112 16:06:52.087762 28920 factorio.go:110] Looking for save "test"; /home/namerif/.factorio/saves/test.zip exists.
Generating mapshot "test" using file /home/namerif/.factorio/saves/test.zip
I1112 16:06:52.093038 28920 render.go:125] copied save from "/home/namerif/.factorio/saves/test.zip" to "/tmp/mapshot3663988854/test.zip"
I1112 16:06:52.093567 28920 factorio.go:183] copying mod mod-list.json from /home/namerif/.factorio/mods/mod-list.json to /tmp/mapshot3663988854/mods/mod-list.json
I1112 16:06:52.094088 28920 factorio.go:206] created mod-list.json
I1112 16:06:52.095460 28920 render.go:141] mod created at "/tmp/mapshot3663988854/mods/mapshot"
I1112 16:06:52.095602 28920 render.go:94] overrides file created at "/tmp/mapshot3663988854/mods/mapshot/overrides.lua"
I1112 16:06:52.095627 28920 render.go:155] removed done-file "/home/namerif/.factorio/script-output/mapshot-done-b7f357c9-88c2-4ca7-8a67-20b1b48000e5": remove /home/namerif/.factorio/script-output/mapshot-done-b7f357c9-88c2-4ca7-8a67-20b1b48000e5: no such file or directory
Starting Factorio...
I1112 16:06:52.095716 28920 factorio.go:124] Running factorio with args: [--disable-audio --disable-prototype-history --load-game /tmp/mapshot3663988854/test.zip --mod-directory /tmp/mapshot3663988854/mods]
0.000 Initializing Steam API.
Running Steam on linuxmint 20.1 64-bit
STEAM_RUNTIME is enabled automatically
Steam runtime environment up-to-date!
Steam client's requirements are satisfied
WARNING: Using default/fallback debugger launch
/home/namerif/.local/share/Steam/ubuntu12_32/steam steam://run/427520//%27--disable-audio%27%20%27--disable-prototype-history%27%20%27--load-game%27%20%27%2Ftmp%2Fmapshot3663988854%2Ftest.zip%27%20%27--mod-directory%27%20%27%2Ftmp%2Fmapshot3663988854%2Fmods%27
0.000 Steam requires game restart, restarting...
I1112 16:07:01.323575 28920 factorio.go:151] Factorio returned: <nil>
I1112 16:07:01.324636 28920 root.go:37] temp dir "/tmp/mapshot3663988854" removed
Error: factorio exited early
OS: Linux Mint 20.1 Cinnamon x64
Steam installed from the official website
Sorry, didn't notice that Steam version is not supported. But still, if it's not supported only because of this issue, I want to propose a solution that I found: this "Allow game launch?" window does not appear, if you run the game this way:
/home/USER/.local/share/Steam/ubuntu12_32/steam -applaunch 427520 --disable-audio --disable-prototype-history --load-game /tmp/mapshot1126956423/test.zip --mod-directory /tmp/mapshot1126956423/mods
instead of the method that currently is used in the program:
/home/USER/.local/share/Steam/ubuntu12_32/steam steam://run/427520//%27--disable-audio%27%20%27--disable-prototype-history%27%20%27--load-game%27%20%27%2Ftmp%2Fmapshot1126956423%2Ftest.zip%27%20%27--mod-directory%27%20%27%2Ftmp%2Fmapshot1126956423%2Fmods%27
So maybe it's possible to add parameter that uses this workaround for Steam version. Anyway, thanks for this mod, it's really helpful!
Thanks for the suggestions! From what I vaguely remember, one of the issue was that things were behaving differently whether Steam was running or not, leading to a very weird experience - and I did not find a good workaround at the time. I'll dig into your suggestion, to see if we can have something automatic, which does not fail (too much) if steam itself is not running. Thanks!
I've tested a bit further, so a few notes, for the day I am motivated to add proper steam support:
- Currently, mapshot does not run the steam binary, it runs the factorio binary. However, when pointing to a steam factorio binary, that binary will itself run steam - hence leading to the command lines mentioned in comment above.
- That means there is no control over how steam is launched if using the steam factorio binary.
- So, steam factorio support would mean calling steam directly, which is possible.
- Determining the steam binary to use is tricky - e.g., on my system, this is not
.local/share/Steam/ubuntu12_32/steam
but.local/share/Steam/ubuntu12_64/steam
as far as I can tell, but both are present. And when calling the wrong ones, it starts doing updates and other thing, so, probably not a good idea to pick a random one. - Simplest here would be to use the one in the path (or manually specified of course).
Then there is the question of shutdown at the end of the render:
- When running the steam factorio binary, even exiting factorio will not stop the command - steam will still be running.
- Same story with
steam -applaunch 42752
. - Shutting down factorio at the end of the render is not that fundamental - mapshot detects the end of the rendering through a file created in the script-output, and the shutdown is just to have a nice integrated experience.
- Maybe there could be something to do to still shutdown factorio (but not steam) at the end of the render, by looking at the process list. A bit hacky, but the process hierarchy should be enough to consistently identify it.
- It is possible to shutdown the steam client (
steam -shutdown
) - but we don't know if it was running before or not, so it might be a bit unexpected. So it is likely that the steam client will stay running afterward. Not ideal.
Bottom line, I think a steam factorio support on Linux would look like this:
- Depending on the overall experience, we can either gate usage of steam version behind an explicit flag or make it automatic when possible (with still a flag to force it).
- Auto detection: identify the presence of a
steam
command and then look for factorio files to know if it is there. - Then, when running in steam mode:
- use
steam -applaunch
to run factorio, instead of calling the binary directly. - Looking up the process hierarchy to know which process to kill at the end of the render.
- Optionally, shutdown steam.
- use
The process management part would require extra logic for other systems (MacOS, Windows) which I'm not familiar with.
Also, it should be possible to use the steam version today without any special support in mapshot by creating a script containing something along the lines of:
#!/usr/bin/env bash
exec steam -applaunch 42752 "$@"
And then run mapshot with --factorio_binary
pointing to this script and probably --factorio_keep_running
. (Untested).