Phing and PharPackage - unable to create temporary file

For Storyplayer, we wanted to be able to distribute a phar file that users can run. This worked when I first started building it, but after adding a few dependencies I started seeing the error message Problem creating package: unable to create temporary file [wrapped: unable to create temporary file]. When using compression="gzip", we were running out of open file handles and erroring out. Disabling gzip compression solved the issue, but the archive was 50x larger than we wanted, so we went back to the drawing board.

The easy solution is to increase the open file limit for the current session. To do this, you use ulimit. Unforunately, you can do only increase the limit above the “hard” limit as root, so you need to do the following:

sudo su -
ulimit -n 20000 # Give ourselves a limit of 20000 open files
sudo su michael # Go back to our user, this is your username
phing your-task-name

This will increase the limit for the current session. Once you close the window / use a different one, your open file limit will be reset. To check your limit, run ulimit -n with no parameters.

August 01, 2013

Quick Fix