Can't use gsutil in Cloud Run instance?

323 views
Skip to first unread message

Adriano Matos

unread,
May 3, 2022, 5:44:10 PM5/3/22
to Google Cloud Developers
I am using the subprocess module in python to run the following command:

gsutil -m -o GSUtil:parallel_composite_upload_threshold=150M cp -r *.csv gs://2-treemap-extraction-ps-trigger

This works fine when running this Python script on my local machine. However, when running this same script in Cloud Run, I get the following error:

CommandException: Incorrect option(s) specified. Usage:

gsutil cp [OPTION]... src_url dst_url
gsutil cp [OPTION]... src_url... dst_url
gsutil cp [OPTION]... -I dst_url

I have no idea what could be the problem. I have changed nothing in my code when running it locally versus in Cloud Run. 

Ernesto Contreras Pinon

unread,
May 5, 2022, 12:17:10 PM5/5/22
to Google Cloud Developers

How are you installing gsutil into your container? Can you elaborate on how your app is configured and deployed to Cloud Run? I can confirm that using the stand-alone gsutil package from PyPi and deploying a simple service that runs your provided command using the subprocess module does indeed work. 

Adriano Matos

unread,
May 13, 2022, 3:13:36 AM5/13/22
to Google Cloud Developers

I'm so dumb. You are totally right. I was testing the code locally on my Windows machine and running it in Cloud Run based on Linux. I needed to include ./*csv  to tell my machine to look at the current directory. That solved the problem.
Reply all
Reply to author
Forward
0 new messages