Lost Relative Path in .pak Files

Hello,

In our project, we have several .pak files located within the project’s content folder, for example:

Packs/Expeditions/

Packs/Events/

Packs/Clans/

Each of these folders contains a PrimaryAssetLabel that is configured to include all contents of the folder into a .pak file. Each folder is assigned a unique ChunkID, so each one results in a separate .pak file.

Here are the settings for each PrimaryAssetLabel:

Priority: 1

ChunkID: (unique per folder)

ApplyRecursive: False

CookRule: Always Cook

Label Assets in My Directory: True

In Runtime Label: False

ExplicitAssets: {}

ExplicitBlueprints: {}

AssetCollection: None

We are using the standard Unreal Engine build system, with no custom packaging or asset cooking pipeline.

Previously, the resulting .pak files preserved the full relative paths (e.g., Packs/Expeditions/) for their contents. For example, an asset located at:

Packs/Expeditions/Test/1.uasset

would be extracted with the same path using UnrealPak -Extract.

However, now the .pak file omits the initial folders and starts directly with subfolders, such as:

Test/1.uasset

So the relative path Packs/Expeditions/ is missing.

We found that this behavior changes based on the following project settings:

Share Material Shader Code

Shared Material Native Libraries

When these are enabled, the .pak files contain full paths. When they are disabled, the paths become shorter and omit the top-level folders.

This affects how we locate assets inside the .pak files and causes issues during mounting or extraction.

Our Questions: How can we ensure that .pak files always contain the full relative paths (e.g., starting with Packs/Expeditions/)? Alternatively, is there a way to detect whether a .pak file contains full or shortened paths, so we can adjust the mount point accordingly during runtime? If so, how?

Thanks in advance for your help!

Steps to Reproduce

Hey Alexandr,

You are not taking into account the pak file mount point.

When creating the pak file the internal relative paths are created relative to the common root path (= mount point) of all files.

So for a list of files like this:

  • ../../../GameName/Content/Packs/Events/Event1.uasset
  • ../../../Engine/Content/GlobalShaders.ushaderbytecode (I made this one up, but I’m fairly sure with the shared code there is a shader library file in the pak that lives outside of your Content folder)

This will choose ../../../ as pak mount point and the relative paths inside the pak end up like this:

  • GameName/Content/Packs/Events/Event1.uasset
  • Engine/Content/GlobalShaders.ushaderbytecode

However, if you only have assets inside the Packs/Events folder the mount point will end up being ../../../GameName/Content/Packs/Events and the path inside the pak file will look like this:

  • Event1.uasset

In general a regular game user would not care about this, since the pak loading code takes the mount point into account and correctly loads the assets by reading the mount point from the pak file.

If you are manually extracting or loading paks with custom mount points then you need to take this into account.

May I ask what your use-case is that you need to extract those paks later on?

Usually with the default pak loading if you don’t manually specify the mount point this would all be handled automatically.

Kind Regards,

Sebastian

Glad to hear that, I’ll mark the question as resolved!

The issue was that we were manually specifying the mount point as FPaths::ProjectContentDir(). This was originally done because we also mount custom-built .pak files that include text files, and this setup worked fine — until we disabled the Share Material Shader Code option, which caused the internal structure of the .pak files to change.

It turns out that if we set the mount point to null for .pak files generated by UE, everything works correctly.

Thank you — your explanation pointed us in the right direction and helped us resolve the issue.