GoogleCloudPlatform / GoogleCloudPlatform/gsutil

gsutil fails to run when PYTHONSAFEPATH=1 is set

Open
#1,735 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
918
Forks
335
PR merge metrics
No merged PRs in 30d

Description

## Host information
Python version: 3.11.x (from Homebrew)
OS: macOS 13.4.1

## Steps to reproduce:
```bash
export PYTHONSAFEPATH=1
gsutil
```
Expected output:
```
Usage: gsutil [-D] [-DD] [-h header]... [-i service_account] [-m] [-o section:flag=value]... [-q] [-u user_project] [command [opts...] args...]
...
```
Actual output:
```
Traceback (most recent call last):
File "/Users/tkaplan/google-cloud-sdk/bin/bootstrapping/gsutil.py", line 15, in
import bootstrapping
ModuleNotFoundError: No module named 'bootstrapping'
```

## Context
`bazel run` sets this environment variable when running Python scripts (see https://github.com/bazelbuild/bazel/blob/b70914d269e1ee688a82606e92af6582bf67a56b/tools/python/python_bootstrap_template.txt#L485), this issue makes it difficult to shell out to `gsutil` from a Python script run by Bazel.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.