Ren'Py All Renpy games have error when saving.

rsnaticz

New Member
Nov 9, 2021
5
0
Code:
I'm sorry, but an uncaught exception occurred.

While running game code:
  File "renpy/common/00action_file.rpy", line 382, in __call__
    renpy.save(fn, extra_info=save_name)
ValueError: (22, 'Invalid argument')

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "renpy/common/_layout/screen_load_save.rpym", line 35, in script
    $ ui.interact()
  File "renpy/ast.py", line 923, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "renpy/python.py", line 2235, in py_exec_bytecode
    exec(bytecode, globals, locals)
  File "renpy/common/_layout/screen_load_save.rpym", line 35, in <module>
    $ ui.interact()
  File "renpy/ui.py", line 298, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "renpy/display/core.py", line 3276, in interact
    repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, pause=pause, pause_start=pause_start, **kwargs)
  File "renpy/display/core.py", line 4110, in interact_core
    rv = root_widget.event(ev, x, y, 0)
  File "renpy/display/layout.py", line 1090, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "renpy/display/layout.py", line 1090, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "renpy/display/layout.py", line 1090, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "renpy/display/screen.py", line 720, in event
    rv = self.child.event(ev, x, y, st)
  File "renpy/display/layout.py", line 1090, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "renpy/display/layout.py", line 1297, in event
    rv = super(Window, self).event(ev, x, y, st)
  File "renpy/display/layout.py", line 273, in event
    rv = d.event(ev, x - xo, y - yo, st)
  File "renpy/display/layout.py", line 1090, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "renpy/display/layout.py", line 1297, in event
    rv = super(Window, self).event(ev, x, y, st)
  File "renpy/display/layout.py", line 273, in event
    rv = d.event(ev, x - xo, y - yo, st)
  File "renpy/display/layout.py", line 1090, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "renpy/display/layout.py", line 273, in event
    rv = d.event(ev, x - xo, y - yo, st)
  File "renpy/display/behavior.py", line 979, in event
    return handle_click(self.clicked)
  File "renpy/display/behavior.py", line 914, in handle_click
    rv = run(action)
  File "renpy/display/behavior.py", line 329, in run
    return action(*args, **kwargs)
  File "renpy/common/00action_file.rpy", line 382, in __call__
    renpy.save(fn, extra_info=save_name)
  File "renpy/loadsave.py", line 435, in save
    location.save(slotname, sr)
  File "renpy/savelocation.py", line 420, in save
    l.save(slotname, record)
  File "renpy/savelocation.py", line 159, in save
    record.write_file(filename)
  File "renpy/loadsave.py", line 354, in write_file
    zf.writestr("screenshot.png", self.screenshot)
  File "/home/tom/ab/renpy-build/tmp/install.linux-x86_64/lib/python2.7/zipfile.py", line 1237, in writestr
ValueError: (22, 'Invalid argument')
 
Last edited:

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Respected User
Donor
Jun 10, 2017
10,279
15,119
All renpy games I play wont let me save, keeps getting errors. anyone can help?
Perhaps, perhaps not.

How do you want someone to be able to help you with so few information ? You could at least tell us what error you get. There's a "traceback.txt" file in the root directory of the game (where you click to launch the game), without it you'll not get help because I doubt than one of us have a divination capacity.
 
  • Like
Reactions: rsnaticz

rsnaticz

New Member
Nov 9, 2021
5
0
Perhaps, perhaps not.

How do you want someone to be able to help you with so few information ? You could at least tell us what error you get. There's a "traceback.txt" file in the root directory of the game (where you click to launch the game), without it you'll not get help because I doubt than one of us have a divination capacity.

Im sorry, i did not notice, I was preoccupied figuring things out that I forgot to paste the code from traceback.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Respected User
Donor
Jun 10, 2017
10,279
15,119
Code:
  File "/home/tom/ab/renpy-build/tmp/install.linux-x86_64/lib/python2.7/zipfile.py", line 1237, in writestr
ValueError: (22, 'Invalid argument')
Hmm... It's the second time I see this error with Ren'Py, but the first one was with the built of the distribution.

So, Ren'Py is putting the save data into a Zip archive, and the error you are getting is that... well, the Zip archive is not a valid Zip archive .

What is strange, because the error happen here:
Code:
        with zipfile.ZipFile(filename_new, "w", zipfile.ZIP_DEFLATED) as zf:
            # Screenshot.
            if self.screenshot is not None:
                zf.writestr("screenshot.png", self.screenshot)
What in human language mean that it happen right after the creation of the Zip archive, when Ren'Py try to store the very first file inside it ; suddenly the Zip Archive isn't a Zip archive anymore :/

It's like, you go to a bicycle store, buy a bicycle, then you want to ride it but are told that you can't use your motorcycle here.

What is more strange, is that you're only the second one to ask about this kind of error, and the first one for who it regard the save files.
I mean, it's the save files, therefore we can assume that between the moment you started this thread and now, dozens of thousands persons around the world have made, at least once, a save file with a game made with Ren'py, this just counting the members of this forum. Therefore, if it was purely a Ren'Py issue, you shouldn't be the only one to talk about it.

Do you encounter other problems, with other software, when you're writing something on your hard drive ? With this user account (the Linux one, of course, not the forum one) ?
And also, because it's perhaps the cause, are the rights for the "[path to the game]/game/save" directory correct ? Same for the "~/.renpy" directory where the save files are duplicated ? You should be the owner of those directories and have the right to write inside.
 
  • Like
Reactions: rsnaticz

Tanzie

Member
Mar 10, 2019
254
455
Wrong Python version perhaps? As it returns a ValueError instead of a RuntimeError.

Python 2.x:
Python:
ZipFile.writestr(zinfo_or_arcname, data[, compress_type])
The archive must be opened with mode 'w', 'x' or 'a' – calling on a ZipFile created with mode 'r' will raise a . Calling on a closed ZipFile will raise a .

Python 3.x:
Python:
ZipFile.writestr(zinfo_or_arcname, data, compress_type=None, compresslevel=None)
Changed in version 3.6: Calling on a ZipFile created with mode 'r' or a closed ZipFile will raise a . Previously, a was raised.

ValueError suggests that one of the parameters passed to writestr function is either inappropriate or missing. If it was unable to create a file or the file was read-only due to permissions or file system issues it would most likely raise a RuntimeError instead of a ValueError with Python 2.x. With Python 3, however, if there's some file system or permission issue it would return a ValueError, which is what made me think that it could be a Python version issue.

To put it simply, you may be running this game using Python 3 for some reason (most likey the version installed on your system) whereas the game wants to use Python 2.7 and in addition to that you may have some permission issues on the directory you want to save your games into (missing "write" permission), as well as potentially on the directory where the Python executables are located (such as a missing "execute" permission?).

I don't use Linux myself, or program in Python, so take this with a grain of salt.
 
Last edited:
  • Like
Reactions: rsnaticz

rsnaticz

New Member
Nov 9, 2021
5
0
Do you encounter other problems, with other software, when you're writing something on your hard drive ? With this user account (the Linux one, of course, not the forum one) ?
And also, because it's perhaps the cause, are the rights for the "[path to the game]/game/save" directory correct ? Same for the "~/.renpy" directory where the save files are duplicated ? You should be the owner of those directories and have the right to write inside.

I don't encounter this on other software, only renpy games, In terms of rights to the directory, I changed it to full control already and my account is the administrator. this is so weird.
 

rsnaticz

New Member
Nov 9, 2021
5
0
Wrong Python version perhaps? As it returns a ValueError instead of a RuntimeError.

Python 2.x:
Python:
ZipFile.writestr(zinfo_or_arcname, data[, compress_type])


Python 3.x:
Python:
ZipFile.writestr(zinfo_or_arcname, data, compress_type=None, compresslevel=None)


ValueError suggests that one of the parameters passed to writestr function is either inappropriate or missing. If it was unable to create a file or the file was read-only due to permissions or file system issues it would most likely raise a RuntimeError instead of a ValueError with Python 2.x. With Python 3, however, if there's some file system or permission issue it would return a ValueError, which is what made me think that it could be a Python version issue.

To put it simply, you may be running this game using Python 3 for some reason (most likey the version installed on your system) whereas the game wants to use Python 2.7 and in addition to that you may have some permission issues on the directory you want to save your games into (missing "write" permission), as well as potentially on the directory where the Python executables are located (such as a missing "execute" permission?).

I don't use Linux myself, or program in Python, so take this with a grain of salt.
I don't even have python installed on my machine. same as other PC I use before when playing renpy games. In terms of permission, I did changed the whole directory to full control. I don't know if there are other permission to configure.
 

Tanzie

Member
Mar 10, 2019
254
455
I don't even have python installed on my machine. same as other PC I use before when playing renpy games. In terms of permission, I did changed the whole directory to full control. I don't know if there are other permission to configure.
If you believe you have installed the game correctly, in other words, the directory structure is correct, then you probably need to be the owner of the "save" directories and have the "write" permission on them, and also need to have "execute" permission on the <gamename>.sh, as well as python, pythonw and <gamename> files inside the "linux-x86_64" directory. Other than that I don't have anything else to suggest.

I don't even have python installed on my machine.
As far as I'm aware Python comes preinstalled in some distributions (e.g. Ubuntu), you don't have to install it yourself. When you type it on the command line does python --version return anything? If, for some reason (e.g. incorrect directory structure, permissions), the game is unable to run the python executable inside the lib folder, it may be using the one installed on your system as a fallback (e.g. Python 3).
 
Last edited:

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Respected User
Donor
Jun 10, 2017
10,279
15,119
Wrong Python version perhaps?
Even on Linux, Ren'Py works with the interpreter embedded with the distribution. Therefore I really doubt that the version is wrong.


As it returns a ValueError instead of a RuntimeError.
As the documentation say, this regard an attempt to write on a archive opened in a "read only" mode. It previously returned a RuntimeError (as in "it can not works this way"), and have been changed to return a ValueError (as in "you used a wrong value when opening the archive).
But here it's a ValueError that is expected, since it's the value of the archive that have the wrong format.


I don't encounter this on other software, only renpy games, In terms of rights to the directory, I changed it to full control already and my account is the administrator. this is so weird.
I was almost sure that it would be your answer, but I wanted to be sure, just in case. And yes, it's weird, totally weird.


If you believe you have installed the game correctly, in other words, the directory structure is correct, then you probably need to be the owner of the "save" directories and have the "write" permission on them,
What he said, right before your answer, he is.


and also need to have "execute" permission on the <gamename>.sh, as well as python, pythonw and <gamename> files inside the "linux-x86_64" directory.
What he have, else he wouldn't even come in position to save, since the game wouldn't have been launched.



If, for some reason (e.g. incorrect directory structure, permissions), the game is unable to run the python executable inside the lib folder, it may be using the one installed on your system as a fallback (e.g. Python 3).
What isn't the case, else once again he wouldn't be in position to save, here again because the game wouldn't have been launched. Python 2.x and Python 3.x have enough incompatibility for Ren'Py to not be able to works correctly with a Python 3.x interpreter.
 

rsnaticz

New Member
Nov 9, 2021
5
0
Thanks so much guys, even though its not solved yet, I appreciate you all taking time. anyway, I think I'm gonna play on other PC for now, until I find solution to the problem.