XF 2.1 xf-addon:build-release fails with error [E_WARNING] file_get_contents(....js) failed to open stream: No such file or directory

Earl

Well-known member
I get this error when I execute xf-addon:build-release Earl/ThreadChooser

[E_WARNING] file_get_contents(/var/www/html/src/addons/Earl/ThreadChooser/_build/upload/js/ThreadChooser/collapseTrigger.js): failed to open stream: No such file or directory
I have that file under _files/ directory (_files/js/ThreadChooser/collapseTrigger.js).
build.json file:
JSON:
{
  "minify": [
    "js/ThreadChooser/collapseTrigger.js"
  ]
}

What could be the problem? :rolleyes: Why is it not detecting that JavaScript file?
 
Jumped into another error after re-executing the xf-addon:build command for the next release (after bumping version)

Code:
$ xfcmd xf-addon:build-release Earl/ThreadChooser
Performing add-on export.

Exporting data for [Earl] Thread chooser to /var/www/html/src/addons/Earl/ThreadChooser/_data.
26/26 [============================] 100%
Written successfully.
Attempting to validate addon.json file...
JSON file validates successfully!

Building release ZIP.

In ReleaseBuilder.php line 327:
                                                                           
  Unexpected error while minifying JS: Empty result provided by the compiler.


Code:
Stack trace
#0 src/XF/Service/AddOn/ReleaseBuilder.php(255): XF\Service\AddOn\ReleaseBuilder->minifyJs(Array)
#1 src/XF/Service/AddOn/ReleaseBuilder.php(390): XF\Service\AddOn\ReleaseBuilder->performBuildTasks()
#2 src/XF/Cli/Command/AddOn/BuildRelease.php(84): XF\Service\AddOn\ReleaseBuilder->build()
#3 src/vendor/symfony/console/Command/Command.php(255): XF\Cli\Command\AddOn\BuildRelease->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 src/vendor/symfony/console/Application.php(982): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#5 src/vendor/symfony/console/Application.php(255): Symfony\Component\Console\Application->doRunCommand(Object(XF\Cli\Command\AddOn\BuildRelease), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#6 src/vendor/symfony/console/Application.php(148): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#7 src/XF/Cli/Runner.php(63): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#8 cmd.php(15): XF\Cli\Runner->run()
#9 {main}
HTML:
Request state
<pre class='xdebug-var-dump' dir='ltr'>
<small>/var/www/html/src/XF/Debugger.php:28:</small>
<b>array</b> <i>(size=1)</i>
  'cli' <font color='#888a85'>=&gt;</font> <small>string</small> <font color='#cc0000'>'cmd.php xf-addon:build-release Earl/ThreadChooser'</font> <i>(length=60)</i>
</pre>

any idea?
@TickTackk
 
Last edited:
It may just mean there is some content within that JavaScript file that it is unable to minify which may actually be down to a bug within the minifier itself (which is 3rd party) or a bug within the JavaScript.

There’s unlikely to be anything we can do about it.

You can try and use a different minifier and run it manually (there are many online) and include that file in the Zip manually.

Or you may consider whether it is necessary to minify it at all. If the file is fairly small to start with then I wouldn’t bother.
 
Okay, I figured it out today, finally!.

in XF\Service\AddOn\JSMinifire.php line 103 you have this API call
PHP:
        {
            $response = $client->post('https://closure-compiler.appspot.com/compile', [
                'form_params' => $options
            ]);

If it doesn't get the $response, it throws this error.

Note: If your internet connection has some issues, it cannot call this API, so it will get this empty $response. My internet connection was fine, but I was using a VPN, so it had some abused IP address, so this API host was have blocking it, so it reserves empty $response so it leads to this error
Unexpected error while minifying JS: Empty result provided

hope it'd help anyone who has the same error.
 
  • Like
Reactions: XKO
Back
Top Bottom