gcloud installation permission issue on Ubuntu 12.04

nkRocks picture nkRocks · Jul 4, 2015 · Viewed 7.3k times · Source

I have installed PHP App Engine SDK first. Then, I installed Google Cloud SDK using:

sudo curl https://sdk.cloud.google.com | bash

but it's showing error while installing.

Then, I installed Google Cloud SDK from a zip file, but it shows an error at the final stage of installation:

  /home/nikhil/google-cloud-sdk/install.sh
Welcome to the Google Cloud SDK!
Traceback (most recent call last):
  File "/home/nikhil/google-cloud-sdk/bin/bootstrapping/install.py", line 20, in <module>
    from googlecloudsdk.gcloud import gcloud
  File "/home/nikhil/google-cloud-sdk/bin/bootstrapping/../../lib/googlecloudsdk/gcloud/gcloud.py", line 190, in <module>
    _cli = CreateCLI()
  File "/home/nikhil/google-cloud-sdk/bin/bootstrapping/../../lib/googlecloudsdk/gcloud/gcloud.py", line 188, in CreateCLI
    return loader.Generate()
  File "/home/nikhil/google-cloud-sdk/bin/bootstrapping/../../lib/googlecloudsdk/calliope/cli.py", line 304, in Generate
    cli = self.__MakeCLI(top_group)
  File "/home/nikhil/google-cloud-sdk/bin/bootstrapping/../../lib/googlecloudsdk/calliope/cli.py", line 467, in __MakeCLI
    log.AddFileLogging(self.__logs_dir)
  File "/home/nikhil/google-cloud-sdk/bin/bootstrapping/../../lib/googlecloudsdk/core/log.py", line 547, in AddFileLogging
    _log_manager.AddLogsDir(logs_dir=logs_dir)
  File "/home/nikhil/google-cloud-sdk/bin/bootstrapping/../../lib/googlecloudsdk/core/log.py", line 331, in AddLogsDir
    log_file = self._SetupLogsDir(logs_dir)
  File "/home/nikhil/google-cloud-sdk/bin/bootstrapping/../../lib/googlecloudsdk/core/log.py", line 408, in _SetupLogsDir
    os.makedirs(day_dir_path)
  File "/usr/lib/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/home/nikhil/.config/gcloud/logs/2015.07.03'

What should I do to complete installation?

Then, I tried gcloud info on terminal, but it's showing the error below:

nikhil@nikhil-Aspire-S3-391:~$ gcloud info
Traceback (most recent call last):
  File "/home/nikhil/google-cloud-sdk/./lib/googlecloudsdk/gcloud/gcloud.py", line 190, in <module>
    _cli = CreateCLI()
  File "/home/nikhil/google-cloud-sdk/./lib/googlecloudsdk/gcloud/gcloud.py", line 188, in CreateCLI
    return loader.Generate()
  File "/home/nikhil/google-cloud-sdk/./lib/googlecloudsdk/calliope/cli.py", line 304, in Generate
    cli = self.__MakeCLI(top_group)
  File "/home/nikhil/google-cloud-sdk/./lib/googlecloudsdk/calliope/cli.py", line 467, in __MakeCLI
    log.AddFileLogging(self.__logs_dir)
  File "/home/nikhil/google-cloud-sdk/./lib/googlecloudsdk/core/log.py", line 547, in AddFileLogging
    _log_manager.AddLogsDir(logs_dir=logs_dir)
  File "/home/nikhil/google-cloud-sdk/./lib/googlecloudsdk/core/log.py", line 331, in AddLogsDir
    log_file = self._SetupLogsDir(logs_dir)
  File "/home/nikhil/google-cloud-sdk/./lib/googlecloudsdk/core/log.py", line 408, in _SetupLogsDir
    os.makedirs(day_dir_path)
  File "/usr/lib/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/home/nikhil/.config/gcloud/logs/2015.07.04'

Answer

Zachary Newman picture Zachary Newman · Jul 6, 2015

This looks like a file permissions error in creating the directory /home/nikhil/.config/gcloud/logs/2015.07.04. Can you check the existence and file permissions for all of the parent directories?

ls -ld /home/nikhil/
ls -ld /home/nikhil/.config
ls -ld /home/nikhil/.config/gcloud
ls -ld /home/nikhil/.config/gcloud/logs
ls -ld /home/nikhil/.config/gcloud/logs/2015.07.04

Then upload the output to this question.

My hunch is that you've run a Cloud SDK command as the root user (generally not recommended), which created the /home/nikhil/.config/gcloud directory with root as the owner. If this is the case, the command:

sudo chown -R nikhil /home/nikhil/.config/gcloud

may fix the issue.


As an aside, the command sudo curl https://sdk.cloud.google.com | bash will not do what you want it to do; it executes curl as root, but the actual install will not happen as the root user. The Cloud SDK can be installed without root privileges, so I recommend simply curl https://sdk.cloud.google.com | bash.