File Naming option grayed out

Hi! I’m using the Flatpak/Flathub version of Picard and the File Naming options are suddenly grayed out. It worked well earlier today. Clues?

This would happen if there is an error loading the page, which would indicate a bug. Can you check the output in Help > View Error/Debug Log after you have opened the options and paste the output here?

1 Like

Thanks @outsidecontext! I tried to use /run/user/1000/doc/18960a00/. Perhaps this caused the error.

E: 20:02:52,724 ui/options/dialog.load_all_pages:203: Failed loading options page <picard.ui.options.renaming.RenamingOptionsPage object at 0x7f3239690670>
Traceback (most recent call last):
  File "/app/lib/python3.11/site-packages/picard/util/filenaming.py", line 326, in _get_filename_limit
    limit = limits[target]
            ~~~~~~^^^^^^^^
KeyError: '/run/user/1000/doc/18960a00/v10_picard'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/app/lib/python3.11/site-packages/picard/ui/options/dialog.py", line 201, in load_all_pages
    page.load()
  File "/app/lib/python3.11/site-packages/picard/ui/options/renaming.py", line 246, in load
    self.update_selector_from_settings()
  File "/app/lib/python3.11/site-packages/picard/ui/options/renaming.py", line 142, in update_selector_from_settings
    self.update_selector_in_editor()
  File "/app/lib/python3.11/site-packages/picard/ui/options/renaming.py", line 154, in update_selector_in_editor
    self.examples.update_examples(script_text=self.script_text)
  File "/app/lib/python3.11/site-packages/picard/ui/scripteditor.py", line 142, in update_examples
    self.update_sample_example_files()
  File "/app/lib/python3.11/site-packages/picard/ui/scripteditor.py", line 126, in update_sample_example_files
    self.update_examples()
  File "/app/lib/python3.11/site-packages/picard/ui/scripteditor.py", line 143, in update_examples
    self.example_list = [self._example_to_filename(example) for example in self._sampled_example_files]
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/lib/python3.11/site-packages/picard/ui/scripteditor.py", line 143, in <listcomp>
    self.example_list = [self._example_to_filename(example) for example in self._sampled_example_files]
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/lib/python3.11/site-packages/picard/ui/scripteditor.py", line 168, in _example_to_filename
    filename_after = file.make_filename(filename_before, c_metadata, self.settings, self.script_text)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/lib/python3.11/site-packages/picard/file.py", line 550, in make_filename
    new_filename = self._format_filename(new_dirname, new_filename, metadata, settings, naming_format)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/lib/python3.11/site-packages/picard/file.py", line 530, in _format_filename
    new_filename = make_short_filename(new_dirname, new_filename, win_shorten_path=win_shorten_path)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/lib/python3.11/site-packages/picard/util/filenaming.py", line 399, in make_short_filename
    limit = _get_filename_limit(basedir)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/lib/python3.11/site-packages/picard/util/filenaming.py", line 334, in _get_filename_limit
    limit = os.statvfs(d).f_namemax
            ^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/run/user/1000/doc/18960a00'
1 Like

Thanks for the details. The dialog shouldn’t fail just because the configured path is unavailable or unaccessible, this needs to be fixed.

A workaround in your case can be to edit the Picard.ini config file manually and reset the path to some other location.

1 Like

It seems it did. Changing the paths in the .ini file (to a directory that actually exists) made the File Naming options available again. Thanks!

2 Likes

I debugged this a bit and added a ticket to track the issue:

The error happens when trying to determine filesystem path limits for the selected path for the rendering of the examples. Generally this can also lead to Picard crashing in some circumstances.

How this lead to a FileNotFoundError in your specific case is a bit curious, as the code actually checks for existing paths. But in my case there is definitely a PermissionError when trying to get filesystem stats for /run/user/1000/doc.

I need to think a bit on how to best solve this.

1 Like

Thanks for working on it! :slight_smile: Not a problem for me anymore, but perhaps confusing to users who have not come across this thread.