heroku / heroku-repo

Plugin for heroku CLI that can manipulate the repo
MIT License
682 stars 111 forks source link

repo:purge_cache fails with "Directory renamed before its status could be extracted" #103

Open edmorley opened 3 years ago

edmorley commented 3 years ago

Sometimes heroku repo:purge_cache fails with errors like:

$ heroku repo:purge_cache
Running set -e
Running set -e
mkdir -p tmp/repo_tmp/unpack
cd tmp/repo_tmp
curl -fo repo-cache.tgz 'https://s3-external-1.amazonaws.com/<REDACTED>'
cd unpack
tar -zxf ../repo-cache.tgz
METADATA="vendor/heroku"
if [ -d "$METADATA" ]; then
  TMPDIR=`mktemp -d`
  cp -rf $METADATA $TMPDIR
fi
cd ..
rm -rf unpack
mkdir unpack
cd unpack
TMPDATA="$TMPDIR/heroku"
VENDOR="vendor"
if [ -d "$TMPDATA" ]; then
  mkdir $VENDOR
  cp -rf $TMPDATA $VENDOR
  rm -rf $TMPDIR
fi
tar -zcf ../cache-repack.tgz .
curl -fo /dev/null --upload-file ../cache-repack.tgz 'https://s3-external-1.amazonaws.com/<REDACTED>'
exit on ⬢ REDACTED... up, run.1234 (Private-M)
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  371M  100  371M    0     0  33.2M      0  0:00:11  0:00:11 --:--:-- 11.2M
tar: ./node/cache/node_modules/webpack/node_modules/.bin: Directory renamed before its status could be extracted
tar: ./node/cache/node_modules/webpack/node_modules: Directory renamed before its status could be extracted
tar: ./node/cache/node_modules/webpack: Directory renamed before its status could be extracted
tar: ./node/cache/node_modules/global-modules/node_modules/.bin: Directory renamed before its status could be extracted
tar: ./node/cache/node_modules/global-modules/node_modules: Directory renamed before its status could be extracted
tar: ./node/cache/node_modules/global-modules: Directory renamed before its status could be extracted
tar: Exiting with failure status due to previous errors

As seen in: https://heroku.support/930885

edmorley commented 3 years ago

For anyone encountering this issue, the workaround is to use the heroku-builds CLI plugin instead, which has a very similar heroku builds:cache:purge command, that unlike repo:purge_cache doesn't attempt to download/repack the existing cache (for context on why heroku-repo does this, see #70), but instead deletes it outright: https://github.com/heroku/heroku-builds#purge-build-cache