isusanin / google-cloud-sdk

Automatically exported from code.google.com/p/google-cloud-sdk
0 stars 0 forks source link

$BROWSER with spaces crashes "gcloud init", probably mishandles %s too #635

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

export BROWSER='google-chrome --'
gcloud init

What is the expected output? What do you see instead?

Expected to authenticate via the browser, got

ERROR: gcloud crashed (OSError): [Errno 2] No such file or directory

What is the output of 'gcloud info'?

Google Cloud SDK [99.0.0]

Platform: [Linux, x86_64]
Python Version: [2.7.10 (default, Oct 14 2015, 16:09:02)  [GCC 5.2.1 20151010]]
Python Location: [/usr/bin/python2]
Site Packages: [Disabled]

Installation Root: [/usr/lib/google-cloud-sdk]
Installed Components:
  core: [2016.02.26]
  core-nix: [2016.02.26]
  gcloud: []
  gsutil-nix: [4.17]
  beta: [2016.02.26]
  gsutil: [4.17]
  bq: [2.0.18]
  alpha: [2016.02.26]
  bq-nix: [2.0.18]

Please provide any additional information below.

execve("/usr/bin/google-chrome --", ["google-chrome --", "--new-window", 
"https://accounts.google.com/o/oa"...], [/* 72 vars */]) = -1 ENOENT (No such 
file or directory)

http://manpages.ubuntu.com/manpages/wily/man1/man.1.html

     BROWSER
              If $BROWSER is set, its  value  is  a  colon-delimited  list  of
              commands,  each  of  which in turn is used to try to start a web
              browser for man --html.  In each command, %s is  replaced  by  a
              filename  containing  the HTML output from groff, %% is replaced
              by a single percent sign (%), and %c is replaced by a colon (:).

http://unix.stackexchange.com/questions/213367/where-do-editor-pager-browser-env
ironment-variables-come-from

Original issue reported on code.google.com by tommi.vi...@gmail.com on 8 Mar 2016 at 11:17

GoogleCodeExporter commented 8 years ago
Thanks for the feedback. So that we can investigate this further, can you 
please provide the following:

- Full output of `gcloud info` (removing personal info).
- Full stack trace.

Original comment by vil...@google.com on 8 Mar 2016 at 11:26

GoogleCodeExporter commented 8 years ago
I think this is working as intended: we use the Python webbrowser module, which 
has this to say about the $BROWSER environment variable 
(https://docs.python.org/2/library/webbrowser.html):

    If the environment variable BROWSER exists, it is interpreted to override the
    platform default list of browsers, as a os.pathsep-separated list of browsers to
    try in order. When the value of a list part contains the string %s, then it is
    interpreted as a literal browser command line to be used with the argument URL
    substituted for %s; if the part does not contain %s, it is simply interpreted as
    the name of the browser to launch.

So

    BROWSER='google-chrome --' python -c "import webbrowser; webbrowser.open('http://example.com/')"

doesn't work, but

    BROWSER='google-chrome -- %s' python -c "import webbrowser; webbrowser.open('http://example.com/')"

does. The sources you link aren't as explicit as to what happens in the case 
with no "%s" (and do seem to support your interpretation), but I don't think we 
want to break with the Python implementation here, especially since you have a 
workaround that makes both `gcloud` and `man` etc. happy.

Original comment by z...@google.com on 9 Mar 2016 at 3:37

GoogleCodeExporter commented 8 years ago
While I think that library is wrong (and/or $BROWSER is not really a standard), 
that's a valid workaround -- let's hope everything else implements %s..

Original comment by tommi.vi...@gmail.com on 9 Mar 2016 at 4:32