Godot: CLI export fails

Created on 23 Feb 2018  路  44Comments  路  Source: godotengine/godot

Godot version:

Godot 3.0 stable

OS/device including version:

Linux Mint 18.3 Sylvia 64-bit

Issue description:

Trying to export via command line throws following error:

ERROR: copy: Condition ' err ' is true. returned: err
   At: core/os/dir_access.cpp:313.

Steps to reproduce:
Just create a bare minimum project, I used one just with a single node in a scene, nothing else.
Try to export via command line.

bug editor

Most helpful comment

I'll rework the mess that is our command line interface eventually.

All 44 comments

Confirmed. The error happens when the target file already exists. Here's what I tried :

$ godot --export nanogodo_linux64 /tmp/nanogodo/build/nanogodo_linux64

Exporting only works when

  • the first parameter is a valid target name
  • the target file does not exist, and
  • the directory containing the target file does

It's not a bug per se, it's a lack of documentation.

The error occurs even when no target file exists. And the target file never gets generated from command line. So it is a valid bug.

I confirmed with 3.0.2 stable release:

godot --export "Linux/X11" /tmp
ERROR: copy: Condition 'err ' is true. returned: err
  At: core/os/dir_access.cpp:305

I also confirmed that it exports fine from GUI editor menu.

You're right, I can't export at all using CLI with the latest master. It works with Godot 3.0 and 3.1 though.

I tested with both Godot 3.0 and 3.0.2 they both fail. I haven't tested master, and I don't see 3.1 being released yet.

I guess I'll try master if you meant it was fixed in latest master. I uncommented the printf statement and it shows that it's trying to copy the templates/linux_x11_64_debug to the output directory. They both exist and have proper permissions.

Ok, that was it. The output path is not supposed be a directory, but a filename. I guess the documentation wasn't updated after all.

Not a bug. It's working if I provide an output filename.

I don't see 3.1 being released yet

I mixed up the versions, my bad. I meant 3.0.1. I can export using CLI in 3.0.1 (I just did again), but not using master, with the exact same project and the exact same command.

Thank you for the solution.

Hello, I have this exact problem, and I specified a filename, not a directory as argument Check #17977 (I closed it as it is related to this bug report).
I just rechecked, toto does not exist, so as you commented, it should have been working/ :

$ ../../godot-server --export "Linux/X11" /tmp/toto
ERROR: initialize: AudioDriverManager: all drivers failed, falling back to dummy driver
   At: servers/audio_server.cpp:153.
ERROR: copy: Condition ' err ' is true. returned: err
   At: core/os/dir_access.cpp:305.

One difference is that I use the server version, not the GUI version which works fine (even for exporting).
Can we reopen this ticket?

@lstep when you say that the GUI version works fine, you mean exporting from the interface right?
Have you tried exporting through the command line, using the "normal" version of Godot? That should fail too, if not, please report back.

As I wrote in #17977 I don't think this is related to the server version, as I can reproduce the error not using the server version.

I confirm, using the command line options from the "normal" version of Godot also fails:

~/Apps/GODOT/3.0/PRJS/vide:
$ ../../Godot_v3.0.2-stable_x11.64 --export "Linux/X11" /tmp/toto
OpenGL ES 3.0 Renderer: GeForce GTX 1050/PCIe/SSE2
ERROR: copy: Condition ' err ' is true. returned: err
   At: core/os/dir_access.cpp:305.

And just to be sure, there is no /tmp/foo file :

 ls -al /tmp/foo
ls: cannot access '/tmp/foo': No such file or directory

So the only way to export is to go through the GUI interface to export.

$ ../../Godot_v3.0.2-stable_x11.64 --export "Linux/X11" /tmp/toto

It's "Linux X11"

@akien-mga actually "Linux/X11" is now the name when you add a new Linux export preset.
Before 3.x it was "Linux X11" indeed though.

But other than that, it is also possible to rename it now, so it could be anything.

Ah thanks for the clarification :)

Still reproduceable at b4c6509

Tested in 3.0.6

--export --path /path/to/Project/test_project "Linux/X11" /path/to/export/project_folder/name_of_game

^ This works as long as the destination path exists.
Let's say the folder "project_folder" doesn't exist already, it throws the error

ERROR: copy: Condition ' err ' is true. returned: err
   At: core/os/dir_access.cpp:305.

I get a different error here (Linux DirAccess), if the destination folder is missing.

3.0.6:

$ godot-3.0 --export --path ~/tmp/godot/test/v3.0_test/ "Linux/X11" ~/test/game
OpenGL ES 3.0 Renderer: GeForce GTX 670MX/PCIe/SSE2
ERROR: copy: Failed to open /home/akien/test/game
   At: core/os/dir_access.cpp:313.
ERROR: _fs_changed: Project export failed with error code 12.
   At: editor/editor_node.cpp:471.

master:

$ godot-git --export --path ~/tmp/godot/test/v3.1_test/ "Linux/X11" ~/test/game
OpenGL ES 3.0 Renderer: GeForce GTX 670MX/PCIe/SSE2
ERROR: copy: Failed to open 
   At: core/os/dir_access.cpp:304.
ERROR: _fs_changed: Project export failed with error code 12.
   At: editor/editor_node.cpp:507.
WARNING: cleanup: ObjectDB Instances still exist!
   At: core/object.cpp:2053.

If it's present, 3.0.6 works fine, and master still fails with this "Failed to open \

BTW I'm surprised it even works, the preset name should come right after --export.

On 3.0.6 I'm not able to get it to working, even with the strange order of args you provide above

root@9da3a3680c0e:~/project# godot --export --path $(pwd)/game/ "web" $(pwd)/server/dist/public/

Yields the error:
ERROR: initialize: AudioDriverManager: all drivers failed, falling back to dummy driver At: servers/audio_server.cpp:165. ERROR: _load: Method/Function Failed, returning: RES() At: core/io/resource_loader.cpp:186. ERROR: start: Condition ' !scene ' is true. returned: false At: main/main.cpp:1688. WARNING: cleanup: ObjectDB Instances still exist! At: core/object.cpp:1989.

Because it tries to load res://web

This export preset works fine locally on Windows both with GUI and CLI export.

As I mentioned in https://github.com/godotengine/godot/issues/16949#issuecomment-413271796, the preset name should come right after --export, so it should be:

godot --export "web" --path $(pwd)/game/ $(pwd)/server/dist/public/

That does not work either:

root@9c1411505f27:~/project# godot -v --export "web" --path $(pwd)/game/ $(pwd)/server/dist/public/
ERROR: initialize: AudioDriverManager: all drivers failed, falling back to dummy driver
   At: servers/audio_server.cpp:165.
CORE API HASH: 0
EDITOR API HASH: 0
load resource: res://web
ERROR: _load: Method/Function Failed, returning: RES()
   At: core/io/resource_loader.cpp:186.
ERROR: start: Condition ' !scene ' is true. returned: false
   At: main/main.cpp:1688.
WARNING: cleanup: ObjectDB Instances still exist!
   At: core/object.cpp:1989.

Seems like you have to give the binary name you want:

godot --export <preset name> /export/folder/binary_name

This is a HTML5 export, so the result should be 5 files. So if giving the binary name similar to the GUI export, where one would give the name "index" and the all the files would be index.js, index.pck etc, then this command would make sense:

root@acd0e0b415bb:~/project#  godot -v --export "web" --path $(pwd)/game/ $(pwd)/server/dist/public/index
ERROR: initialize: AudioDriverManager: all drivers failed, falling back to dummy driver
   At: servers/audio_server.cpp:165.
CORE API HASH: 0
EDITOR API HASH: 0
load resource: res://web
ERROR: _load: Method/Function Failed, returning: RES()
   At: core/io/resource_loader.cpp:186.
ERROR: start: Condition ' !scene ' is true. returned: false
   At: main/main.cpp:1688.
WARNING: cleanup: ObjectDB Instances still exist!
   At: core/object.cpp:1989.

But it still does not work.

For HTML5 export, the file name extension is .html.

On 2018-08-26 17:34, Karl wrote:

This is a HTML5 export, so the result should be 5 files. So if giving
the binary name similar to the GUI export, where one would give the
name "index" and the all the files would be index.js, index.pck etc,
then this command would make sense:

Again, this does not work.

root@6cb7dcae9368:~/project#  godot -v --export "web" --path $(pwd)/game/ $(pwd)/server/dist/public/index.html
ERROR: initialize: AudioDriverManager: all drivers failed, falling back to dummy driver
   At: servers/audio_server.cpp:165.
CORE API HASH: 0
EDITOR API HASH: 0
load resource: res://web
ERROR: _load: Method/Function Failed, returning: RES()
   At: core/io/resource_loader.cpp:186.
ERROR: start: Condition ' !scene ' is true. returned: false
   At: main/main.cpp:1688.
WARNING: cleanup: ObjectDB Instances still exist!
   At: core/object.cpp:1989.

Works for me (3.0.6 editor binary on Linux):

$ ls minimal -l
total 48
-rw-r--r-- 1 akien akien 2609 ao没t  26 17:05 default_env.tres
drwxr-xr-x 2 akien akien 4096 ao没t  27 09:20 export/
-rw-r--r-- 1 akien akien  952 ao没t  27 09:20 export_presets.cfg
-rw-r--r-- 1 akien akien 3498 ao没t  26 16:42 icon.png
-rw-r--r-- 1 akien akien  615 ao没t  26 16:44 icon.png.import
-rw-r--r-- 1 akien akien  320 ao没t  26 16:42 Main.gd
-rw-r--r-- 1 akien akien  818 ao没t  26 17:05 Main.tscn
-rw-r--r-- 1 akien akien  512 ao没t  26 16:42 Player.gd
-rw-r--r-- 1 akien akien  697 ao没t  26 16:48 Player.tscn
-rw-r--r-- 1 akien akien  409 ao没t  26 17:24 project.godot
-rw-r--r-- 1 akien akien  427 ao没t  26 17:05 Trigger.gd
-rw-r--r-- 1 akien akien  967 ao没t  26 16:48 Trigger.tscn
$ ls minimal/export -l
total 0
$ godot3 --export "web" --path $(pwd)/minimal/ $(pwd)/minimal/export/index.html
OpenGL ES 3.0 Renderer: GeForce GTX 670MX/PCIe/SSE2
exporting res://Main.tscn
exporting res://Player.tscn
exporting res://Trigger.tscn
exporting res://default_env.tres
$ ls minimal/export -l
total 11504
-rw-r--r-- 1 akien akien    10156 ao没t  27 09:22 index.html
-rw-r--r-- 1 akien akien   339750 ao没t  27 09:22 index.js
-rw-r--r-- 1 akien akien    16276 ao没t  27 09:22 index.pck
-rw-r--r-- 1 akien akien    21430 ao没t  27 09:22 index.png
-rw-r--r-- 1 akien akien 11386156 ao没t  27 09:22 index.wasm

What Godot binary are you using? Do you have a preset named "web"? Does the $(pwd)/server/dist/public folder exist and is writable?

This is the godot-server binary, 3.0.6. "web" is a preset that works fine
on GUI exports locally. The output folder exists and has correct
permissions.

You need to use the "headless" binary, the "server" one has no editor tools (see #19683). The server binary should not have --export in its godot --help a priori.

(Of course the terrible error reporting needs to be improved, but that's another topic.)

Aha. I'll update my Docker image with headless and report back.

Is the difference between server and headless a new change?

@karl-run yes, we previously didn't really have a 'server' binary. The 'server' release used to be just a headless editor, not an export template (so it was slower). 'Headless' is now properly a headless 'editor' build whereas 'server' is actually useful to use as a game server.

See the 3.0.6 release announcement for more details.

Some definite progress by using headless instead of server.

However:

root@3354872e9556:~/project# godot --path $(pwd)/game --export "web" $(pwd)/server/dist/public/index.html
ERROR: initialize: AudioDriverManager: all drivers failed, falling back to dummy driver
At: servers/audio_server.cpp:165.
exporting res://snip.tscn
export output snipped
ERROR: _fs_changed: Project export failed with error code 7.
At: editor/editor_node.cpp:471.
ERROR: ~List: Condition ' _first != __null ' is true.
At: core/self_list.h:100.
ERROR: cleanup: There are still MemoryPool allocs in use at exit!

The contents of the output folder:

root@3354872e9556:~/project# ls  $(pwd)/server/dist/public/
index.pck

@karl-run I am getting the same error code, error code 7. Did you had any luck solving that issue? I am using a dockerfile image from this repo.

@juanbrena

No sorry, I'm still stuck on this one.

I confirm I'm getting Error 12 with headless 3.0.6 when exporting Mac OS version and Error 7 when exporting Window version.

Ok, I resolved this.
The templates path should be as mentioned here:
https://github.com/godotengine/godot-docs/issues/1247

@akien-mga, @hpvb what should we do with this?

I'll rework the mess that is our command line interface eventually.

I'm getting the exact same error, and error code as @karl-run

ERROR: initialize: AudioDriverManager: all drivers failed, falling back to dummy driver
At: servers/audio_server.cpp:165.
exporting res://snip.tscn
...
ERROR: _fs_changed: Project export failed with error code 7.
At: editor/editor_node.cpp:471.
ERROR: ~List: Condition ' _first != __null ' is true.
At: core/self_list.h:100.
ERROR: cleanup: There are still MemoryPool allocs in use at exit!

when attempting to HTML5 export via the headless linux binary on an ubuntu 18.04 server. I also created the template path as described by @hedin-hiervard: https://github.com/godotengine/godot-docs/issues/1247 with no difference at all. Any suggestions?

I was able to export from my continuous delivery server. (gocd)

Hope this can help someone else.

- buildStage: 
          jobs:            
            buildJob:
              resources:
                - linux
                - mingw5
              artifacts:
                - build:
                    source: "export_windows"
                - build:
                    source: "export_osx"
                - build:
                    source: "export_linux"
                - build:
                    source: "export_linux_server"
              tasks:
                - fetch:
                    artifact_origin: gocd
                    source: "godot_server.x11.opt.tools.64.llvm"
                    destination: ""
                    is_file: yes
                    pipeline: godot-groups
                    stage: defaultStage
                    job: serverJob
                - fetch:
                    artifact_origin: gocd
                    source: "godot.templates.tpz"
                    destination: ""
                    is_file: yes
                    pipeline: godot-groups
                    stage: templateZipStage
                    job: defaultJob      
                - exec: 
                    arguments:
                      - "-c"
                      - "mkdir -p groups"
                    command: "/bin/bash"
                - exec:
                    arguments:
                      - "-c"
                      - "chmod +x ../b/repo && HOME=`pwd` ../b/repo init -u https://example.com/example/example.git -m build.xml"
                    command: "/bin/bash"
                    working_directory: "groups"
                - exec:
                    arguments:
                      - "-c"
                      - "chmod +x ../b/repo && HOME=`pwd` ../b/repo sync --force-sync"
                    command: "/bin/bash"
                    working_directory: "groups"
                - exec:
                    arguments:
                      - "-c"
                      - "git lfs fetch" 
                    command: "/bin/bash"
                    working_directory: "groups"
                - exec:
                    arguments:
                      - "-c"
                      - "mkdir -p .local/share/godot/ .config .cache" 
                    command: "/bin/bash"
                    working_directory: "groups"
                - exec:
                    arguments:
                      - "-c"
                      - "unzip godot.templates.tpz" 
                    command: "/bin/bash"
                - exec:
                    arguments:
                      - "-c"
                      - "rm -rf .local/share/godot/templates/" 
                    command: "/bin/bash"
                - exec:
                    arguments:
                      - "-c"
                      - "mkdir -p .local/share/godot/templates/`cat templates/version.txt`" 
                    command: "/bin/bash"
                - exec:
                    arguments:
                      - "-c"
                      - "mkdir -p .local/share/godot/templates/`cat templates/version.txt`" 
                    command: "/bin/bash"
                - exec:
                    arguments:
                      - "-c"
                      - "cp templates/* .local/share/godot/templates/`cat templates/version.txt`" 
                    command: "/bin/bash"
                - exec:
                    arguments:
                      - "-c"
                      - "cp templates/* .local/share/godot/templates/`cat templates/version.txt`" 
                    command: "/bin/bash"
                - exec:
                    arguments:
                      - "-c"
                      - "rm -rf templates" 
                    command: "/bin/bash"
                - exec:
                    arguments:
                      - "-c"
                      - "rm -rf export_windows" 
                    command: "/bin/bash"
                - exec:
                    arguments:
                      - "-c"
                      - "mkdir -p export_windows" 
                    command: "/bin/bash"
                # ./godot_server.x11.opt.tools.64.llvm --version and version.txt must be corresponding
                - exec:
                    arguments:
                      - "-c"
                      - chmod +x godot_server.x11.opt.tools.64.llvm && HOME=`pwd` ./godot_server.x11.opt.tools.64.llvm --export "Windows Desktop" --path groups ../export_windows/groups.exe || true
                    command: "/bin/bash"
                - exec:
                    arguments:
                      - "-c"
                      - "rm -rf export_osx" 
                    command: "/bin/bash"
                - exec:
                    arguments:
                      - "-c"
                      - "mkdir -p export_osx" 
                    command: "/bin/bash"
                - exec:
                    arguments:
                      - "-c"
                      - chmod +x godot_server.x11.opt.tools.64.llvm && HOME=`pwd` ./godot_server.x11.opt.tools.64.llvm --export "Mac OSX" --path groups ../export_osx/groups.zip || true
                    command: "/bin/bash"
                - exec:
                    arguments:
                      - "-c"
                      - "rm -rf export_linux_server" 
                    command: "/bin/bash"
                - exec:
                    arguments:
                      - "-c"
                      - "mkdir -p export_linux_server" 
                    command: "/bin/bash"
                - exec:
                    arguments:
                      - "-c"
                      - chmod +x godot_server.x11.opt.tools.64.llvm && HOME=`pwd` ./godot_server.x11.opt.tools.64.llvm --export "Linux/X11 Server" --path groups ../export_linux_server/groups.x86_64 || true
                    command: "/bin/bash"
                - exec:
                    arguments:
                      - "-c"
                      - "rm -rf export_linux" 
                    command: "/bin/bash"
                - exec:
                    arguments:
                      - "-c"
                      - "mkdir -p export_linux" 
                    command: "/bin/bash"
                - exec:
                    arguments:
                      - "-c"
                      - chmod +x godot_server.x11.opt.tools.64.llvm && HOME=`pwd` ./godot_server.x11.opt.tools.64.llvm --export "Linux/X11" --path groups ../export_linux/groups.x86_64 || true
                    command: "/bin/bash"

Edit: typos.

I'm trying to export a blank Godot project on Gentoo Linux (with xdg-user-dirs installed). The headless build acts as if the ._sc_ file is present (which makes some sense, I guess, as headless is usually used for automated builds on servers).

However, it fails to create the cache dir (get_cache_path() returns './godot/cache' but it isn't created) and if I manually create that one, it get this:

Exporting Godot project to bin/Linux-AMD64/Test.x86_64
/opt/godot-3.0/bin/godot_headless.x11.tools.64 --export "Linux-AMD64" "bin/Linux-AMD64/Test.x86_64" project.godot -v
ERROR: initialize: AudioDriverManager: all drivers failed, falling back to dummy driver
   At: servers/audio_server.cpp:165.
CORE API HASH: 6850056324485626191
EDITOR API HASH: 2577452685349188824
load resource: res://default_env.tres
ERROR: create: Cannot create cache directory!
   At: editor/editor_settings.cpp:768.
load resource: res://default_env.tres
ERROR: copy: Failed to open 
   At: core/os/dir_access.cpp:304.
ERROR: _fs_changed: Project export failed with error code 12.
   At: editor/editor_node.cpp:471.
ERROR: save: Cannot save EditorSettings config, no valid path
   At: editor/editor_settings.cpp:938.
ERROR: ~List: Condition ' _first != __null ' is true.
   At: core/self_list.h:100.
ERROR: cleanup: There are still MemoryPool allocs in use at exit!
   At: core/dvector.cpp:70.
scons: done building targets.

The failed "Failed to open" message is supposed to be followed by a path, I believe.

Thanks @fire, finally got the headless linux binary cli export to work. The bit that finally did it for me was the fact that ~/.local/share/godot/templates/{version} has to match the version.txt in the export template's version.txt.

# This will work
cat ~/.local/share/godot/templates/3.0.6.stable/version.txt 
3.0.6.stable
# This will not work
cat ~/.local/share/godot/templates/3.0.5.stable/version.txt 
3.0.6.stable

After that the export worked on the project like a charm.

Further info:

Godot 3.0.6-stable

Trying to export using a self contained version of Godot causes:

ERROR: copy: Failed to open 
   At: core/os/dir_access.cpp:304.
ERROR: _fs_changed: Project export failed with error code 12.
   At: editor/editor_node.cpp:471.

EDIT:
Templates should be in 'editor_data/templates/3.0.6.stable/' and not just 'editor_data/templates/'
That is why it didn't work.

Hello there. As it so happens I'm also trying to set up a CI and had this not found export template error.

When we first build the game via the godot GUI editor it creates for us a file called export_presets.cfg in the project directory. I bet that --export uses this file to search for defined presets which is counter-intuitive.

So CLI works only after you manually create this file (in the proper format of course) or after you first export for the presets you want to use. And sure, have those version/editor_data/templates etc. properly set-up too.

You can commit export_presets.cfg into version control, but only if it doesn't contain sensitive information like an Android keystore password. (This is why sensitive information ought to be moved to a separate file, so that export_presets.cfg can be safely committed no matter what platforms you're exporting to.)

That's a good point. So what's the option here then? I mean where do you store the android pass so that godot reads it and sets up the settings? If you can't use export_presets.cfg for it?

Was this page helpful?
0 / 5 - 0 ratings