Hey,
I'd need some help understanding what I'm doing wrong.
Expectation: path: ${{ env.LOCALAPPDATA }} points to C:\Users\runneradmin\AppData\Local.
runs-on: windows-latest
- name: Test print stuff
run: |
echo $env:LOCALAPPDATA
ls $env:LOCALAPPDATA
Test print stuff7s
Run echo $env:LOCALAPPDATA
C:\Users\runneradmin\AppData\Local
Directory: C:\Users\runneradmin\AppData\Local
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 11/11/2019 2:16 PM Google
d----- 11/17/2019 11:28 PM Microsoft
d----- 11/17/2019 9:44 PM Packages
d----- 11/17/2019 11:29 PM Temp
- name: Cache electron-builder dependencies
uses: actions/cache@v1
with:
path: ${{ env.LOCALAPPDATA }}electron-builder
Post Cache electron-builder dependencies3s
##[warning]The process 'C:\Program Files\Git\usr\bin\tar.exe' failed with exit code 2
Post job cleanup.
"C:\Program Files\Git\usr\bin\tar.exe" -cz --force-local -f d:/a/_temp/0b413849-9e8e-4665-894e-02bf8c693b6e/cache.tgz -C d:/a/my-project/my-project/electron-builder .
/usr/bin/tar: d\:/a/my-project/my-project/electron-builder: Cannot open: No such file or directory
/usr/bin/tar: Error is not recoverable: exiting now
##[warning]The process 'C:\Program Files\Git\usr\bin\tar.exe' failed with exit code 2
Meanwhile, path: C:\Users\runneradmin\AppData\Local\electron-builder works as expected.
The env context is limited to environment variables set for jobs, steps, and workflows. See context docs
You have a few options:
env context - name: Set env
run: echo "::set-env name=appdata::$($env:LOCALAPPDATA)"
- name: Cache electron-builder dependencies
uses: actions/cache@v1
with:
path: ${{ env.appdata }}\electron-builder
- name: Env output
id: output-env
run: echo "::set-output name=appdata::$env:LOCALAPPDATA"
- name: Cache electron-builder dependencies
uses: actions/cache@v1
with:
path: ${{ steps.output-env.outputs.appdata }}\electron-builder
~ to represent the user directory and append Appdata - name: Cache electron-builder dependencies
uses: actions/cache@v1
with:
path: ~\AppData\Local\electron-builder
The action will recognize ~ and replace it with the user directory, see https://github.com/actions/cache/blob/master/src/utils/actionUtils.ts#L80
Thanks! This resolves my issue.
To follow-up though, is there a reason for not having this variable available? It seemed like a commonly used system variable to me, maybe you could consider making it available in its original form. Cheers.
is there a reason for not having this variable available?
I'm not sure, right now the env context doesn't contain any environment variables from the runner itself, it's more of a "workflow" environment instead of the system environment.
Not sure if it warrants a feature request. If you agree that it's useful and you have the resources, perhaps add it to the backlog. :)
Most helpful comment
The
envcontext is limited to environment variables set for jobs, steps, and workflows. See context docsYou have a few options:
envcontext~to represent the user directory and append AppdataThe action will recognize
~and replace it with the user directory, see https://github.com/actions/cache/blob/master/src/utils/actionUtils.ts#L80