Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No error is reported for paths with incorrect case #70765

Closed
L2750558108 opened this issue Dec 31, 2022 · 12 comments
Closed

No error is reported for paths with incorrect case #70765

L2750558108 opened this issue Dec 31, 2022 · 12 comments

Comments

@L2750558108
Copy link

L2750558108 commented Dec 31, 2022

Godot version

3.5.1mono

System information

windows10

Issue description

See "Steps to reproduce" for details

Steps to reproduce

Create a project
Create a folder names "level" in project
Create a scene in the folder names "sce_test"
Create another scene names "sce_main"
Create a C# script names "new_script" with these code

using Godot;
using System;
public class new_script : Node
{
public override void _Ready()
{
GD.Load("res://Level/sce_test.tscn");//no mistake
}
}

Mount the "new_script" script on any node in the scene ”sce_main“
Run from the scene "sce_main" and you can see no error or warning in the console
Export it and run the exported program in CMD,and you can see error like these
image

Two problems can be seen:
1.The case path of the error is not prompted as an error or warning in the editor.In fact,there is a runtime warning when the case of the file name is wrong, like this:
image
but not when the folder name is wrongcased. I think it's better to add runtime warnings for both cases to make it easier for developers to spot such issues

2.The editor and the exprted program ran the same project but got different result.Maybe they do not use the same template when running.This can lead to debugging difficulties.I think the in-editor runtime should use the same export template as the platform the editor is on.

Minimal reproduction project

test folder.zip

The folder "Output" is exported program

@L2750558108 L2750558108 changed the title No error is reported for paths with incorrect case and inconsistent results between running with the editor and running after export in the same platform No error is reported for paths with incorrect case Dec 31, 2022
@AThousandShips
Copy link
Member

AThousandShips commented Jan 2, 2023

This looks like it's caused by the fact that paths on Windows are not case sensitive (by default) but they are in PCK files, see here

@L2750558108
Copy link
Author

Sorry, but I don't quite understand how this issue relates to the issue I raised... Could you please point it out?

@AThousandShips
Copy link
Member

I'm sorry pasted the wrong link.

@L2750558108
Copy link
Author

  1. The document says "If a developer working in a case insensitive host file system saves an asset as myfile.PNG, but then references it as myfile.png, it will work fine on their platform, but not on other platforms.", such as Linux, Android, etc. "But I'm exporting for Windows
  2. When I case the filename part in the path, I get a runtime warning telling me that the case is wrong and may not work correctly on some platforms. But when I misspell the folder name in the path, there is no hint. I think misspelling the case of a folder name should also have a runtime error like writing a miswritten filename to correct me

@AThousandShips
Copy link
Member

AThousandShips commented Jan 2, 2023

The relevant part is "This may also apply to exported binaries, which use a compressed package to store all files.", the file path is correct on Windows and should therefore not cause an error, but some kind of warning to make it clear that the path might not work in exported project makes sense, though I'm not sure how it would work, but to be clear this isn't a bug, it's how Windows works.

Also relevant is this recommendation: "One simple fool-proof convention is to only allow lowercase file and path names."

@L2750558108
Copy link
Author

But there is a runtime warning when the case of the file name is wrong, like this:
image
but not when the folder name is wrongcased. I think it's better to add runtime warnings for both cases to make it easier for developers to spot such issues

@AThousandShips
Copy link
Member

AThousandShips commented Jan 2, 2023

Oh agreed, I'm sorry I missed that distinction, as your original issue didn't point out the waring I was confused.

@L2750558108
Copy link
Author

Sorry I didn't make it clear. I've modified the initial information so that people who fix it later can better understand what I mean

@YuriSizov
Copy link
Contributor

It works in debug because Windows doesn't care about case sensitivity in file paths, by default. However, in the exported project these resources do not exist in any filesystem, they exist as a hashmap stored inside of the PCK file. So case sensitivity is respected and expected.

There isn't much we can do, I don't think, because to Windows those paths are indeed absolutely identical. We can only warn where we can that you should avoid relying on case insensitivity of Windows (or other platforms configured in this way).

@YuriSizov
Copy link
Contributor

I think we can merge this report in my own older issue: #52231.

@YuriSizov YuriSizov closed this as not planned Won't fix, can't repro, duplicate, stale Jan 3, 2023
@L2750558108
Copy link
Author

Will this (https://stackoverflow.com/questions/3644863/how-do-i-get-the-correct-case-of-a-path) helps?
Maybe it's possible to get the case-correct file path locally by going through each level of directories (although this can be cumbersome, there should at least be a solution, shouldn't there)

image
(Some of the qt functions need to be replaced)

@AThousandShips
Copy link
Member

Opened a PR for this #71975

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants