setup-gcloud icon indicating copy to clipboard operation
setup-gcloud copied to clipboard

gsutil is not working on windows

Open vohtaski opened this issue 4 years ago • 9 comments

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: image

Looks like gsutil it's looking python in the wrong place.

vohtaski avatar May 06 '20 09:05 vohtaski

I also tried to use the following setting:

      - run: gsutil
        shell: bash

and got the following issue, gcloud info worked. image

vohtaski avatar May 06 '20 10:05 vohtaski

This is probably related to https://github.com/GoogleCloudPlatform/github-actions/blob/dbbc2aaee4ded56fea9d438baacbdd875addfc3f/setup-gcloud/tests/integration-tests.sh#L26-L28.

sethvargo avatar May 06 '20 13:05 sethvargo

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"

vohtaski avatar May 06 '20 14:05 vohtaski

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

craigdbarber avatar May 06 '20 16:05 craigdbarber

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

splix avatar Jun 28 '20 17:06 splix

@averikitsch hi, can you please confirm if that was fixed in the master and the workarounds could be dropped? thanks

splix avatar Sep 03 '20 17:09 splix

Sorry, closed this prematurely - reopening

averikitsch avatar Sep 03 '20 17:09 averikitsch

Github is not working on window 7 version

mirzawaseembaig avatar Jan 09 '21 08:01 mirzawaseembaig

Anyone working on this? Is there a recommended workaround?

amacneil avatar Apr 04 '21 03:04 amacneil

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.

sethvargo avatar Dec 21 '23 04:12 sethvargo