google-cloud-sdk needs python2 to work
mmoya opened this issue · comments
gcloud
needs python2
to work. The dependency shouldn't be optional.
Steps to reproduce:
$ yay -Q google-cloud-sdk
google-cloud-sdk 354.0.0-1
$ yay -Rs python2
$ python2
bash: python2: command not found
$ gcloud
/opt/google-cloud-sdk/bin/gcloud: line 194: /usr/bin/python2: No such file or directory
This is not the case for a default installation.
➜ pacman -Qi python2
error: package 'python2' was not found
➜ gcloud --version
Google Cloud SDK 354.0.0
alpha 2021.08.20
beta 2021.08.20
bq 2.0.71
core 2021.08.20
gsutil 4.67
➜ gcloud
ERROR: (gcloud) Command name argument expected.
Can you please include the output of `the following commands?
$ stat $(command -v python)
$ gcloud --verbosity=debug info
And additionally, for good measure:
$ cat /etc/profile.d/google-cloud-sdk.sh
$ stat $(command -v python)
File: /home/mmoya/.pyenv/shims/python
Size: 178 Blocks: 8 IO Block: 4096 regular file
Device: 0,41 Inode: 71697889 Links: 1
Access: (0755/-rwxr-xr-x) Uid: ( 1000/ mmoya) Gid: ( 1000/ mmoya)
Access: 2021-09-28 13:25:49.921052712 +0200
Modify: 2021-09-21 09:43:51.292299608 +0200
Change: 2021-09-21 09:43:51.292299608 +0200
Birth: 2021-09-21 09:43:51.292299608 +0200
$ gcloud --verbosity=debug info
DEBUG: Running [gcloud.info] with arguments: [--verbosity: "debug"]
INFO: Explicit Display.
Google Cloud SDK [357.0.0]
Platform: [Linux, x86_64] ('Linux', 'okonkolo', '5.10.68-1-lts', '#1 SMP Wed, 22 Sep 2021 11:00:42 +0000', 'x86_64', '')
Locale: ('en_US', 'UTF-8')
Python Version: [2.7.18 (default, Aug 23 2021, 14:19:19) [GCC 11.1.0]]
Python Location: [/usr/bin/python2]
Site Packages: [Disabled]
Installation Root: [/opt/google-cloud-sdk]
Installed Components:
core: [2021.09.10]
beta: [2021.09.10]
gsutil: [4.67]
bq: [2.0.71]
alpha: [2021.09.10]
System PATH: [/home/mmoya/.pyenv/shims:/home/mmoya/.pyenv/bin:/home/mmoya/go/bin:/home/mmoya/bin:/opt/google-cloud-sdk/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/var/lib/flatpak/exports/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl]
Python PATH: [/opt/google-cloud-sdk/lib/third_party:/opt/google-cloud-sdk/lib:/usr/lib/python27.zip:/usr/lib/python2.7:/usr/lib/python2.7/plat-linux2:/usr/lib/python2.7/lib-tk:/usr/lib/python2.7/lib-old:/usr/lib/python2.7/lib-dynload]
Cloud SDK on PATH: [True]
Kubectl on PATH: [/usr/bin/kubectl]
Installation Properties: [/opt/google-cloud-sdk/properties]
User Config Directory: [/home/mmoya/.config/gcloud]
Active Configuration Name: [sc]
Active Configuration Path: [/home/mmoya/.config/gcloud/configurations/config_sc]
Account: [mmoya@redacted]
Project: [None]
Current Properties:
[core]
account: [mmoya@redacted]
disable_usage_reporting: [true]
verbosity: [debug]
Logs Directory: [/home/mmoya/.config/gcloud/logs]
Last Log File: [/home/mmoya/.config/gcloud/logs/2021.09.28/13.28.05.390446.log]
git: [git version 2.33.0]
ssh: [OpenSSH_8.8p1, OpenSSL 1.1.1l 24 Aug 2021]
DEBUG: SDK update checks are disabled.
$ cat /etc/profile.d/google-cloud-sdk.sh
export CLOUDSDK_ROOT_DIR=/opt/google-cloud-sdk
export CLOUDSDK_PYTHON=python
export CLOUDSDK_PYTHON_ARGS=-S
export PATH=$CLOUDSDK_ROOT_DIR/bin:$PATH
export GOOGLE_CLOUD_SDK_HOME=$CLOUDSDK_ROOT_DIR
Do you have something installed at /usr/bin/python2
? Run stat /usr/bin/python /usr/bin/python2
.
^ That will help further debug your issue, but I should note, this is explicitly your issue. You are using pyenv
, which is proxying ~/.pyenv/shims/python
out to /usr/share/pyenv/libexec/pyenv-exec
, which is responsible for detecting the version of python you've configured your shell environment to use and exec
-ing out to it.
/opt/google-cloud-sdk/bin/gcloud
is a shim that simply uses exec
to hand off to the specified python version, which in this case is pointing to ~/mmoya/.pyenv/shims/python
.
I installed pyenv
to try to recreate your issue. Here's what happening under the hood.
gcloud
execs intoCLOUDSDK_PYTHON
, which is set topython
python
is really~/.pyenv/shims/python
~/.pyenv/shims/python
execs into/usr/share/pyenv/libexec/pyenv-exec
with the arguments"python"
and"<args...>"
, which ends up being something likeexec /usr/share/pyenv/libexec/pyenv-exec python "$CLOUDSDK_PYTHON_ARGS" "/opt/google-cloud-sdk/lib/gcloud.py" "<gcloud args...>"
/usr/share/pyenv/libexec/pyenv-exec
calls/usr/share/pyenv/libexec/pyenv-which
to determine the path to the python installation specified on the command line before handing off/usr/share/pyenv/libexec/pyenv-which
reports back/usr/bin/python2
/usr/share/pyenv/libexec/pyenv-exec
completes the chain by handing off to/usr/bin/python2
, which apparently doesn't exist.
I was not able to get pyenv-which
to report back /usr/bin/python2
for the argument python
unless I manually created a /usr/bin/python2
executable file and manually wrote /usr/bin/python2
into ~/.pyenv/version
. I'm going to close this out, because it is not a package or upstream issue, but would be interested in what you find out is causing your problem.
I'd recommend taking a look at your local ~/.pyenv/version
file, pyenv global
, pyenv versions
, pyenv which python
, and /usr/bin/python2
to further debug this.