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

This subforum contains all the issues which we already resolved.
realleif
Manual Inserter
Manual Inserter
Posts: 1
Joined: Sat May 07, 2022 5:21 pm
Contact:

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

Post 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
Attachments
factorio-current.log
(5.59 KiB) Downloaded 136 times
Jiehong
Burner Inserter
Burner Inserter
Posts: 5
Joined: Fri Jan 05, 2018 7:55 pm
Contact:

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

Post by Jiehong »

I confirm this still happening on 1.1.59
bratorange
Manual Inserter
Manual Inserter
Posts: 1
Joined: Fri Oct 21, 2022 10:58 pm
Contact:

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

Post by bratorange »

Hey,

I just bought the game and cant play it because of this bug. :(
benmachine
Manual Inserter
Manual Inserter
Posts: 3
Joined: Sun Jan 08, 2023 9:19 pm
Contact:

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

Post by benmachine »

Also having this issue on 1.1.70 :(
ogsIhdw
Manual Inserter
Manual Inserter
Posts: 4
Joined: Fri Aug 18, 2023 5:18 pm

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

Post 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
ogsIhdw
Manual Inserter
Manual Inserter
Posts: 4
Joined: Fri Aug 18, 2023 5:18 pm

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

Post 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.
ogsIhdw
Manual Inserter
Manual Inserter
Posts: 4
Joined: Fri Aug 18, 2023 5:18 pm

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

Post 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
User avatar
raiguard
Factorio Staff
Factorio Staff
Posts: 607
Joined: Wed Dec 13, 2017 8:29 pm
Contact:

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

Post by raiguard »

Thanks for the report, this has been fixed for the next release.
Don't forget, you're here forever.
Post Reply

Return to “Resolved Problems and Bugs”