threads / bug / 33178

Fwd: Bug: git web--browse doesn't recognise browser on OS X

Subject: Fwd: Bug: git web--browse doesn't recognise browser on OS X

## tl;dr

11 messages between Mar 14, 2013 and Apr 4, 2013.

replies: 10people: 4as markdown or json

Timo Sand· Mar 14, 2013, 11:39 UTC · lore
Hi

I tried to open a website by runnin 'git web--browse http://google.com' and it replied 'No known browser available'. I also tried with '--browser=chrome' and '--browser=google-chrome' but the responded with 'The browser chrome is not available as 'chrome'.'

I expected the command to open a new tab in my browser in each of the 3 tries. This has worked for my system before.

OS X 10.8.2, git 1.8.2, Google Chrome 27.0.1438.7 dev

-- Timo Sand timo.j.sand+sig@gmail.com

Christian Couder· Mar 15, 2013, 11:19 UTC · re: Timo Sand · lore

Re: Bug: git web--browse doesn't recognise browser on OS X

Hi,
On Thu, Mar 14, 2013 at 12:39 PM, Timo Sand <timo.j.sand@gmail.com> wrote:
> Hi
>
> I tried to open a website by runnin 'git web--browse http://google.com'
> and it replied 'No known browser available'.

First git web--browse is a plumbing shell script to display documentation on a web browser when you type something like "git help -w log". It is not really supposed to be used directly by the user. On OS X it might be simpler to just type "open http://google.com".

That said there is the following in it to make it work on OS X:

# SECURITYSESSIONID indicates an OS X GUI login session if test -n "$SECURITYSESSIONID" \ -o "$TERM_PROGRAM" = "Apple_Terminal" ; then browser_candidates="open $browser_candidates" fi

So I guess that you don't have SECURITYSESSIONID set in your terminal and you are not using Apple Terminal.

As I am not using OS X, I have no idea how to improve the script in this case.
> I also tried with '--browser=chrome' and '--browser=google-chrome' but
> the responded with 'The browser chrome is not available as 'chrome'.'

Could you try something like: "chromium http://google.com" or "chromium-browser http://google.com" If it works, then using 'git web--browse' with '--browser=chromium' or '--browser=chromium-browser' should work.

Otherwise did you try "chrome http://google.com" and "google-chrome http://google.com"?

> I expected the command to open a new tab in my browser in each of the 3 tries.
> This has worked for my system before.
>
> OS X 10.8.2, git 1.8.2, Google Chrome 27.0.1438.7 dev

Thanks, Christian.

Timo Sand· Mar 22, 2013, 16:19 UTC · re: Christian Couder · lore

Re: Bug: git web--browse doesn't recognise browser on OS X

Hi,

well my use case is actually that I'm trying to use the gem 'gem-browse' which uses 'git web--browse' I'm not using Apple Terminal, I'm using iTerm2 and there doesn't seem to be a SECURITYSESSIONID set, at least echo didn't find any. But neither did I find it on Apple Terminal either.

What troubles me is that this issue has only arisen recently, earlier this worked fine for me

On 15 March 2013 11:19, Christian Couder <christian.couder@gmail.com> wrote:
Show 45 quoted lines
> Hi,
>
> On Thu, Mar 14, 2013 at 12:39 PM, Timo Sand <timo.j.sand@gmail.com> wrote:
>> Hi
>>
>> I tried to open a website by runnin 'git web--browse http://google.com'
>> and it replied 'No known browser available'.
>
> First git web--browse is a plumbing shell script to display
> documentation on a web browser when you type something like "git help
> -w log".
> It is not really supposed to be used directly by the user. On OS X it
> might be simpler to just type "open http://google.com".
>
> That said there is the following in it to make it work on OS X:
>
> # SECURITYSESSIONID indicates an OS X GUI login session
> if test -n "$SECURITYSESSIONID" \
> -o "$TERM_PROGRAM" = "Apple_Terminal" ; then
> browser_candidates="open $browser_candidates"
> fi
>
> So I guess that you don't have SECURITYSESSIONID set in your terminal
> and you are not using Apple Terminal.
>
> As I am not using OS X, I have no idea how to improve the script in this case.
>
>> I also tried with '--browser=chrome' and '--browser=google-chrome' but
>> the responded with 'The browser chrome is not available as 'chrome'.'
>
> Could you try something like: "chromium http://google.com" or
> "chromium-browser http://google.com"
> If it works, then using 'git web--browse' with '--browser=chromium' or
> '--browser=chromium-browser' should work.
>
> Otherwise did you try "chrome http://google.com" and "google-chrome
> http://google.com"?
>
>> I expected the command to open a new tab in my browser in each of the 3 tries.
>> This has worked for my system before.
>>
>> OS X 10.8.2, git 1.8.2, Google Chrome 27.0.1438.7 dev
>
> Thanks,
> Christian.
-- 
Timo Sand
timo.j.sand+sig@gmail.com
John Szakmeister· Mar 22, 2013, 17:36 UTC · re: Timo Sand · lore

Re: Bug: git web--browse doesn't recognise browser on OS X

On Fri, Mar 22, 2013 at 12:19 PM, Timo Sand <timo.j.sand@gmail.com> wrote:
Show 7 quoted lines
> Hi,
>
> well my use case is actually that I'm trying to use the gem
> 'gem-browse' which uses 'git web--browse'
> I'm not using Apple Terminal, I'm using iTerm2 and there doesn't seem
> to be a SECURITYSESSIONID set, at least echo didn't find any. But
> neither did I find it on Apple Terminal either.

I noticed this the other day, but I think SECURITYSESSIONID only gets set when Screen Sharing is enabled. I had Screen Sharing enabled, launched iTerm2 and saw the variable. I closed iTerm2, turned off Screen Sharing, and relaunched iTerm2 to find the variable missing. As a result, I'm not SECURITYSESSIONID is a good mechanism for determining whether the terminal is associated a GUI or not. Unfortunately, I don't know of a better way.

> What troubles me is that this issue has only arisen recently, earlier
> this worked fine for me
The following patch fixes the issue by recognizing iTerm2 as a GUI terminal.
-John
>From 5d282325f9374b25609a8704661c252304b4d18a Mon Sep 17 00:00:00 2001
Date: Fri, 22 Mar 2013 13:23:07 -0400
Subject: [PATCH] git-web--browse: recognize iTerm as a GUI terminal on OS X
Signed-off-by: John Szakmeister <john@szakmeister.net>
---
 git-web--browse.sh | 1 +
 1 file changed, 1 insertion(+)
diff --git a/git-web--browse.sh b/git-web--browse.sh
index 1e82726..1ff5379 100755
--- a/git-web--browse.sh
+++ b/git-web--browse.sh
@@ -120,6 +120,7 @@ if test -z "$browser" ; then
 	fi
 	# SECURITYSESSIONID indicates an OS X GUI login session
 	if test -n "$SECURITYSESSIONID" \
+		-o "$TERM_PROGRAM" = "iTerm.app" \
 		-o "$TERM_PROGRAM" = "Apple_Terminal" ; then
 		browser_candidates="open $browser_candidates"
 	fi
-- 
1.8.1.1
Christian Couder· Mar 24, 2013, 21:05 UTC · re: John Szakmeister · lore

Re: Bug: git web--browse doesn't recognise browser on OS X

On Fri, Mar 22, 2013 at 6:36 PM, John Szakmeister <john@szakmeister.net> wrote:
Show 21 quoted lines
> On Fri, Mar 22, 2013 at 12:19 PM, Timo Sand <timo.j.sand@gmail.com> wrote:
>> Hi,
>>
>> well my use case is actually that I'm trying to use the gem
>> 'gem-browse' which uses 'git web--browse'
>> I'm not using Apple Terminal, I'm using iTerm2 and there doesn't seem
>> to be a SECURITYSESSIONID set, at least echo didn't find any. But
>> neither did I find it on Apple Terminal either.
>
> I noticed this the other day, but I think SECURITYSESSIONID only gets
> set when Screen Sharing is enabled.  I had Screen Sharing enabled,
> launched iTerm2 and saw the variable.  I closed iTerm2, turned off
> Screen Sharing, and relaunched iTerm2 to find the variable missing.
> As a result, I'm not SECURITYSESSIONID is a good mechanism for
> determining whether the terminal is associated a GUI or not.
> Unfortunately, I don't know of a better way.
>
>> What troubles me is that this issue has only arisen recently, earlier
>> this worked fine for me
>
> The following patch fixes the issue by recognizing iTerm2 as a GUI terminal.

Your patch looks good to me, and I cannot really test it as I don't have a Mac. Could you just had some of the explanations you gave above to the commit message?

Thanks, Christian.

John Szakmeister· Mar 25, 2013, 10:13 UTC · re: Christian Couder · lore

[PATCH] git-web--browse: recognize iTerm as a GUI terminal on OS X

It turns out that the presence of SECURITYSESSIONID is not sufficient for detecting the presence of a GUI under Mac OS X. SECURITYSESSIONID appears to only be set when the user has Screen Sharing enabled. Disabling Screen Sharing and relaunching the shell showed that the variable was missing, at least under Mac OS X 10.6.8. As a result, let's check for iTerm directly via TERM_PROGRAM.

Signed-off-by: John Szakmeister <john@szakmeister.net>
---

On Sun, Mar 24, 2013 at 10:05:53PM +0100, Christian Couder wrote: [snip]

> Your patch looks good to me, and I cannot really test it as I don't have a Mac.
> Could you just had some of the explanations you gave above to the
> commit message?

Here's an updated patch. I also noticed that git-bisect.sh is also trying to determine if a GUI is present by looking for SECURITYSESSIONID as well. I wonder if it would be better to create a shell function in git-sh-setup.sh that the two scripts could use?

-John
git-web--browse.sh | 1 +
 1 file changed, 1 insertion(+)
diff --git a/git-web--browse.sh b/git-web--browse.sh
index 1e82726..1ff5379 100755
--- a/git-web--browse.sh
+++ b/git-web--browse.sh
@@ -120,6 +120,7 @@ if test -z "$browser" ; then
 	fi
 	# SECURITYSESSIONID indicates an OS X GUI login session
 	if test -n "$SECURITYSESSIONID" \
+		-o "$TERM_PROGRAM" = "iTerm.app" \
 		-o "$TERM_PROGRAM" = "Apple_Terminal" ; then
 		browser_candidates="open $browser_candidates"
 	fi
-- 
1.8.2
Christian Couder· Mar 25, 2013, 20:13 UTC · re: John Szakmeister · lore

Re: [PATCH] git-web--browse: recognize iTerm as a GUI terminal on OS X

On Mon, Mar 25, 2013 at 11:13 AM, John Szakmeister <john@szakmeister.net> wrote:
>
> Here's an updated patch.
Thank you for it. For what it's worth:
Acked-by: Christian Couder <chriscool@tuxfamily.org>
Show 5 quoted lines
> I also noticed that git-bisect.sh is
> also trying to determine if a GUI is present by looking for
> SECURITYSESSIONID as well.  I wonder if it would be better to
> create a shell function in git-sh-setup.sh that the two scripts
> could use?

Yeah, it might be a good idea to have some common functions to determine if a GUI is present. Maybe you could start with an os_x_gui_present() function in another patch on top of this one.

Thanks, Christian.

Junio C Hamano· Mar 25, 2013, 21:44 UTC · re: John Szakmeister · lore

Re: [PATCH] git-web--browse: recognize iTerm as a GUI terminal on OS X

John Szakmeister <john@szakmeister.net> writes:
Show 21 quoted lines
> It turns out that the presence of SECURITYSESSIONID is not sufficient
> for detecting the presence of a GUI under Mac OS X.  SECURITYSESSIONID
> appears to only be set when the user has Screen Sharing enabled.
> Disabling Screen Sharing and relaunching the shell showed that the
> variable was missing, at least under Mac OS X 10.6.8.  As a result,
> let's check for iTerm directly via TERM_PROGRAM.
>
> Signed-off-by: John Szakmeister <john@szakmeister.net>
> ---
>
> On Sun, Mar 24, 2013 at 10:05:53PM +0100, Christian Couder wrote:
> [snip]
>> Your patch looks good to me, and I cannot really test it as I don't have a Mac.
>> Could you just had some of the explanations you gave above to the
>> commit message?
>
> Here's an updated patch.  I also noticed that git-bisect.sh is
> also trying to determine if a GUI is present by looking for
> SECURITYSESSIONID as well.  I wonder if it would be better to
> create a shell function in git-sh-setup.sh that the two scripts
> could use?
Yes, but that can come later once this settles.
Your patch makes me wonder if
	test -n "$TERM_PROGRAM"

without any SECURITYSESSIONID or explicit program name checks should suffice, though.

Show 18 quoted lines
>
> -John
>
> git-web--browse.sh | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/git-web--browse.sh b/git-web--browse.sh
> index 1e82726..1ff5379 100755
> --- a/git-web--browse.sh
> +++ b/git-web--browse.sh
> @@ -120,6 +120,7 @@ if test -z "$browser" ; then
>  	fi
>  	# SECURITYSESSIONID indicates an OS X GUI login session
>  	if test -n "$SECURITYSESSIONID" \
> +		-o "$TERM_PROGRAM" = "iTerm.app" \
>  		-o "$TERM_PROGRAM" = "Apple_Terminal" ; then
>  		browser_candidates="open $browser_candidates"
>  	fi
John Szakmeister· Mar 26, 2013, 08:54 UTC · re: Junio C Hamano · lore

Re: [PATCH] git-web--browse: recognize iTerm as a GUI terminal on OS X

Sorry about the repeat Junio, I meant to hit "Reply to All".

On Mon, Mar 25, 2013 at 5:44 PM, Junio C Hamano <gitster@pobox.com> wrote: [snip]

Show 6 quoted lines
> Your patch makes me wonder if
>
>         test -n "$TERM_PROGRAM"
>
> without any SECURITYSESSIONID or explicit program name checks should
> suffice, though.

So, after downloading a couple of other terminals and trying things out, I think you're suggestion does suffice. Should I send an updated patch?

-John
Junio C Hamano· Mar 27, 2013, 14:43 UTC · re: John Szakmeister · lore

Re: [PATCH] git-web--browse: recognize iTerm as a GUI terminal on OS X

John Szakmeister <john@szakmeister.net> writes:
Show 14 quoted lines
> Sorry about the repeat Junio, I meant to hit "Reply to All".
>
> On Mon, Mar 25, 2013 at 5:44 PM, Junio C Hamano <gitster@pobox.com> wrote:
> [snip]
>> Your patch makes me wonder if
>>
>>         test -n "$TERM_PROGRAM"
>>
>> without any SECURITYSESSIONID or explicit program name checks should
>> suffice, though.
>
> So, after downloading a couple of other terminals and trying things
> out, I think you're suggestion does suffice.  Should I send an updated
> patch?
If that approach is better than what you originally sent, then yes.

But I do not use OS X, so you may need to pay attention to possible complaints and comments from other Mac users on this list for a while---there may be people who run the program in question without that environment variable.

John Szakmeister· Apr 4, 2013, 00:10 UTC · re: Junio C Hamano · lore

Re: [PATCH] git-web--browse: recognize iTerm as a GUI terminal on OS X

On Wed, Mar 27, 2013 at 10:43 AM, Junio C Hamano <gitster@pobox.com> wrote: [snip]

Show 6 quoted lines
> If that approach is better than what you originally sent, then yes.
>
> But I do not use OS X, so you may need to pay attention to possible
> complaints and comments from other Mac users on this list for a
> while---there may be people who run the program in question without
> that environment variable.

Sorry it has taken me so long to get back to this. I searched around and tried out a few terminal programs that are available, and I think what you queued--checking that TERM_PROGRAM is non-empty--is the right fix.

Thanks!
-John

← back to recent threads