Page 1 of 1

Error when manually updating Factorio

Posted: Thu Nov 10, 2016 6:06 pm
by Artentus
So as some of you may know I am working on a mod manager and I am currently trying to implement an updater into it.
However, in my manual tests on how the updating thing actually works I keep getting an error and I don't know why.

What I am doing is the following:
I have a clean test installation of Factorio (directly downloaded the ZIP from the website and extracted it).
I have also an update package that I downloaded from updater.factorio.com.

I am starting the update via the command line like this:

Code: Select all

D:\Factorio-Test\Factorio_0.14.19\bin\x64>factorio.exe --apply-update "D:\Factorio-Test\core-win64-0.14.19-0.14.20-update.zip"
Where "D:\Factorio-Test\Factorio_0.14.19" is the clean installation of Factorio 0.14.19 and "D:\Factorio-Test\core-win64-0.14.19-0.14.20-update.zip" is the update package (from 0.14.19 to 0.14.20).


The problem now is, that this does not work. The updater will start but after a while I just get an error.
Here is the complete console output:

Code: Select all

D:\Factorio-Test\Factorio_0.14.19\bin\x64>   0.000 2016-11-10 18:43:57; Factorio 0.14.19 (build 25291, win64, alpha)
   0.000 Operating system: Windows 10 (version 1607)
   0.000 Not rotating logs.
   0.000 Program arguments: "factorio.exe" "--apply-update" "D:\Factorio-Test\core-win64-0.14.19-0.14.20-update.zip"
   0.000 Read data path: D:/Factorio-Test/Factorio_0.14.19/data
   0.000 Write data path: D:/Factorio-Test/Factorio_0.14.19
   0.000 Binaries path: D:/Factorio-Test/Factorio_0.14.19/bin
   0.010 System info: [CPU: Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz, 8 cores, RAM: 32680MB]
   0.010 Running in headless mode
   0.012 Loading mod core 0.0.0 (data.lua)
   0.016 Loading mod base 0.14.19 (data.lua)
   0.086 Checksum for core: 1291735968
   0.086 Checksum for mod base: 786624017
   0.334 Info PlayerData.cpp:57: Local player-data.json unavailable
   0.334 Info PlayerData.cpp:62: Cloud player-data.json unavailable
   0.337 Custom inputs active: 0
   0.348 Factorio initialised
   1.009 Goodbye
Regards from the updater slave
   0.000 2016-11-10 18:43:58; Factorio 0.14.19 (build 25291, win64, alpha)
   0.000 Operating system: Windows 10 (version 1607)
   0.000 Not rotating logs.
   0.001 Info Updater-win32.cpp:130: Starting updater
   0.001 Info Updater.cpp:388: Applying update D:\Factorio-Test\core-win64-0.14.19-0.14.20-update.zip
   4.163 Info Updater-win32.cpp:141: Starting updated game
   4.284 Goodbye
   0.000 2016-11-10 18:44:02; Factorio 0.14.20 (build 25315, win64, alpha)
   0.001 Operating system: Windows 10 (version 1607)
   0.001 Program arguments: "D:\Factorio-Test\Factorio_0.14.19\bin\x64\factorio.exe" "--apply-update" "D:\Factorio-Test\core-win64-0.14.19-0.14.20-update.zip" "D:\Factorio-Test\Factorio_0.14.19\temp\instructions.json" "--autoupdate-finished" "--wait-to-close" "2208"
   0.002 Read data path: D:/Factorio-Test/Factorio_0.14.19/data
   0.002 Write data path: D:/Factorio-Test/Factorio_0.14.19
   0.002 Binaries path: D:/Factorio-Test/Factorio_0.14.19/bin
   0.012 System info: [CPU: Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz, 8 cores, RAM: 32680MB]
   0.012 Running in headless mode
   0.015 Loading mod core 0.0.0 (data.lua)
   0.018 Loading mod base 0.14.20 (data.lua)
   0.089 Checksum for core: 1291735968
   0.089 Checksum for mod base: 786624017
   0.318 Info PlayerData.cpp:55: Local player-data.json available, timestamp 1478799838
   0.319 Info PlayerData.cpp:62: Cloud player-data.json unavailable
   0.322 Custom inputs active: 0
   0.324 Factorio initialised
   0.325 Error Util.cpp:57: copy_file(p1, p2, options): invalid arguments: operation not permitted
Note that I have tried running the command as administrator but the result is exactly the same.

The game still appears to be updated if I restart it manually after that, but I can't have any error messages when automating this process.
I would be glad if anyone could point me into the rights direction.

Re: Error when manually updating Factorio

Posted: Thu Nov 10, 2016 6:28 pm
by posila
Does your application open some files in Factorio folder which might prevent Factorio to overwrite them?

Re: Error when manually updating Factorio

Posted: Thu Nov 10, 2016 7:12 pm
by Artentus
As I said this is a test installation so it is completely untouched, my application is not running. It's just the extracted ZIP archive from the official download site.

Sadly the error does not print out what specific file caused it. However, I did notice that the 'temp' folder does still contain the files "factorio.exe" (it's the old one), "factorio.pdb" (I guess also the old one but I cant really check) and "instructions.json".
Based on this and the console output my guess is that the update gets applied correctly but the temp-folder does not get cleaned up.

Re: Error when manually updating Factorio

Posted: Fri Nov 11, 2016 1:41 pm
by Artentus
I have now also tried it with Factorio version 0.13.20 (update package to 0.14.5) and it worked without problem.
I guess this means the error is related to the newest experimental.

Re: Error when manually updating Factorio

Posted: Fri Nov 11, 2016 2:41 pm
by posila
You are right. The bug was caused by fix in 0.14.6 ( 32412 ). It passes --apply-update parameter on restart, which makes it run update again, but this time it can't overwrite Factorio.exe in temp, because it is being currently executed.

Fixed for next release (might not be 0.14.21)

Re: Error when manually updating Factorio

Posted: Fri Nov 11, 2016 2:48 pm
by Artentus
So this is actually a bug, good to know.

Problem is that this will prevent updating from older versions. You should probably add a package that updates directly from 0.14.5 to 0.14.21 so this bug can be circumvented.

Re: Error when manually updating Factorio

Posted: Fri Nov 11, 2016 2:54 pm
by posila
--apply-update is only used when we change updater and we need to test it, in-game autoupdater doesn't use it (that is why it is broken in almost all 0.14 versions)

As a workaround you can do the first stage yourself:
Copy factorio.exe to <write-data-path>\temp\
Create instructions.json (example below) also in temp
Execute temp\factorio.exe --autoupdate-stage2 <full-path-to-instructions.json>

Example of instructions.json

Code: Select all

{
    "path": {
        "executable": "d:\\Factorio-Test\\Factorio_0.14.19\\bin\\x64\\factorio.exe",
        "read-data": "d:\\Factorio-Test\\Factorio_0.14.19\\data",
        "log": "d:\\Factorio-Test\\Factorio_0.14.19"
    },
    "updates": [
        {
            "file": "d:\\Factorio-Test\\core-win64-0.14.19-0.14.20-update.zip"
        }
    ]
}

Re: Error when manually updating Factorio

Posted: Fri Nov 11, 2016 2:58 pm
by Artentus
Thanks, I will try that.

Re: Error when manually updating Factorio

Posted: Fri Nov 11, 2016 3:10 pm
by posila
Alternative workaround: run it like following

Code: Select all

factorio.exe --wait-to-close=0 --apply-update <path-to-update.zip>
that will work because --wait-to-close and the following thing is removed when the application restarts, so that will eat --apply-update. Path to zip will stay there, but that won't cause any problems.

Re: Error when manually updating Factorio

Posted: Fri Nov 11, 2016 3:33 pm
by Artentus
Just tested it and it works perfectly, thank you very much.