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

OS.execute() should work the same whether run within the editor or within an exported binary #39127

Open
tx350z opened this issue May 28, 2020 · 3 comments

Comments

@tx350z
Copy link

tx350z commented May 28, 2020

Godot version:

v3.2.stable.official

OS/device including version:

Windows 8.1

Issue description:

OS.execute() has different behavior if the execute target is an exported Godot binary.

This was pointed out in issue (godotengine/godot-docs#3593) which was determined to be a documentation issue (A.K.A "a feature").

This doesn't seem to make sense, OS.execute() should behave the same whether run within the editor or within an exported binary.

I've created an ugly work-around by using a Windows .bat file which then executes the target binary.

Steps to reproduce:

  1. Unzip to a folder of your choosing.
  2. Import osexec_child project into Godot.
  3. Do a Windows export (note Embed PCK is checked). Verify ../osexec_bins/osexec_child.exe runs correctly when run from the command line.
  4. Click Project/Exit to Project List.
  5. Import osexec_parent project into Godot and run it in the editor (F5)
  6. Clicking the button launches a second instance of oexec_parent, not ../osexec_bin/osexec_child.exe
  7. Do a Windows export of osexec_parent (Embed PCK is checked)
  8. Run ../osexec_bins/osexec_parent.exe from the command line
  9. Clicking the button correctly launches osexec_child.exe

Minimal reproduction project:

osexec_oddness.zip

@akien-mga
Copy link
Member

It does work the same for any kind of binary. It's just that the Godot binary itself doesn't work the way you expect it to - or in general, binaries might not work the way you think they did.

A binary that depends on external files needs to be able to locate them, and this can be done by looking either in the binary's own folder, or the location of the caller (which is likely your project's location, or wherever the user's shell is current at).

You may see this happen if you take any of your installed games (not necessarily Godot-made), move its executable to a different folder, and then try to run that executable: it won't work. But if you cd to the game folder and try to run the executable from there, it might work as many executables look for their dependency in the current working directory (the location of the caller).

Godot uses these features in a way which you may think unconventional, but which makes sense for our use cases of having a pre-compiled binary (the export template) that gets exported without modification and should then be able to locate a data pack for the game it's meant to run. The same binary can be used to run any project if it's made for a compatible version of Godot. You can make a launcher for many different Godot games, all using the same executable (that's actually what Godot itself is).

@tx350z
Copy link
Author

tx350z commented May 29, 2020

Yes, I understand how it works. However, if I export with embedded PCK then I expect that PCK should be the default used which doesn't appear to be the case.

And once again, I want to thank all the Godot developers for the hard work. It is a great product.

@akien-mga
Copy link
Member

However, if I export with embedded PCK then I expect that PCK should be the default used which doesn't appear to be the case.

Well as @Calinou mentioned in godotengine/godot-docs#3593 (comment), this was a bug which has since been fixed in 3.2.2 beta 3. You're using 3.2, so you don't have that bugfix yet.

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