Bunzip2: phantomjs-2.1.1-linux-x86_64.tar.bz2 is not a bzip2

My builds are sporadically failing with the error:

bunzip2: phantomjs-2.1.1-linux-x86_64.tar.bz2 is not a bzip2 file.
tar: phantomjs-2.1.1-linux-x86_64.tar: Cannot open: No such file or directory

I believe whatever source Circle is downloading PhantomJS from is occasionally serving an empty or corrupted file.

The same. Any solution how to avoid this problem?

PhantomJS has a note posted about this–they suggest using a CDN like so: PHANTOMJS_CDNURL=http://cnpmjs.org/downloads npm install phantomjs

I recommend going one step further. Do this in your dependencies phase and then make sure you’re caching the new install with cache_directories in your circle.yml.