diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index e23ce3260daf84b4059fc6b0554b2f88eef56956..bbf04fb797f83dead30a1461b6f954a59a25a2e6 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -100,7 +100,7 @@ jobs:
 
       - name: Clear pip cache
         if: steps.pip_cache_packages.outputs.cache-hit != 'true'
-        run: rm -rf ${{ steps.init.outputs.pip_cache }}
+        run: python -c "from pip._internal.locations import USER_CACHE_DIR; from shutil import rmtree; rmtree(USER_CACHE_DIR, ignore_errors=True)"
 
       - name: Installing dependencies
         shell: bash