Openfl html5 -minify throwing error

Hi,

I tried minifying the code and following error occur:

openfl build html5 -minify
Called from ? line 1
Called from CommandLineTools.hx line 1330
Called from CommandLineTools.hx line 25
Called from a C function
Called from CommandLineTools.hx line 126
Called from CommandLineTools.hx line 567
Called from project/PlatformTarget.hx line 77
Called from platforms/HTML5Platform.hx line 61
Called from helpers/HTML5Helper.hx line 176
Called from /usr/lib/haxe/std/neko/_std/sys/FileSystem.hx line 38
Uncaught exception - std@sys_rename

Do i have to install something before compiling minified. Its happening in following command as well:

openfl build html5 -minify -yui

Doesn’t work for me either.

But I did a little digging and found that for some reason rename from /tmp to a file in /home doesn’t work (linux).
If I change PathHelper.getTemporaryFile to use the current working directory instead of /tmp then it works.
It’s not a permission issue, I can mv it without any problem.

Perhaps this is an issue with the updated Closure compiler, or does java work on your system?

Yes it works.

@ibilon please share your fix code, as I am not able to do similar.

It’s only a quick and dirty fix, the root cause of the problem will have to be found.

But in the meantime you can edit the file /usr/lib/haxe/lib/lime/2,1,1/lime/tools/helper/PathHelper.hx (or another version but line number may vary a little) line 334, inside the getTemporaryFile function.
replace
path += "/temp_" + Math.round (0xFFFFFF * Math.random ()) + extension;
with
path = Sys.getCwd() + "/temp_" + Math.round (0xFFFFFF * Math.random ()) + extension;

Then do a lime rebuild tools.

This works for me, hopefuly it’ll work for you too.

1 Like

What OS and version are you using? What are the permissions of your temp directory? I’ve used Ubuntu with this, fine (I think since changing the closure version as well) but it could be different folder permissions, or maybe a difference between Oracle Java 7 and another replacement for Java

I’m using OpenSuse 13.2 and my temp directory is 1777.

// Doesn't work (used by lime tool after the closure compiler has finished)
sys.FileSystem.rename("/tmp/temp_4766286.js", "/home/ibilon/test.js");
        
// Work
Sys.command("mv", ["/tmp/temp_4766286.js", "/home/ibilon/test.js"]);
        
// Work
sys.io.File.copy("/tmp/temp_4766286.js", "/home/ibilon/test.js");
sys.FileSystem.deleteFile("/tmp/temp_4766286.js");

I have no idea how FileSystem.rename work (I’ll look) but that does sound like a bug.

edit: tracked it to there https://github.com/HaxeFoundation/neko/blob/master/libs/std/sys.c#L284 but no idea what defines the rename c function.

Okay, great, that last sample seems best – we copy it over, then remove our temporary file. Would you mind doing a pull for this? We don’t have to understand all mysteries if we get it working anyway :wink:

No problem, https://github.com/openfl/lime/pull/344

Thank you! :success:

Thanks guys you are great :wink: