Godot 4.x Can't access some resources in the *.pck file

I have a bunch of SVG files. Most are used as images and there are no problems with them.
But one particular SVG file I read and parse as XML.
While everything is perfectly fine while I run my project through the IDE, I have problems with that file in the exported version.

var file = FileAccess.open(file_path, FileAccess.READ) returns null

I can bypass the problem by putting this SVG-XML near the project binary in the corresponding directory.

I looked into the *.pck file itself and I see that my problematic file is mentioned there. At least its name.

I have tried some shaman dancing with

const _force_pack = preload(“res://img/world_map.svg”), experimented with export_presets.cfg

What could the problem be?

Are you sure the path is correct? It should work fine. Try printing FileAccess.get_open_error() after calling FileAccess.open() like print(error_string(FileAcess.get_open_error()) to see the error.

Of course. As I said it works perfectly well while starting through the IDE.

Anyway, I’ve added that “verbose” variant of error: “File not found”

The .pck filesystem is case sensitive. For example, if your file name is World_map.svg then the path would be res://World_map.svg and not res://world_map.svg

If your filesystem is case insensitive (Windows, macOS) it will work in the editor and it will also work if you move the file to the exported project.

I use Linux. And I have checked the name/path/case/etc many times :slight_smile:

Craziness.
After an excessive amount of absolutely illogical and crazy experiments, I got a variant that works:

res://resources/word_map.xml

No, any other dir except for resources doesn’t work.
No, I can’t use *.svg extension. Any other is fine, though.

If it isn’t a bug, then I don’t know what a bug is.

I don’t know then. This:

extends Node

func _ready() -> void:
	var svg = FileAccess.open("res://icon.svg", FileAccess.READ)
	var out = [error_string(FileAccess.get_open_error())]
	out.append(svg.get_as_text())
	$TextEdit.text = "\n".join(out)

Works just fine:

I’m on Windows right now but I also tested it on Linux. I exported the project with the default Linux and Windows preset.

Did you change the Import settings of that specific svg file for any reason? The only way I can get it to fail is to change its Import As to Skip File (not exported) which… well… you can guess why it fails then :sweat_smile:

Hmm… Can you, please, try to move that *.svg in /img dir? To get res://img/whatever_name.svg path? Yes, it sounds stupid, I know, but please. All this situation sounds stupid :slight_smile:

Maybe the content of the SVG is important somehow too? Maybe the engine is trying to be cleverer than it is?

Moved it to res://img/icon.svg and changed the path when opening it in code and it still works fine (only tested on Windows)

I’m not sure. You could try to reproduce the issue in a new project using the same svg file.

If it still fails on a new project you could try opening an issue in the issue tracker giving as much info as possible and also attaching that new project.