Page 1 of 1

[raiguard][1.1.57] Tutorial files are read-only copied

Posted: Sat May 07, 2022 6:00 pm
by realleif
Hi,

I checked the factorio demo on NixOS (linux) prior to buying it and immediately ran into an error when trying to play a tutorial map.
An error message popped up reading:

Code: Select all

Error while running reload_script: filesystem error: copy_file "/nix/store/8jpssm9gbl841y00160rnz27rrrqwrjs-factorio-demo-1.1.57/share/factorio/data/base/campaigns/tutorial/lualib/new-hope-util.lua" to "/home/jakob/.factorio/temp/currently-playing/new-hope-util.lua" failed: Permission denied [/nix/store/8jpssm9gbl841y00160rnz27rrrqwrjs-factorio-demo-1.1.57/share/factorio/data/base/campaigns/tutorial/lualib/new-hope-util.lua] [/home/jakob/.factorio/temp/currently-playing/new-hope-util.lua]
The problem seems to be that the NixOS store (/nix/store/) is read-only and the game does not check the permissions flags for the lua scripts when copying them.

Code: Select all

ls -la .factorio/temp/currently-playing/
drwxr-xr-x  4 jakob users    4096  7. Mai 19:40 ./
drwxr-xr-x  4 jakob users    4096  7. Mai 19:40 ../
-rw-r--r--  1 jakob users 1701817  7. Mai 19:40 blueprint.dat
drwxr-xr-x 47 jakob users    4096  7. Mai 19:40 campaign-locale/
-r--r--r--  1 jakob users   13580  7. Mai 19:40 control.lua
-rw-r--r--  1 jakob users      32  7. Mai 19:40 info.json
drwxr-xr-x 37 jakob users    4096  7. Mai 19:40 locale/
-r--r--r--  1 jakob users    1925  7. Mai 19:40 new-hope-util.lua
There exists a GitHub issue in the NixOS repository https://github.com/NixOS/nixpkgs/issues/91409.

This bash command fixes the issue, so I hope it is not difficult to fix in the game.

Code: Select all

while true; do chmod -R +rw $HOME/.factorio/temp; done
BR

Re: [1.1.57] Tutorial files are read-only copied

Posted: Sat May 07, 2022 6:32 pm
by Loewchen
Ref.: 61763

Re: [1.1.57] Tutorial files are read-only copied

Posted: Sat Jul 02, 2022 9:55 pm
by Jiehong
I confirm this still happening on 1.1.59

Re: [1.1.57] Tutorial files are read-only copied

Posted: Fri Oct 21, 2022 11:03 pm
by bratorange
Hey,

I just bought the game and cant play it because of this bug. :(

Re: [1.1.57] Tutorial files are read-only copied

Posted: Sun Jan 08, 2023 9:33 pm
by benmachine
Also having this issue on 1.1.70 :(

Re: [1.1.57] Tutorial files are read-only copied

Posted: Fri Aug 18, 2023 5:48 pm
by ogsIhdw
I have a marginally better hacky workaround. This mounts a filesystem that does not follow Unix permissions (Fat32) and uses that for the temp directory.

Remove the last three lines of code (the factorio command onwards) to make it a "one-time" thing.

Code: Select all

#!/usr/bin/env bash

set -e

FACTORIO_CONFIG="$HOME/.factorio"

AUTH_PROGRAM=sudo # Replace with pkexec if you want

img_path="$FACTORIO_CONFIG/temp.img"

if [ ! -f "$img_path" ]; then
	dd if=/dev/zero of="$img_path" bs=4M count=16
	mkfs.fat -F32 "$img_path"
fi

loop_dev=$($AUTH_PROGRAM losetup -f)

$AUTH_PROGRAM losetup $loop_dev "$img_path"

if [ -d "$FACTORIO_CONFIG/temp" ]; then
	rmdir "$FACTORIO_CONFIG/temp"
fi

mkdir "$FACTORIO_CONFIG/temp"

$AUTH_PROGRAM mount $loop_dev "$FACTORIO_CONFIG/temp" -o uid=$(id -u) -o gid=$(id -g)

factorio || true

$AUTH_PROGRAM umount $loop_dev
$AUTH_PROGRAM losetup -d $loop_dev

Re: [1.1.57] Tutorial files are read-only copied

Posted: Fri Aug 18, 2023 7:43 pm
by ogsIhdw
I still think that this should instead be fixed in Factorio: on *Nix systems, Factorio should copy, chmod, then modify the files instead of just copying and modifying.

Re: [1.1.57] Tutorial files are read-only copied

Posted: Wed Sep 20, 2023 11:04 pm
by ogsIhdw
After poking around a bit, it seems that all that is needed to implement a fix is to add the following code in "Filesystem::copy_file":

Code: Select all

std::filesystem::copy_file(from, to, options); // Already there
std::filesystem::permissions(to, std::filesystem::perms::owner_write, std::filesystem::perm_options::add); // New
// Error handling, etc

Re: [raiguard][1.1.57] Tutorial files are read-only copied

Posted: Wed Jan 03, 2024 5:24 am
by raiguard
Thanks for the report, this has been fixed for the next release.