Godot: Directory.dir_exists() always returns False in *exported* projects

Created on 18 Feb 2019  路  6Comments  路  Source: godotengine/godot

Godot version:
Godot 3.1 Beta 5

OS/device including version:
Manjaro Linux - Kernel 4.19

Issue description:
So, I have a function that read files in a specific directory.
For save guarding, I use Directory.dir_exists(path)
This works fine when running the project in editor, however, when exporting it, dir_exists returns false, even if the directory exists. If I remove this safe guard and export, the files get loaded properly.

Steps to reproduce:

  1. Run the MRP in the editor. Everything should work, two strings are displayed.
  2. Export the project, include .txt to the exported files, since the texts are read out of TXT files.
  3. Run the exported project in terminal. It should say Loader: failed to load res://texts, return [] (dir_exists).
  4. Go back to the editor and remove
if not directory.dir_exists(path):
    print("Loader: failed to load ", path, ", return [] (dir_exists)")
    return []

from res://reader/Reader.gd

  1. Export again.
  2. Run exported project. Now it should work fine.

Minimal reproduction project:
test.zip

bug confirmed core

Most helpful comment

I found the issue, working on a proper fix.

All 6 comments

I can confirm this problem. Works in the editor, but fails in exported programs.
This is still present in Godot V3.1 stable!
This is also present under Windows 10 operating system.
Note that directory.file_exists(path) still works correctly.

Reproducible in Ubuntu 18.04, Using latest master

I found the issue, working on a proper fix.

Until the fix is included in a stable release, you can work around the issue by simply removing the "res://" prefix from your path.

I've been experiencing this bug in custom builds of mine, which were just 3.2 beta 5, and the master branch 3.2.2 + Zylann's voxel module.

@TheMisteryMan Please open a new bug report with a reproduction project, this one has been fixed so the bug you experienced might be different.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SleepProgger picture SleepProgger  路  3Comments

timoschwarzer picture timoschwarzer  路  3Comments

Spooner picture Spooner  路  3Comments

mefihl picture mefihl  路  3Comments

ducdetronquito picture ducdetronquito  路  3Comments