cache icon indicating copy to clipboard operation
cache copied to clipboard

examples: "Using pip to get cache location" does not work with WIndows PowerShell (the default)

Open mgorny opened this issue 10 months ago • 3 comments

The example @ https://github.com/actions/cache/blob/6f1f1e10f3bad9846e298e7670d605f5674ddd17/examples.md#using-pip-to-get-cache-location does not work with Windows runners, as they use PowerShell by default. In particular, the following part:

- name: Get pip cache dir
  id: pip-cache
  run: |
    echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT

does not write into the output file since $GITHUB_OUTPUT evaluates to an empty string (apparently you need to use $env:GITHUB_OUTPUT for PowerShell but I haven't tested that). I've been able to get the action to work by forcing shell: bash — perhaps the example should do that to make the code more portable?

mgorny avatar Aug 13 '23 15:08 mgorny

This issue is stale because it has been open for 200 days with no activity. Leave a comment to avoid closing this issue in 5 days.

github-actions[bot] avatar Mar 01 '24 08:03 github-actions[bot]

Dear annoying bot, I'm sorry to say that ignoring the issue did not make it magically disappear. However, this annoyingly useless workflow has almost managed to make me let this issue rot and be closed. Maybe next time.

mgorny avatar Mar 01 '24 17:03 mgorny

Workaround - add shell: bash

- name: Get pip cache dir
  id: pip-cache
  shell: bash
  run: |
    echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT

Olegt0rr avatar Apr 16 '24 00:04 Olegt0rr