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.
Michael is a polyglot software engineer, committed to reducing complexity in systems and making them more predictable. Working with a variety of languages and tools, he shares his technical expertise to audiences all around the world at user groups and conferences. You can follow @mheap on Twitter