lanoxx / tilda

A Gtk based drop down terminal for Linux and Unix
GNU General Public License v2.0
1.28k stars 161 forks source link

tilda --version throws error 'Cannot open display' when invoked via SSH #143

Closed nifr closed 9 years ago

nifr commented 9 years ago

I'm trying to set up a simple build-system for tilda with Vagrant. However when I try to get the installed version with ...

 vagrant ssh -c 'tilda --version'

... it throws the following error message.

Error parsing command-line options. Try "tilda --help"
to see all possible options.

Error message: Cannot open display: 

This is strange because ...

vagrant ssh -c 'tilda --help'

... prints to stdout as expected.

lanoxx commented 9 years ago

The help message is generated implicitly by GOption where as version requires that the parsing of options completes successfully. It seems that there is some kind of dependency to X although I am not sure why. As a work around I suggest to start tilda with X or at least use X forwarding in ssh.

nifr commented 9 years ago

Thanks for the quick reply and your awesome work with tilda.

There shouldn't be a dependency to X when invoking the --version command.

I worked around this for now but it would be nice to get this fixed somehow. It would be helpful to test the version of the build remotely without requiring X-Forwarding on the build-server.

pik commented 9 years ago

You could add g_option_context_set_description () to output the version on --help ? It's not very nice, but I'm not sure what can be done about GOption behaving like that.

lanoxx commented 9 years ago

I think I found a solution that fixes this issue, the reason is the call to gtk_get_option_group, when TRUE is passed to this function it will try to open the default screen and that fails if no screen is available (or if $DISPLAY is unset). By separating that from the parsing of the tilda options and handling it after the version option has been evaluation, we can prevent this dependency. I think for the other options it makes sense to check that the display is available since they all affect tilda and tilda wont run without a valid display.

@nifr Please test my commit, and if it works for you and has no unexpected side effects, then I will merge it into master.

lanoxx commented 9 years ago

@nifr Updated the branch to add additional error checking and a small comment to explain the reason for the change.

lanoxx commented 9 years ago

Please reopen if you can still reproduce it.