|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73946 tar-based phar error on buildFromDirectory function
Submitted: 2017-01-16 11:05 UTC Modified: 2021-01-19 18:03 UTC
Avg. Score:4.0 ± 1.0
Reproduced:3 of 3 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (33.3%)
From: escalle dot emilien at gmail dot com Assigned: cmb (profile)
Status: Not a bug Package: PHAR related
PHP Version: 5.6.29 OS: debian 8.3
Private report: No CVE-ID: None
 [2017-01-16 11:05 UTC] escalle dot emilien at gmail dot com

I got an error when using \PharData::buildFromDirectory on a huge directory (608MB) : 

PharException - "tar-based phar "..." cannot be created, header for  file "..." could not be written"

I've checked the free disk space and RAM, everything seems to be ok.
I've delete the file which is specified by the error, but the errors occurs on another file.

The error is not verbose to understand what happens.

Test script:
$oTar = new \PharData('test_dir/test.tar.gz');
$oTar->buildFromDirectory('/test_dir_huge/'); // /test_dir_huge/ is a direcotry of 608MB
$oTarGz = $oTar->compress(\Phar::GZ);


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-01-16 11:16 UTC]
-Package: *General Issues +Package: PHAR related
 [2021-01-19 17:52 UTC]
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2021-01-19 17:52 UTC]
> on a huge directory (608MB)

That doesn't mean much, so I do some guesswork.  The minimum size
of a file plus its metadata in an uncompressed tar archive is 1
KiB.  If all the files in that directory would be 256 bytes, the
tarball would exceed the 2 GiB maximum size which is supported on
32 bit systems, what would explain the error.

Is that the case?  Otherwise, can you still reproduce this issue
with any of the actively supported PHP versions[1]?

[1] <>
 [2021-01-19 18:00 UTC] escalle dot emilien at gmail dot com
-Status: Feedback +Status: Assigned
 [2021-01-19 18:00 UTC] escalle dot emilien at gmail dot com
As the error was raised in January 2017, a great deal of water has flowed under the bridge since.

I didn't try to reproduce the error with new PHP version, and I will not, to be honest.
 [2021-01-19 18:03 UTC]
-Status: Assigned +Status: Not a bug
 [2021-01-19 18:03 UTC]
Thank you for taking the time to report a problem with PHP.
Unfortunately you are not using a current version of PHP --
the problem might already be fixed. Please download a new
PHP version from

If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Sep 27 09:03:37 2021 UTC