setup-gcloud
setup-gcloud copied to clipboard
gsutil is not working on windows
We are using setup-gcloud. It works perfectly on linux.
However on windows-latest we are having issues with gsutil
not being found while gcloud
is working.
This is the config that always returns an error
jobs:
release-win-to-gcs:
name: Release Win to GCP
runs-on: windows-latest
steps:
- name: Setup gcloud CLI for Dev
uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
with:
version: 'latest'
project_id: ${{ env.PROJECT_ID }}
service_account_email: ${{ env.SERVICE_ACCOUNT_EMAIL }}
service_account_key: ${{ secrets.DEV_GITHUB_CI_CD_SA_KEY}}
- run: gcloud info
- run: gsutil
Error:
Looks like gsutil
it's looking python in the wrong place.
I also tried to use the following setting:
- run: gsutil
shell: bash
and got the following issue, gcloud info
worked.
This is probably related to https://github.com/GoogleCloudPlatform/github-actions/blob/dbbc2aaee4ded56fea9d438baacbdd875addfc3f/setup-gcloud/tests/integration-tests.sh#L26-L28.
Made it work for now with the following:
$env:python_version=$(python -c 'import sys; print(\".\".join(map(str, sys.version_info[:3])))')
$env:CLOUDSDK_PYTHON="C:\hostedtoolcache\windows\Python\$env:python_version\x64\python"
Thanks for raising the issue @vohtaski This is indeed a known issue when the Windows distribution of the gcloud-sdk. Another workaround for Windows is documented here: https://cloud.google.com/storage/docs/gsutil_install#expandable-1-label
Another workaround. There is ${{env.pythonLocation}}
, which to my understanding comes from actions/setup-python
, and it contains the base path to Pyhton. The only only issue is that you need that only for Windows, so you have to duplicate everything.
Workflow may look like:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Setup GCP (windows)
uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
if: runner.os == 'Windows'
env:
CLOUDSDK_PYTHON: ${{env.pythonLocation}}\python.exe
with: ...
- name: Use GCP (windows)
run: gsutil cp ....
if: runner.os == 'Windows'
env:
CLOUDSDK_PYTHON: ${{env.pythonLocation}}\python.exe
@averikitsch hi, can you please confirm if that was fixed in the master and the workarounds could be dropped? thanks
Sorry, closed this prematurely - reopening
Github is not working on window 7 version
Anyone working on this? Is there a recommended workaround?
Hi folks - I'm going to close this out. For gsutil issues, please open an issue on the Google Cloud CLI tracker. Additionally, you may want to try gcloud storage
instead of gsutil
.